百度云推送sdk

云推送(Push)是百度开放云向开发者提供的消息推送服务;通过利用云端与客户端之间建立稳定、可靠的长连接来为开发者提供向客户端应用推送实时消息服务。

百度云推送提供了三种推送方式:通知、消息、富媒体,ios只支持通知。android都支持。

资源

官网:

http://developer.baidu.com

SDK:

http://developer.baidu.com/cloud/push

文档中心:

http://developer.baidu.com/wiki/index.php?title=docs/cplat/push/guideios

群
348807820创建者
467086835

使用

  • 注册百度帐号,登录开发这平台,帐号审核通过。需要提交一些信息,如手持身份证的照片等
  • 云推送创建应用,会生成对应的API Key等。
  • 准备证书:

      * 开发阶段:需要一个开发阶段类型的推送证书生成 dev_push.cer 和 dev_push.p12一个开发阶段类型的 dev.cer一个配置文件 dev_profile.mobileprovision (对应的app id 不可带通配符)* 发布阶段:需要一个发布阶段类型的推送证书生成 dis_push.cer 和 dis_push.p12一个发布阶段类型的 dis.cer一个配置文件 dis_profile.mobileprovision (对应的app id 不可带通配符)
    
  • 生成推送证书的pem文件MyApnsCert.pem;

    (后台和APNS服务器通信使用,在设置推送设置时我们需要将这个文件提供给baiduPush,如何生成在官方文档里有)

  • 在开发者服务管理中添加应用、设置推送设置。

  • 工程修改

    • 百度静态类库加入工程
    • 添加BPushConfig.plist 配置文件:

      内容如下: API_KEY对应的管理平台中申请时配置的API_KEY

        <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>PRODUCTION_MODE</key><false/><key>DEBUG</key><true/><key>API_KEY</key><string>*******************</string></dict></plist>
      

    UIAppliationDelegate中代码:

              #pragma mark - 启动- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{//注册推送的设置信息[self registerUserNotificationSettings];return YES;}#pragma mark - 注册推送的设置信息-(void)registerUserNotificationSettings{//* BPush//[BPush setupChannel:launchOptions];//[BPush setDelegate:self];//* APNS//设置badge//[application setApplicationIconBadgeNumber:0];//注册推送的设置信息if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { //UIRemoteNotificationTypeBadge |UIUserNotificationType myTypes =  UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:myTypes categories:nil];[[UIApplication sharedApplication] registerUserNotificationSettings:settings];}else{UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound;[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];}}#pragma mark - 推送回调///回调 - APP成功注册了苹果推送通知服务(APN)时调用- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{NSLog(@"test:%@",deviceToken);[BPush registerDeviceToken: deviceToken];[BPush bindChannel]; // 必须。可以在其它时机调用,只有在该方法返回(通过onMethod:response:回调)绑定成功时,app才能接收到Push消息。一个app绑定成功至少一次即可(如果access token变更请重新绑定)。self.viewController.textView.text = [self.viewController.textView.text stringByAppendingFormat: @"Register device token: %@\n openudid: %@", deviceToken, [OpenUDID value]];}///回调 - APP注册苹果推送通知服务(APN)失败时调用- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{NSLog(@"Failed To Regist APNS : %@",error);}///回调 - 当接收到远程推送的时候调用。- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{NSLog(@"Receive Notify: %@", [userInfo JSONString]);NSString *alert = [[userInfo objectForKey:@"aps"] objectForKey:@"alert"];if (application.applicationState == UIApplicationStateActive) {// Nothing to do if applicationState is Inactive, the iOS already displayed an alert view.UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Did receive a Remote Notification"message:[NSString stringWithFormat:@"The application received this remote notification while it was running:\n%@", alert]delegate:selfcancelButtonTitle:@"OK"otherButtonTitles:nil];[alertView show];}[application setApplicationIconBadgeNumber:0];[BPush handleNotification:userInfo];self.viewController.textView.text = [self.viewController.textView.text stringByAppendingFormat:@"Receive notification:\n%@", [userInfo JSONString]];}///回调 - 当采用registerUserNotificationSettings:注册了通知设置 (IOS8及其以后需要)#if SUPPORT_IOS8- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{//返回 注册的 notificationSettings//register to receive notifications[application registerForRemoteNotifications];}#endif#pragma mark BPushDelegate//6. 实现BPushDelegate协议,必须实现方法onMethod:response::// 必须,如果正确调用了setDelegate,在bindChannel之后,结果在这个回调中返回。// 若绑定失败,请进行重新绑定,确保至少绑定成功一次- (void) onMethod:(NSString*)method response:(NSDictionary*)data{NSLog(@"On method:%@", method);NSLog(@"data:%@", [data description]);NSDictionary* res = [[[NSDictionary alloc] initWithDictionary:data] autorelease];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];if (returnCode == BPushErrorCode_Success) {self.viewController.appidText.text = appid;self.viewController.useridText.text = userid;self.viewController.channelidText.text = channelid;// 在内存中备份,以便短时间内进入可以看到这些值,而不需要重新bindself.appId = appid;self.channelId = channelid;self.userId = userid;}} else if ([BPushRequestMethod_Unbind isEqualToString:method]) {int returnCode = [[res valueForKey:BPushRequestErrorCodeKey] intValue];if (returnCode == BPushErrorCode_Success) {self.viewController.appidText.text = nil;self.viewController.useridText.text = nil;self.viewController.channelidText.text = nil;}}self.viewController.textView.text = [[[NSString alloc] initWithFormat: @"%@ return: \n%@", method, [data description]] autorelease];}
    
  • 应用继承sdk具体步骤参照文档中心:

    http://developer.baidu.com/wiki/index.php?title=docs/cplat/push

问题

  • 有没有一个推送平台?(有)有一个发送消息的管理平台

  • 提供的服务器端调用的接口吗?(有)

    • 服务器端接口:

      http://developer.baidu.com/wiki/index.php?title=docs/cplat/push/api/list

Baidu Push SDK - 百度云推送相关推荐

  1. 【第三方SDK】使用百度云推送实现推送功能详解

    之前介绍过如何使用shareSDK实现新浪微博分享功能,今天介绍如何使用百度云推送SDK实现Android手机后台推送功能. 运行效果如下 第一步,如果使用百度的SDK,当然要先成为百度的开发者啦,这 ...

  2. 改写百度云推送SDK,PHP PEAR 包:Services_Baidu_Push

    iPhone使用apple push很方便,而Android很多厂商删除了google push,而且google在大陆连不上,所以要用别的办法. Android常见的推送服务商有:极光推送(http ...

  3. 百度云推送-服务端 C# SDK

    思路: 1.公司有项目需要做android和ios手机端推送消息的功能: 2.没有接触过这方面的知识,一头雾水,开始在网上一顿搜,网上倒是有不少解决方案,首先搜的是android的解决方案,因为ios ...

  4. Android百度云推送接入,附完整代码

    1.创建应用获取api_key 百度云推送:http://push.baidu.com/ SDK下载:http://push.baidu.com/sdk/push_client_sdk_for_and ...

  5. 关于百度云推送加厂商进行app离线推送的步骤小记

    经过漫长的无所事事,终于来了一个活,要搞推送,不能socket,要后台关闭了也能推. 第三方推送,厂商自带,各种看了一下,但最终产品敲定,用百度云推送 研究的过程都是千篇一律,下demo,看文档,测试 ...

  6. 集成百度云推送,Android8.0系统推送收不到问题解决方案

    因为之前没有集成过百度云推送,接手新项目之后项目需求是接入百度云推送,没办法因为项目是海外项目所以只能硬着头皮来接入了,话不多说开始你的表演: 首先就是去百度云推送的官网去创建应用并启用: .在配置详 ...

  7. Android推送 百度云推送 入门篇

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/27231237 现在app基本都有推送的功能,于是看了下百度云的推送,官方文档和D ...

  8. JPush极光推送 and 百度云推送

    一.极光推送 这两天在研究极光推送,极光推送是一种第三方推送,提供了比较便利的推送的方式,首先让开发者不用花人力和时间去开发后台数据返回,客户端这边只管一些配置和客户端接受消息的配置. 激光推送文档: ...

  9. 快速集成推送通知功能---百度云推送

    发现百度云推送简直太好集成了,一下午时间都用不上就搞定了 先看效果吧 发送通知 接收通知 接下来就是步骤了 1.先去百度云推送开发者平台注册账号 http://push.baidu.com/ 然后创建 ...

最新文章

  1. Arthas 征文活动火热进行中,cherry 键盘等你来拿!(内附第三期中奖名单)
  2. linux /proc/net/arp
  3. MySQL ACID及四种隔离级别的解释
  4. HTML向Flex传参
  5. mysql的存储过程正负数的变化_《转》mysql存储过程语法及范例
  6. 70行Python代码,获取中国数据库大会(DTCC)全部PPT
  7. oracle关于时区,关于oracle时区
  8. 音频插件安装教程,Arturia Prophet V3 Mac安装说明
  9. Xor Sum(AtCoder-2272)
  10. 直播丨Oracle 12.2系列安装
  11. Spring自定义注解(验证身份证+性别+地区)
  12. 用猿大师VLC播放程序与海康威视官方播放器在高版本Chrome播放RTSP视频流延迟效果对比!(视频演示)
  13. opencv mat与cvmat, iplimage转换
  14. Linux服务器绑定mac与ip,Linux实现ip和mac绑定
  15. 面试秘籍大放送,编测编学独家秘籍遭外泄?!
  16. 细说设计模式七大原则(7):合成复用原则
  17. sap采购申请自动转采购订单_我的SAP运维日常_0021_MM_计划订单转采购申请时绑定凭证类型...
  18. krpano 陀螺仪 相关问题
  19. iOS:Xcode Instruments的使用
  20. 惠普800g1支持什么内存_做工精够迷你 惠普EliteDesk800G1评测

热门文章

  1. Matlab中pause函数的使用
  2. c语言:求长方体的体积和表面积
  3. Android实现可拖动的尺子
  4. 计算机辅助制造标准,计算机辅助设计制造专业专业标准框架.doc
  5. 如何从用户态进入内核态
  6. CD4541B定时器的使用方法
  7. 国产COS操作系统与“核高基”重大软件专项有无关联?
  8. 什么是流量劫持?Win10如何避免流量劫持?
  9. 中国防近视镜片市场深度研究分析报告
  10. 计算机网络——第一章:计算机网络概述