Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 22.214.171.124 release ready!
GCM as in Google cloud messaging gives us a way to implement/use push notifications in a easier way by using registration tokens. But these tokens are periodically or due to some reason can refresh/ regenrated . So the older one are not for use so we must manage them.
Before moving forward, you must have an implementation of GCM in your project. Each time the app unistalls and reinstalled a new token is created. Also to protect the client app and app server from potential malicious re-use of registration tokens, you should periodically initiate token refresh from the server. This causes the old token to be marked for deletion by GCM.Also when there is some error in clients app because of which multiple tokens are generated
All this can cause many problems like extra memory allocation at your server database, duplicate messages at clents app, etc. To solve the problem there are two methods
Method 1: Canonical Ids
Implementing canonical IDs can help you more easily recover from these situations. A canonical registration ID is the registration token of the last registration requested by the client app . This is the ID that the server should use when sending messages to the device.
If you try to send a message using an old registration token, GCM will process the request as usual, but it will include the canonical ID in the registration_id field of the response. Make sure to replace the registration token stored in your server with this canonical ID, as eventually the old registration token will stop working.
Now just delete those 2 registration ids.
Method 2: NotRegistered error message
When the old id expires or is changed by the new id then the old registration id is market for deletion by GCM and when your server sends a notification to that registration id , the server sends NotRegistered error message.So for every value you recieve NotRegistered error message, delete that token from your database.
Thats all, you can use any method that suits you best.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Webkul is a truly trusted and supported IT Company to develop business ideas for e-commerce. They provide professional support after deploying the solution to production and be responsible to act for fixing the reported issues or system errors. We highly encourage to deal with Webkul for business development.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.