如何处理取消注册推送通知?
How to handle unregistering of push notifications?
拥有一个 Ionic 应用程序 (cordova),我正在使用这个 plugin 来处理通知推送。
我对 unregister
函数感到困惑。
正在阅读 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.
出于这些原因:
- 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.
所以我想知道如果真的不推荐,为什么会有注销客户端的功能。
确实,从逻辑上讲,通过阅读,我考虑在客户端实现自定义注销功能,如以下伪代码:
function unregister() {
deleteRegistrationIdFromServerDatabaseOnly();
}
=> 无需注销客户端本身。
确实,因为它在服务器数据库上存在 registrationId
和 userId
之间的映射,只需清空 registrationId
值,就不会再向客户端发送任何消息;什么是预期的。
因此,再次期待通知的唯一方法是让客户端再次注册。
所以,我再说一遍,need/use注销客户端本身的情况是什么?
确实不清楚。
我找到了以下 here
所以我认为取消注册的唯一用途是如果您想更改您的发件人 ID。我确信该 ID 也会在 google 服务器上占用一些资源,因此,如果您在从服务器中删除该 ID 后取消注册,这可能会对他们有所帮助
public void unregister ()
Unregister the application. Calling unregister() stops any messages
from the server. This is a blocking call—you shouldn't call it from
the UI thread. You should rarely (if ever) need to call this method.
Not only is it expensive in terms of resources, but it invalidates
your registration ID, which you should never change unnecessarily. A
better approach is to simply have your server stop sending messages.
Only use unregister if you want to change your sender ID.
Throws IOException if we can't connect to server to unregister.
拥有一个 Ionic 应用程序 (cordova),我正在使用这个 plugin 来处理通知推送。
我对 unregister
函数感到困惑。
正在阅读 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.
出于这些原因:
- 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.
所以我想知道如果真的不推荐,为什么会有注销客户端的功能。
确实,从逻辑上讲,通过阅读,我考虑在客户端实现自定义注销功能,如以下伪代码:
function unregister() {
deleteRegistrationIdFromServerDatabaseOnly();
}
=> 无需注销客户端本身。
确实,因为它在服务器数据库上存在 registrationId
和 userId
之间的映射,只需清空 registrationId
值,就不会再向客户端发送任何消息;什么是预期的。
因此,再次期待通知的唯一方法是让客户端再次注册。
所以,我再说一遍,need/use注销客户端本身的情况是什么?
确实不清楚。
我找到了以下 here
所以我认为取消注册的唯一用途是如果您想更改您的发件人 ID。我确信该 ID 也会在 google 服务器上占用一些资源,因此,如果您在从服务器中删除该 ID 后取消注册,这可能会对他们有所帮助
public void unregister ()
Unregister the application. Calling unregister() stops any messages from the server. This is a blocking call—you shouldn't call it from the UI thread. You should rarely (if ever) need to call this method. Not only is it expensive in terms of resources, but it invalidates your registration ID, which you should never change unnecessarily. A better approach is to simply have your server stop sending messages. Only use unregister if you want to change your sender ID.
Throws IOException if we can't connect to server to unregister.