iOS: Device token and registerForRemoteNotificationTypes, didReceiveRemoteNotification
来源:互联网 发布:蛋白质数据库有哪些 编辑:程序博客网 时间:2024/06/05 17:26
Device token for an iPhone device生成之后就永远不变吗?
不是,if a device is wiped (应该是重装系统), it will get a new device token.
官方网站是这样写的: If the user restores backup data to a new device or computer, or reinstalls the operating system, the device token changes
正是因为device有可能改变,所以建议在app start时(即在didFinishLaunchingWithOptions 里)调用registerForRemoteNotificationTypes来获取device token以检查device token是否改变,如果改变了就应该把新token传给push provider。(官方描述:An application should register every time it launches and give its provider the current token)
device token应该存储在NSUserDefaults来达到新旧比较的目的
那么旧device token在push provider对应的record怎么办?
方案1:把旧device token send to provider and request delete record
方案2:使用apns feedback service。
方案2可能更好些,因为总是需要使用apns feedback service来处理用户在device里删除app的情况。
调用registerForRemoteNotificationTypes方法后,成功注册后,APNS就会返回一个device token,然后回调delegate methoddidRegisterForRemoteNotificationsWithDeviceToken, 如果注册失败,则回调delegate method didFailToRegisterForRemoteNotificationsWithError。
注意:
* 在第一次调用registerForRemoteNotificationTypes方法时没有联网,则既不会调用didRegisterForRemoteNotificationsWithDeviceToken,也不会调用didFailToRegisterForRemoteNotificationsWithError
*在第一次调用registerForRemoteNotificationTypes注册成功后,之后即使没有联网,再调用registerForRemoteNotificationTypes时都会以最上一次的device token作为参数回调didRegisterForRemoteNotificationsWithDeviceToken方法。
* (官方描述) If your application has previously registered, calling registerForRemoteNotificationTypes:
results in the operating system passing the device token to the delegate immediately without incurring additional overhead.
上述东东参考官方网站关于Registering for Remote Notifications的讲解
- iOS: Device token and registerForRemoteNotificationTypes, didReceiveRemoteNotification
- iOS: Device token and registerForRemoteNotificationTypes, didReceiveRemoteNotification
- registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later
- registerForRemoteNotificationTypes: is not supported in iOS 8.0 and late
- registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later
- registerForRemoteNotificationTypes: is not supported in iOS 8.0 and
- registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later
- registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later
- registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later
- iOS iOS8中 问题"registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later" 解决方案
- iOS 推送问题 registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later
- iOS iOS8中 问题"registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later" 解决方案
- [iOS] APNS: 如何check valid device token
- [iOS] APNS: 如何check valid device token
- iOS APNS device Token 是否会改变?
- iOS 的APNS device token特性
- device token
- IOS错误之 ---- registerForRemoteNotificationTypes: is not supported
- WebRTC现状及实现概要
- Java笔记6 网络编程<2>TCP、自定义图形界面浏览器、URL
- window 时间获取
- abap smartforms使用自定义格式打印输出重叠解决方案
- AS引用
- iOS: Device token and registerForRemoteNotificationTypes, didReceiveRemoteNotification
- 2013年,各大IT公司待遇—公司更多,数据更加真实(最终版)
- 自建项目push后再pull报The remote end hung up unexpectedly问题解决
- asp.net的web页面(aspx),数据量过多是提交失败
- ORA-02069: 此操作的global_names参数必须设置为TRUE
- 短信网关返回的短信内容编码怎么转换成中文
- C++学习笔记--标准库类型(vector,iterator,bitset)(二)
- 安装php加速器Zend guard loader出现无法加载,没有找到php5.dll 的错误
- 安装arcgis10.0时报错ORA-30512: 不能在事务处理超过一次修改SDE.ST_GEOMETRY_INDEX