Have problem with local notifications

Hi! I try to use Expo.Notifications.scheduleLocalNotificationAsync and Expo.Notifications.presentLocalNotificationAsync and i cant see any notifications in expo ios client on real device. Looks like other expo features works good, whats wrong with local notifications, or what am i doing wrong?

ios: 10.2
expo: 15.1.0
react-native: 0.43.3
expo-client(ios): 1.15.0

code exmaple:

await Notifications.cancelAllScheduledNotificationsAsync()
meals.map(async ({ label, time: { source } }, count) => {
  const id = await Notifications.scheduleLocalNotificationAsync({
    title: 'some title',
    body: label
  },
  { time: new Date(source).getTime() })
  meals[count].notificationId = id
})
2 Likes

I had this problem too.

  1. The notifications are only shown if the Expo client is closed.

  2. You have to add a listener with Notifications.addListener(...) to see/do anything “inside” your app.

1 Like

Notifications.addListener(...) is not firing up for me in iOS. The app is not in the foreground, I tried even turning off the screen and it is still not showing me in iOS

In my case the problem was with Permissions.askAsync(Permissions.NOTIFICATIONS). Once add the following snippet, it started working. Yes, notifications will show up only when the app is closed.

async componentDidMount() {
  let result = await Permissions.askAsync(Permissions.NOTIFICATIONS);
  if (Constants.isDevice && result.status === 'granted') {
    console.log('Notification permissions granted.')
  }
}
1 Like

Hi, anybody knows how to use intervalMs parameter for Notifications.scheduleLocalNotificationAsync().
I want to schedule a single notification to fire thrice a day.

Tried intervalMs parameter but its throwing following error:
java.lang.Double cannot be cast to java.lang.long. Kindly help.

3 Likes

did you solved the java.lang.Double cannot be cast to java.lang.long. problem?
im facing same error

1 Like

i still have error ( java.lang.Double cannot be cast to java.lang.long). any solution??
its making me crazy!