Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

Cancel all expo local scheduled notifications on iOS

$
0
0

I tried scheduling local notifications using expo (react native) and something very strange is happening.

This is the code I wrote:

const localNotification = {
  title: 'test',
  body: 'test body',
  ios: {
    sound: true
  }
};

let t = new Date();
t.setSeconds(t.getSeconds() + 10);

const schedulingOptions = {
  time: t, // (date or number) — A Date object representing when to fire the notification or a number in Unix epoch time. Example: (new Date()).getTime() + 1000 is one second from now.
  repeat: 'minute'
};

Notifications.scheduleLocalNotificationAsync(localNotification, schedulingOptions);

Then I started to receive the same notification every time the app is in background.

I removed that piece of code to use Notifications.presentLocalNotificationAsync() instead and I expected the previous notification to stop appearing as Notifications.scheduleLocalNotificationAsync() is never called anywhere in the whole app.

On Android I rebooted the phone and the notification doesn't appear anymore, but on iOS even after rebooting and reinstalling expo I keep getting the same scheduled notification.

I tried calling Notifications.cancelAllScheduledNotificationsAsync() with no luck.


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>