APNs-百度推送使用总结(二)
来源:互联网 发布:truncate删除部分数据 编辑:程序博客网 时间:2024/05/16 01:55
//推送相关的设置
[BPushsetupChannel:launchOptions];
// 必须。参数对象必须实现(void)onMethod:(NSString*)method response:(NSDictionary*)data 方法,本示例中为 self
[BPushsetDelegate:self];
//推送的通知事件
[[UIApplicationsharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert |UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge)];
if (launchOptions) {
//截取apns推送的消息
NSDictionary* pushInfo = [launchOptionsobjectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
//[self setRemoteInfo:pushInfo];
//[[NSNotificationCenter defaultCenter] postNotificationName:kMessageDidChangeNofication object:nil];
//获取推送详情
NSString *pushInfoStr = [NSString stringWithFormat:@"%@",[pushInfo objectForKey:@"aps"]];
NSLog(@"aps : %@",pushInfoStr);
}
#pragma mark - PNS Push Service
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[application setApplicationIconBadgeNumber:0];
//[self setRemoteInfo:userInfo];
[BPushhandleNotification:userInfo];
NSLog(@"RemoteInfo : %@",userInfo);
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
#warning BPush - 自定义一个方法提交设备信息
//[self registClientWithDeviceToken:deviceToken];
[BPushregisterDeviceToken: deviceToken];
[BPushbindChannel];
}
- (void) onMethod:(NSString*)method response:(NSDictionary*)data {
#warning BPush - 接受后台推送的信息
NSDictionary* res = [[NSDictionary alloc] initWithDictionary:data];
if ([BPushRequestMethod_Bind isEqualToString:method]) {
// NSString *appid = [res valueForKey:BPushRequestAppIdKey];
NSString *userid = [res valueForKey:BPushRequestUserIdKey];
NSString *channelid = [res valueForKey:BPushRequestChannelIdKey];
//NSString *requestid = [res valueForKey:BPushRequestRequestIdKey];
int returnCode = [[res valueForKey:BPushRequestErrorCodeKey]intValue];
self.bduid = userid;
if (returnCode == BPushErrorCode_Success) {
[[XZDataStoresharedObject] saveBDUid:userid];
[[XZDataStoresharedObject] saveBDChannelId:channelid];
}
} else if ([BPushRequestMethod_UnbindisEqualToString:method]) {
int returnCode = [[res valueForKey:BPushRequestErrorCodeKey]intValue];
if (returnCode == BPushErrorCode_Success) {
[[XZDataStoresharedObject] saveBDUid:@""];
[[XZDataStoresharedObject] saveBDChannelId:@""];
}
}
}
- APNs-百度推送使用总结(二)
- APNs-百度推送使用总结(一)
- 苹果apns推送总结
- APNS 学习总结(二)
- IOS 苹果推送 APNS(二)
- 消息推送(APNS)
- 苹果推送APNS自己总结
- 苹果推送APNS自己总结
- 苹果推送APNS自己总结
- 苹果推送APNS自己总结
- 苹果推送APNS自己总结
- 苹果推送APNS自己总结
- 苹果推送APNS自己总结
- 苹果推送APNS自己总结
- 苹果推送APNS自己总结
- 苹果推送APNS问题总结
- 苹果推送APNS自己总结
- Android 百度推送使用总结
- 2015悲催求职总结
- 在Mac10.10中使用cocoapods的方法
- Reveal查看任意app的高级技巧
- dedecms调用评论 仿DoNews右侧最新评论的代码
- Java 虚拟机的内存分布
- APNs-百度推送使用总结(二)
- 文件夹创建删除和判断
- PCH in Xcode 6
- 【BZOJ】【P2527】【Poi2011】【Meteors】【题解】【整体二分】
- 一元二次方程的解法
- 珍爱网笔试总结
- 发布App需要准备的资料
- DedeCMS后台新建栏目,初识内容模型
- 程序bug寻找