简体   繁体   English

如果您在事先同意后禁用通知,Apple如何处理推送令牌?

[英]How does Apple handle push tokens if you disable notifications after agreeing to them prior?

I am working with Leanplum and having trouble finding documentation around apples push tokens. 我正在与Leanplum合作,无法找到有关苹果推送令牌的文档。 The main question is if a user originally accepts notifications when the app is installed and a push token is generated but then disables notifications later on, does the phone itself restrict the notification or is it done on apples push servers? 主要问题是,用户最初是在安装该应用程序时生成通知,还是在生成推送令牌后又在以后禁用通知,那么手机本身是否会限制通知,还是在苹果推送服务器上完成通知? Mainly just trying to understand the process flow. 主要只是试图了解流程。

From what I've read the push token is the same unless the user resets their phone. 根据我的阅读,推送令牌是相同的,除非用户重置手机。 So if leanplum has a push token for a user and we try to send a push notification after they went and disabled notifications what actually happens? 因此,如果leanplum为用户提供了推送令牌,并且我们尝试在用户离开后发送推送通知并禁用了通知,那么实际上会发生什么? Will leanplum remove the token or will that token be invalid? leanplum会删除令牌还是该令牌无效? I understand this is vague, I'm just trying to learn more about what's going on under the hood with apples push process. 我知道这很模糊,我只是想了解更多有关苹果推送过程中幕后情况的信息。 Thanks for any help! 谢谢你的帮助!

Summary 摘要

User permission has no effect on remote push notifications, and thus APNs registration (ie, token retrieval) is not affected. 用户权限对远程推送通知没有影响,因此APNs注册(即令牌检索)不受影响。 Therefore, your server-side push notification logic does not need to feel the impact of a user denying your application permission to present user-facing push notifications. 因此,您的服务器端推送通知逻辑不需要感觉到用户拒绝您的应用程序权限来呈现面向用户的推送通知的影响。 You will continue to receive your remote push notifications even when the user does not consent to seeing them. 即使用户不同意您看到远程推送通知,您也将继续收到。 The difference is that with a lack of permission, your push notifications are considered background remote notifications. 不同之处在于,由于缺少权限,您的推送通知被视为后台远程通知。 Continue reading for further explanation. 继续阅读以获取进一步的解释。


Remote Push Notifications vs. User Notifications 远程推送通知与用户通知

APNs is a service that has the ability to remotely send a payload to a particular device, as identified by the app-device-specific token provided when registering for remote notifications. APNs是一项能够将有效负载远程发送到特定设备的服务,这由注册远程通知时提供的特定于应用程序设备的令牌标识。 Push notifications seen by the user are not necessarily the same as a plain remote push notification. 用户看到的推送通知不一定与普通的远程推送通知相同。 Remote notifications do not need explicit permission to be granted by the user. 远程通知不需要用户明确授予的权限。 However, if the push notification is to be displayed to the user, only then is permission required. 但是,如果要将推送通知显示给用户,则只有这样才需要权限。


User Permission & Server-Side of Push Notifications 用户权限和服务器端的推送通知

To more directly answer your question: When your application launches you should register for remote notifications. 要更直接地回答您的问题:在应用程序启动时,您应该注册以获取远程通知。 That call will fetch an app-device token from APNs and then return it to you. 该调用将从APN中获取应用程序设备令牌,然后将其返回给您。 If something prevented the registration from succeeding, another delegate method is called. 如果由于某种原因阻止注册成功,则调用另一个委托方法。 Once you've registered for remote notifications, only then should you request user permission to display notifications to them. 注册了远程通知后,只有在那时,您才应该请求用户权限才能向他们显示通知。 The user permission is only to display the notifications, so APNs will still work as intended without any change on the server-side. 用户权限仅用于显示通知,因此APN仍将按预期工作,而无需在服务器端进行任何更改。 The only difference is how the device presents the information. 唯一的区别是设备如何显示信息。

- (void)applicationDidFinishLaunching:(UIApplication *)app {
    // Configure the user interactions first.
    [self configureUserInteractions];

    // Register for remote notifications.
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}

// Handle remote notification registration.
- (void)application:(UIApplication *)app
        didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
    // Forward the token to your provider, using a custom method.
    // Setup user notifications.
    [self enableRemoteNotificationFeatures];
    [self forwardTokenToServer:devTokenBytes];
}

- (void)application:(UIApplication *)app
        didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
    // The token is not currently available.
    NSLog(@"Remote notification support is unavailable due to error: %@", err);
    [self disableRemoteNotificationFeatures];
}

References: 参考文献:

Local and Remote Notification Programming Guide – Configuring Remote Notification Support 本地和远程通知编程指南–配置远程通知支持

Experience from using solely remote notifications (ie, background) and user notifications. 从仅使用远程通知(即后台)和用户通知的经验。

Leanplum SDK simply uploads the push token to the Leanplum dashboard (server). Leanplum SDK只需将推送令牌上传到Leanplum仪表板(服务器)。 Leanplum will use that token to talk to APNS (Apple Push Notification Service) and APNS talks to the device to show a push. Leanplum将使用该令牌与APNS(Apple Push Notification Service)进行对话,而APNS与设备进行对话以显示推送。 Leanplum will remove the token if it is expired or invalidated. 如果令牌过期或无效,Leanplum将删除该令牌。

User's device is talking to APNS constantly. 用户的设备一直在与APNS通信。 So when the user disables notification on their phone, it simply ignores the pushes from Leanplum. 因此,当用户禁用手机通知时,它只会忽略Leanplum的推送。 It does not remove the push token immediately. 它不会立即删除推送令牌。 Take it with grain of salt but I'm pretty sure the token does get expired at some point. 把它和盐一起吃,但是我很确定令牌确实在某个时候过期了。

One case that we know when the token get invalidated is when user uninstalls the app. 我们知道令牌失效的一种情况是用户卸载应用程序的时间。 That's how Leanplum tracks uninstalls. 这就是Leanplum跟踪卸载的方式。 It's not completely accurate as same user can reinstall the app and track as uninstall but it's the closest thing we got. 这不是完全准确,因为同一用户可以重新安装该应用程序并跟踪其卸载,但这是我们得到的最接近的结果。

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

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