I am using react-native-push-notification library. I am able to make notification appear along with vibration and sound.....however problem is that it keeps repeating and wont stop.
I get 20+ of the same notification in quick succession. Anyone know why this is happening?
See code below
import PushNotification from 'react-native-push-notification';
constructor(props) {
super(props);
PushNotification.configure({
onNotification: function(notification) {
console.log('NOTIFICATION:', notification);
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
popInitialNotification: true,
requestPermissions: true,
});
runPushNotification = () => {
PushNotification.localNotification({
title: 'title'
message: 'message',
playSound: true,
soundName: 'sound.mp3',
autoCancel: true,
vibrate: true,
vibration: 300,
actions: '["Yes", "No"]',
onlyAlertOnce: true,
});
};
For future viewers, if you are getting a notification there are 2 ways to do so, either as a push notification from an external server, or a local notification created from your apps own code.
If you are getting push notifications, then you need to check your server side logic to see that you aren’t firing them too many times.
If these are local notifications do a search through your code for any place you are calling the notification.
Doing both of these should lead to where it is being called excessively.