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

React Native - Clear previous push notifications on receiving local push notification

$
0
0

I'm using react-native-push-notification for scheduling and generating local push notifications in React Native and I'm trying to clear previously received notification on receiving any scheduled notification or auto remove currently received notification after sometime but I can't find any way to achieve it on iOS. One way is to use timeoutAfter property provided by the library which is for android only. For iOS, other way is to use PushNotificationIOS.removeAllDeliveredNotifications() if I can call any method on receiving local notification but onNotification() doesn't trigger on receiving local notification. It only triggers when receiving or tapping remote notification or tapping local notification. Is there any other way or any other library to achieve this? This is my code for scheduling local notifications:

PushNotification.localNotificationSchedule({    channelId: 'channelId',    id,    message: '...',    timeoutAfter: 10000,    soundName: 'default',});

notification config:

PushNotification.configure({    onRegister: function (token) {        console.log('TOKEN:', token);    },    onNotification: function (notification) {        console.log('NOTIFICATION:', notification);    },    onAction: function (notification) {        console.log('ACTION:', notification.action);        console.log('NOTIFICATION:', notification);        // process the action    },    onRegistrationError: function (err) {        console.error(err.message, err);    },    permissions: {        alert: true,        badge: true,        sound: true,    },    popInitialNotification: true,    requestPermissions: Platform.OS === OS.IOS,});

Viewing all articles
Browse latest Browse all 16552

Trending Articles



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