Users getting multiple push notifications iOS
I am getting reports from users that are receiving multiple push notifications (iOS users this far). Some users are reporting 3 notifications, some 2 notifications, and I (and several others) are getting 1 notification.
Steps to reproduce
- I am not quite sure how to reproduce this, as I am not experiencing this myself.
- Create app that registers for remote notifications, and allows user (installation) to subscribe to channels.
- User might, or might not, delete and re-install the app (I think I have deleted and re-installed the app myself, and I am getting just 1 push notification).
- Send push notification through cloud code after certain object type is saved.
Expected Results
Users that are subscribing to a given channel is getting 1 push notification.
Actual Outcome
Some users are getting 3, some are getting 2 and some are getting 1 push notification.
Environment Setup
- Server
- parse-server version (Be specific! Don't say 'latest'.) : 2.2.21
- Operating System: (Heroku)
- Hardware: (Heroku)
- Localhost or remote server? Heroku
- Database
- MongoDB version: mLab (dont know version)
- Storage engine: mLab
- Hardware: mLab
- Localhost or remote server? mLab
Logs/Trace
Logs are not saying anything specific since the pushes are sent out with not errors from the server side.
Cloud code for sending push
Parse.Cloud.afterSave("Message", function(request) {
var channelName = request.object.get('channelName');
var text = request.object.get('text');
var shouldBeSentToEveryone = request.object.get('globalFavorite');
var query = new Parse.Query(Parse.Installation);
query.equalTo('channels', channelName);
if (shouldBeSentToEveryone === true) {
var query1 = new Parse.Query(Parse.Installation);
Parse.Push.send(
{
where: query1,
data:
{
alert: text,
badge: 1,
sound: 'default'
}
},
{
success: function() {
// s
},
error: function(error) {
// e
},
useMasterKey: true
});
} else {
Parse.Push.send(
{
where: query,
data:
{
alert: text,
badge: 1,
sound: 'default'
}
},
{
success: function() {
// s
},
error: function(error) {
// e
},
useMasterKey: true
});
}
});
I identified the installation of one of the customers that were reporting 3 push notifications. After filtering the Installation table for the deviceToken in that installation, I found 2 records in the database with the same deviceToken (so still a bit strange that the user got 3 push notifications?). The oldest installation was with an old version of the parse framework. I think I read somewhere that this was not so well handled in early versions of the parse framework.
I had the same issue: 3 installation objects were created for the same device token. Check the image: http://i.imgur.com/FaREYDa.png
Parse server: [email protected] Operating System: (Redhat) Hardware: (AWS) Localhost or remote server? AWS
iOS SDK: 1.12.0
Dear all, Do we have any update or solution for this issue?
I made a cloud code function for deleting all but the newest installation object with the same device token. All the duplicate installation objects were from an old parse sdk version.
this is still actually a problem though right? shouldn't this be fixed whenever a new installation is written? is there ever a case where 2 installations with the same device token make sense? if not why not just update an existing one if its there?