百度推送iOS
来源:互联网 发布:ubuntu jenkins git 编辑:程序博客网 时间:2024/05/20 23:38
点击钥匙串访问-->从证书颁发机构请求证书-->填写用户邮件地址-->常用名-->点击储存-->继续-->最后点击保存。
在桌面上就可以看见CertificateSigningRequest.certSigningRequest文件就是CSR文件,在我们生成CSR文件的同时,会在钥匙串访问中生成一对秘钥,名称为刚才我们填写的常用名。
2.打开开发者中心 首先创建Identifiers -->在创建Certificates -->在创建Provisoning Profiles
注意:1.创建Identifiers时,一定要勾选Push Notifications,
2.保证Identifiers中的ID,Certificates中的Name,Provisoning Profiles中的APP ID,应用程序中的Bundle identifier,保持一致。
3.点击钥匙串访问-->我的证书-->找到刚刚生成的.p12文件-->点击导出到桌面。
4.打开中端 -->openssl pkcs12 -in push.p12 -out push.pem -nodes,将.p12文件变成.pem文件。
5.添加到SDK到?工程中的步骤如下:
将 libBPush.a 和 BPush.h 添加到?自?己的?工程下,添加时需要注意勾选当前Target
6.创建并配置BPushConfig.plist文件,在工程中创建一个新的Property List文件,并命名为BPushConfig.plist,添加以下键值:
?
1
2
3
4
5
{
“PRODUCTION_MODE” = NO
“API_KEY” = “uZbmgZKhfumvGYGowcjSPFc1”
“DEBUG” = NO
}
PRODUCTION_MODE:
必选。应用发布模式。开发证书签名时,值设为”NO”;发布证书签名时,值设为”YES”。请在调试和发布应用时,修改正确设置这个值,以免出现推送通知无法到达。
API_KEY:
必选。百度开发者中心为每个app自动分配的api key,在开发者中心app基本信息中可以查看。
6.SDK需要以下
库: Foundation.framework 、 CoreTelephony.framework 、 libz.dylib 、 SystemConfiguration.framework ,请在?工程中添加
7.在 AppDelegate 中的 application: didFinishLaunchingWithOptions: 中调?用 API,初始化Push:
因为iOS8中对于推送有更改,所以要判断设备的版本
1
2
[BPush setupChannel:launchOptions];
[BPush setDelegate:self]; //参数对象必须实现onMethod: response:方法,
#if SUPPORT_IOS8
// 8.0以后使用这种方法来注册推送通知
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
UIUserNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:myTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}else
#endif
{
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
}
8. 在application: didRegisterForRemoteNotificationsWithDeviceToken:中调用API,注册device token:
BPush registerDeviceToken:deviceToken]; // 必须
[BPush bindChannel]; // 必须。可以在其它时机调用,只有在该方法返回(通过onMethod:response:回调)绑定成功时,app才能接收到Push消息。一个app绑定成功至少一次即可(如果access token变更请重新绑定)。
9. 实现BPushDelegate协议,必须实现方法onMethod:response:
if ([BPushRequestMethod_Bind isEqualToString:method])
{
NSDictionary* res = [[NSDictionary alloc] initWithDictionary:data];
NSString *appid = [res valueForKey:BPushRequestAppIdKey];
NSString *userid = [res valueForKey:BPushRequestUserIdKey];
NSString *channelid = [res valueForKey:BPushRequestChannelIdKey];
int returnCode = [[res valueForKey:BPushRequestErrorCodeKey] intValue];
NSString *requestid = [res valueForKey:BPushRequestRequestIdKey];
}
10.在application: didReceiveRemoteNotification:中调用API,处理接收到的Push消息:
获取推送后返回的数据
[BPush handleNotification:userInfo]; // 可选
- iOS推送 (百度推送)
- iOS推送 (百度推送)
- ios 推送消息 极光推送/百度推送
- 百度 iOS推送
- iOS百度推送
- <iOS>百度推送
- 百度推送iOS
- iOS 百度推送
- iOS - 百度推送
- 百度推送(iOS)
- 百度云推送----iOS
- ios 百度推送
- iOS 百度云推送详解
- 百度推送--IOS(一)
- 百度推送--IOS(一)
- 百度云推送 Android+IOS
- iOS百度云推送问题
- iOS之百度云推送
- [2035]:人见人爱A^B
- Linux下各文件夹的含义
- 项目报错相关
- 解析Spring IOC原理——工厂模式与反射机制的综合应用
- 使用easyui图片上传的三点注意
- 百度推送iOS
- 深度解析JAVA动态代理设计模式
- 嵌入式Linux下CUPS移植
- CentOS7网络配置
- 昂贵的聘礼
- 浅析 Linux 初始化 init 系统,第 2 部分: UpStart
- 不常用到的EXCEL功能
- 第十六天
- DRBD 的日常管理