JPush极光推送会有时绑定不了registrationID的解决方法
来源:互联网 发布:gameloft java游戏 编辑:程序博客网 时间:2024/06/06 16:44
在使用极光推送的过程中,服务器端有时候会遇到设备绑定不了registrationID的状况。
经过排查发现,向服务器接口传registrationID的时候,一定几率极光推送的服务还没初始化完成,导致registrationID没有值。
然后发现极光的API里面有这个:
@class UILocalNotification;
extern NSString \*const kJPFNetworkDidSetupNotification; //建立连接
extern NSString \*const kJPFNetworkDidCloseNotification; //关闭连接
extern NSString \*const kJPFNetworkDidRegisterNotification; //注册成功
extern NSString \*const kJPFNetworkDidLoginNotification; //登录成功
extern NSString \*const
kJPFNetworkDidReceiveMessageNotification; //收到消息(非APNS)
extern NSString \*const kJPFServiceErrorNotification; //错误提示
一开始我从UILocalNotification这个命名,以为是以本地通知的形式传过来的,但是在
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
里没接收到通知。
然后翻阅极光的文档,在个角落发现了- -这个通知要自己注册的。。醉了。。
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
xxxxxx
//注册
NSNotificationCenter \*defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:selfselector:@selector(networkDidReceiveMessage:)name:kJPFNetworkDidLoginNotificationobject:nil];
}
//通知方法
- (void)networkDidLoginMessage:(NSNotification *)notification {
//调用接口
DLog(@"\n\n极光推送注册成功\n\n");
//通知后台registrationID
xxxxx
//注销通知
[[NSNotificationCenter defaultCenter] removeObserver:self name:kJPFNetworkDidLoginNotification object:nil];
}
这样就能防止registrationID还没生成,就调服务器接口的情况了
这个通知每次启动的时候都会走,所以最后还是要加个常量,来判断一下,只跟服务器进行一次绑定registrationID的通讯。
- JPush极光推送会有时绑定不了registrationID的解决方法
- Jpush极光推送获取RegistrationID
- 极光推送--RegistrationID
- jPush 极光推送的理解
- android 的jpush极光推送
- 获取JPush的registrationId
- 极光推送的设备唯一性标识 RegistrationID
- jpush极光推送平台的使用
- Android JPush(极光推送)的使用教程
- Android JPush(极光推送)的使用教程
- Android JPush(极光推送)的使用教
- Swift - JPush极光推送的使用
- Android JPush(极光推送)的使用教程
- JPush极光推送的android实现
- Android JPush的集成 极光推送
- Jpush 极光推送遇到的几个问题
- JPush极光推送的原理与简单demo的实现会遇到的问题
- 极光推送JPush
- AndroidStudio提交新项目到git@osc开源中国
- intellij idea使用maven本地仓库及修改本地仓库路径
- quartus仿真提示: Can't launch the ModelSim-Altera software
- requirejs原理深究以及r.js和gulp的打包
- composer入门
- JPush极光推送会有时绑定不了registrationID的解决方法
- 翻译《有关编程、重构及其他的终极问题?》——28.如果你可以使用简单的函数就不要使用宏
- java-day03-reflect-Field
- OC语言学习04-数组
- vue-router实现路由懒加载
- 怎么解决TortoiseGit每次Pull或者Push都需要输用户名密码的问题
- Python读取目录下子文件
- redis最大缓存设置策略
- composer的安装