Two pushes coming through when only one is sent and app is open

Hello,
I have got push notification set up and working between my device and simulator. When I push a push notification to my device (from simulator or the dashboard) two push notifications seem to come through.
The reason I say “seem” is that if the phone is locked then only one push comes through as expected. If I have the phone unlocked then the push appears and a second later it appears again. This isn’t due to multiple devices registered or multiple pushes being sent through, it seems to be something being picked up wrong as when the phone is locked the pushes are dealt with fine. Also because looking at the dashboard I can see the single push being staged and sent.
I have made a video showing this occurring but couldn’t attach it to the files. I have therefore attached some screenshots showing the first push being replaced by the second identical push. You can download a copy of the video here.
If you have any ideas of the cause of this it would be great to know, even it is an issue with Apples recognition of the pushes.
Simon

Hi Simon,

I cannot reproduce this issue with our sample project (see in attachment). When I publish a message from device, simulator or dashboard, only one message is received.

Please try our project (change Bundle Identifier, AppId and secretKey by yours), could you reproduce this issue with it?

Regards,
Slava

TestPushNotify.zip (20.56MB)

I had the same issue. It took me some time to realize the cause. What worked for me was replacing

backendless.messaging.registerForRemoteNotifications()

with

let settings = UIUserNotificationSettings(forTypes: [.Alert, .Sound, .Badge], categories: nil)

UIApplication.sharedApplication().registerUserNotificationSettings(settings)

Hi Vyacheslav,

The comment posted by Florin has helped me make some progress with this issue.

Currently we already register our device for push notifications

First we register our Backendless push handler which calls all the Backendless code

[self.pushHandler registerForPushNotificationsWithApplication:app launchOptions:options];

Then we call the following code:

if ([app respondsToSelector:@selector(registerUserNotificationSettings:)]) {
        UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
                                                        UIUserNotificationTypeBadge |
                                                        UIUserNotificationTypeSound);


        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
                                                                                 categories:nil];
        [app registerUserNotificationSettings:settings];
        [app registerForRemoteNotifications];
    }
    else {
        // Register for Push Notifications before iOS 8
        [app registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                                 UIRemoteNotificationTypeAlert |
                                                 UIRemoteNotificationTypeSound)];
    }

This is left over code from using Parse where we still had to manually register the device.

I suspect that we are registering the device twice and so each push notification is being dealt with twice.

As I see I have two options:

  • Remove the Backendless registerForRemoteNotification code
  • Remove the above register for notification code

Will removing the Backendless code causing any issues with functionality? Similarly does the Backendless code run a similar code to the one I have copied above?

Any advice would be very welcome.

Note: Currently I have tested removing them both and in each case the double push notification stops. I am happy that this will fix the problem but don’t want to unknowingly cause more problems by removing needed code.

Simon

Simon, please see how our sample project is organized, it works without any problems.

Yes, the code above is run in Backendless SDK registerForRemoteNotifications method.