RegistrationId 是每个设备吗?
Is RegistrationId per device?
我正在使用 this tutorial 作为指南从我的后端实现对 Azure 通知中心的注册。我的应用程序需要身份验证,但用户可以注销并使用另一个帐户重新登录。 RegistrationId 应该基于唯一设备还是用户和设备的组合?换句话说,我是否应该在每次注销时都清除 RegistrationId?当用户注销,以另一个用户身份重新登录,但随后又以原始用户身份重新登录时,我们应该创建一个新的 RegistrationId 还是继续使用原来的 RegistrationId?
GCM documentation for registering client apps 声明如下:
Developers should never unregister the client app as a mechanism for logout or
for switching between users, for the following reasons:
- A registration token isn't associated with a particular logged in
user. If the client app unregisters and then re-registers, the app can
receive the same registration token or a different registration token.
- Unregistration and re-registration may each take up to five minutes to
propagate. During this time messages may be rejected due to the
unregistered state, and messages may go to the wrong user.
To make sure that messages go to the intended user:
- The app server can maintain a mapping between the current user and the
registration token.
- The client app can then check to ensure that
messages it receives match the logged in user.
这也适用于其他推送通知服务,例如iOS.
推送通知服务注册标识一台设备上的特定应用程序。
使用 Azure 通知中心,从技术上讲,您可以在单个设备上为特定应用程序注册多个 Azure 通知中心,甚至可以在登录和注销时注册和注销(仅在 Azure 通知中心,而不是在特定平台上)推送通知系统),但这很容易出错,有更好的方法:
- 一旦您希望能够接收推送通知,请尽快在 Azure 通知中心注册您的应用程序,只有在您希望停止接收推送通知时才取消注册。其实你可以在应用程序启动时注册,永远不会注销。
- 如果用户登录,请将带有用户 ID(例如“user:123”)的标签添加到注册中,如果他注销,请再次删除该标签。
- 这样,您就可以只使用标签来寻址特定用户登录的设备,请参阅 Azure Notification Hubs Routing and Tag Expressions。
修改标签也在the tutorial you linked中描述。
我正在使用 this tutorial 作为指南从我的后端实现对 Azure 通知中心的注册。我的应用程序需要身份验证,但用户可以注销并使用另一个帐户重新登录。 RegistrationId 应该基于唯一设备还是用户和设备的组合?换句话说,我是否应该在每次注销时都清除 RegistrationId?当用户注销,以另一个用户身份重新登录,但随后又以原始用户身份重新登录时,我们应该创建一个新的 RegistrationId 还是继续使用原来的 RegistrationId?
GCM documentation for registering client apps 声明如下:
Developers should never unregister the client app as a mechanism for logout or for switching between users, for the following reasons:
- A registration token isn't associated with a particular logged in user. If the client app unregisters and then re-registers, the app can receive the same registration token or a different registration token.
- Unregistration and re-registration may each take up to five minutes to propagate. During this time messages may be rejected due to the unregistered state, and messages may go to the wrong user.
To make sure that messages go to the intended user:
- The app server can maintain a mapping between the current user and the registration token.
- The client app can then check to ensure that messages it receives match the logged in user.
这也适用于其他推送通知服务,例如iOS.
推送通知服务注册标识一台设备上的特定应用程序。
使用 Azure 通知中心,从技术上讲,您可以在单个设备上为特定应用程序注册多个 Azure 通知中心,甚至可以在登录和注销时注册和注销(仅在 Azure 通知中心,而不是在特定平台上)推送通知系统),但这很容易出错,有更好的方法:
- 一旦您希望能够接收推送通知,请尽快在 Azure 通知中心注册您的应用程序,只有在您希望停止接收推送通知时才取消注册。其实你可以在应用程序启动时注册,永远不会注销。
- 如果用户登录,请将带有用户 ID(例如“user:123”)的标签添加到注册中,如果他注销,请再次删除该标签。
- 这样,您就可以只使用标签来寻址特定用户登录的设备,请参阅 Azure Notification Hubs Routing and Tag Expressions。
修改标签也在the tutorial you linked中描述。