简体   繁体   English

IOS7,8,9接收先前的推送通知行为

[英]IOS7,8,9 receive previous push notification behavior

I'm trying to develop an app to receive push notifications with a user account. 我正在尝试开发一个应用程序来接收用户帐户的推送通知。

(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

Once the registration successfully, the deviceToken is linked to a user account. 注册成功后,deviceToken将链接到用户帐户。

There is a scenario when the userA completes registration and uninstalls the app, the app ideally will not receive the push notification from APNs, but another userB installs it without registration, with the same iPhone, the iPhone will receive the userA 's push notification because the deviceToken is the same as previous. 有一种情况,当userA完成注册并卸载应用程序时,该应用程序理想情况下不会从APN接收推送通知,但另一个用户B安装它而无需注册,使用相同的iPhone,iPhone将收到userA的推送通知,因为deviceToken与之前相同。

In fact, the userB should not receive the userA 's push notification with the same device. 实际上, userB不应该使用相同的设备接收userA的推送通知。 Luckily, it only exists in IOS7,8 but not in iOS9 (iOS9 is disabled the push permission until the user grant the permission) 幸运的是,它只存在于IOS7,8但不存在于iOS9中(iOS9在用户授予权限之前禁用了推送权限)

How to solve it ? 怎么解决? Thanks 谢谢

One way of handling this issue is: 处理此问题的一种方法是:

1 ) As soon as user login to device do unregister your device for remote notification .This way, it will ensure that next set of notification won't reach to device even if application server sends it to device. 1)用户登录设备后,请立即取消注册设备以进行远程通知 。这样,即使应用程序服务器将设备发送到设备,也会确保下一组通知无法到达设备。

Sample code for how to unregister (see logout method): 有关如何取消注册的示例代码(请参阅注销方法):

https://github.com/AppLozic/Applozic-iOS-SDK/blob/af7b6b1e9ebeb2d7a7679a887e5d3a17b1b6b4ca/sample-with-framework/Applozic/Applozic/Services/ALRegisterUserClientService.m https://github.com/AppLozic/Applozic-iOS-SDK/blob/af7b6b1e9ebeb2d7a7679a887e5d3a17b1b6b4ca/sample-with-framework/Applozic/Applozic/Services/ALRegisterUserClientService.m

2) Register your device for remote notification again and send the new token to application server. 2)再次注册设备以进行远程通知,并将新令牌发送到应用程序服务器。 For extra check application server will do following. 对于额外检查,应用程序服务器将执行以

i) Check for the device token sent to application server, if same is linked with any other user (lets say userA )reset that token. i)检查发送到应用服务器的设备令牌,如果它与任何其他用户(比如userA)链接,则重置该令牌。

ii) Store device token and linked with the current user(Say userB ). ii)存储设备令牌并与当前用户链接(Say userB)。

Hope this will help. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM