Recently I switched my application to production mode for push notification.
Then I scheduled the first notification through the dashboard and it worked well.
However, I received the same push notification 9 times. It never happened when I used development mode.
Should I register for push notification only once, or every time the application starts?
This is the code that executes every time the application starts.
var user = $ionicUser.get();
if (!user.user_id) {
$ionicUser.identifyAnonymous().then(function() {
registerForPushNotification();
});
} else {
$ionicUser.identify(user).then(function() {
registerForPushNotification();
});
}
function registerForPushNotification() {
$ionicPush.register({
canShowAlert: true,
canSetBadge: false,
canPlaySound: true,
canRunActionsOnWake: true,
onNotification: function(notification) {
displayNotification(notification);
}
});
}
Now I’m afraid to try it again since my users may experience the same thing.