w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Android Parse Push notification device registration only one time on one device

PushService.subscribe seems to cache the subscription in local storage, to avoid re-subscribing when you launch the app multiple times.

This is what the first parameter of that method is used for :

context - This is used to access local storage to cache the subscription, so it must currently be a viable context.

(quote from here).

However, when you uninstall the app, local storage for that app is wiped from your device, so the new installation will cause PushService.subscribe to re-register to Google Cloud Messaging. If the new registration returns a new registration ID, Parse would have two registration IDs that can be used to send push notifications to your app, and both of them would be linked to the same userName you supplied to subscribe. Therefore sending a notification to that userName will send it to both registration IDs, causing it to arrive twice.

When Parse send the notifications for you, they should get from Google a response with canonical_registration_id, which will let them know one of the registration IDs associated with your app on your device is old, and should not be used anymore. Therefore (assuming Parse have a decent implementation of GCM) the next time you send a notification to your device, you should receive it only once.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.