为什么我百度云推送推送不了,日志报错setupChannel, isFirstLaunch,证书已经反复弄过好几遍了,只上传了开发证书,也不会出现错乱的的情况,在线等大神,求解答,求解答
解决方案 »
- 如何在windows 7安装iphone开发环境?
- iphone导航栏的title可以点击
- 我下载了一个电子书的源代码,想自己整理资料发送上app会通过审核吗?
- iphone中按提示弄音频接收, 在线等
- iphone娱乐应用上架 (dreamspace1.0)求改进建议!
- 为什么我在table view cell中添加的按钮不显示
- ios8向下兼容问题
- ios8 屏幕旋转 问题
- 问个在html5上播放视频的问题-100分立等可取。
- nsdata加密后转化为nsstring为nil
- tableview删除cell时总是报错 说增加的行与删除不一致
- UINavigationController 和UIViewController, UITabBarController的关系????
然后再获取到apn的deviceToken的时候,拿到deviceToken转成字符串,调用BPush的registerDeviceToken,参数是deviceToken字符串,然后BPush的bindChannel
最后在BPush的delegate回调OnMethod....里面可以查看百度推送绑定的结果以及绑定成功后的pushkey和pushChannel
差不多就这么多
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//百度推送
[BPush setupChannel:launchOptions];
[BPush setDelegate:self];
//apns注册
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];
}-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
/*
接收到苹果的token,先和本地的对比一下,如果不一样再绑定百度的推送
*/
const unsigned *tokenBytes = [deviceToken bytes];
NSString *hexToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",
ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
//将苹果返回的Token注册给百度
[BPush registerDeviceToken:deviceToken];
//该方法返回绑定成功时(delegate设定的OnMethod:response:),app才能接收消息,至少绑定一次,token变更需要重新绑定
[BPush bindChannel];
}- (void)onMethod:(NSString*)method response:(NSDictionary*)data
{
//参考demo自行判断成功与否,获取pushkey和chaneelkey
}
很久以前用过(可能不是最新的sdk),大概是这样,测试过是可以的,仅供参考(没有处理最新的ios8apns)