Owning an Ionic application (cordova), I'm using this plugin to handle pushing of notifications.
I'm confused regarding the unregister
function.
Reading the official GCM documentation:
You should only need to unregister in rare cases, such as if you want an app to stop receiving messages, or if you suspect that the registration ID has been compromised. In general, once an app has a registration ID, you shouldn't need to change it.
For those reasons:
- A registration ID isn't associated with a particular logged in user. If you unregister and then re-register, GCM may return the same ID or a different ID—there's no guarantee either way.
- Unregistration may take up to 5 minutes to propagate.
- After unregistration, re-registration may again take up to 5 minutes to propagate. During this time messages may be rejected due to the state of being unregistered, and after all this, messages may still go to the wrong user.
So I wonder why there is the functionality of unregistering client if this is really not recommended.
Indeed, logically, by reading that, I think about implementing a custom unregister function at client side like the following pseudo-code:
function unregister() {
deleteRegistrationIdFromServerDatabaseOnly();
}
=> no need to unregister the client itself.
Indeed, as it exists a mapping on the server database between registrationId
and userId
, by just emptying the registrationId
value, no message would be sent to the client any more; what is expected.
Therefore, the only way to expect notifications again would be to let the client register again.
So, I repeat, what is the need/use case of unregistering the client itself?
It's really not clear.