iOS极光推送-具体步骤
来源:互联网 发布:网络正常守望先锋卡 编辑:程序博客网 时间:2024/06/07 23:19
1、在JPush Portal上创建应用
创建条件:【测试】:
- 登陆苹果开发者平台
- 进入证书中心
- 创建
- 申请请求文件
- 生成证书 下载证书
- 创建appids
- 创建devices
- 创建provisoning 【将证书,appids,devices连接打包】
- 生成p12文件。
- 下载SDK
- 讲sdk集成到程序中
- CFNetwork.framework
- CoreFoundation.framework
- CoreTelephony.framework
- SystemConfiguration.framework
- CoreGraphics.framework
- Foundation.framework
- UIKit.framework
- Security.framework
- libz.dylib
- 设置 Search Paths 下的 User Header Search Paths 和 Library Search Paths,比如SDK文件夹(默认为lib)与工程文件在同一级目录下,则都设置为"$(SRCROOT)/[文件夹名称]"即可。
{
"APS_FOR_PRODUCTION"="0";
"CHANNEL"="Publish channel";
"APP_KEY"="AppKey copied from JPush Portal application";
}
- CHANNEL
- 指明应用程序包的下载渠道,为方便分渠道统计。根据你的需求自行定义即可。
- APP_KEY
- 在管理Portal上创建应用时自动生成的(AppKey)用以标识该应用。请确保应用内配置的 AppKey 与第1步在 Portal 上创建应用时生成的 AppKey 一致,AppKey 可以在应用详情中查询。
API@interface APService : NSObject // init Push+ (void)setupWithOption:(NSDictionary *)launchingOption; // register notification type+ (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types; // upload device token+ (void)registerDeviceToken:(NSData *)deviceToken; // handle notification recieved+ (void)handleRemoteNotification:(NSDictionary *)remoteInfo;调用代码 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];self.window.backgroundColor = [UIColor whiteColor];[self.window makeKeyAndVisible]; // Requiredif ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {//可以添加自定义categories[APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |UIUserNotificationTypeSound |UIUserNotificationTypeAlert)categories:nil];} else {//categories 必须为nil[APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert)categories:nil];} // Required[APService setupWithOption:launchOptions]; return YES;} - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { // Required[APService registerDeviceToken:deviceToken];} - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { // Required[APService handleRemoteNotification:userInfo];} - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { // IOS 7 Support Required[APService handleRemoteNotification:userInfo];completionHandler(UIBackgroundFetchResultNewData);}
监听通知
在你的工程中创建一个新的Property List文件,并将其命名为PushConfig.plist,填入Portal为你的应用提供的APP_KEY等参数。
APIs 主要集中在 APService 接口类里。
监听系统事件,相应地调用 JPush SDK 提供的 API 来实现功能。
以下 3 个事件监听与调用 JPush SDK API 都是必须的。请直接复制如下代码块里,注释为 "Required" 的行,到你的应用程序代理类里相应的监听方法里。
API里面提供了下面 5 种类型的通知:
extern NSString * const kJPFNetworkDidSetupNotification; // 建立连接
extern NSString * const kJPFNetworkDidCloseNotification; // 关闭连接
extern NSString * const kJPFNetworkDidRegisterNotification; // 注册成功
extern NSString * const kJPFNetworkDidLoginNotification; // 登录成功
extern NSString * const kJPFNetworkDidReceiveMessageNotification; // 收到消息(非APNS)
其中,kJPFNetworkDidReceiveMessageNotification通知是有传递数据的,可以通过NSNotification中的userInfo方法获取,包括标题、内容、内容类型、扩展信息等
- iOS极光推送-具体步骤
- jcenter 快速集成 极光推送 具体步骤
- iOS- 推送极光推送
- iOS极光推送集成
- iOS极光推送常见问题
- 《iOS极光推送步骤》
- ios极光推送
- iOS极光推送
- <iOS>极光推送
- iOS JPush极光推送
- iOS极光推送常见问题
- iOS 极光推送问题
- iOS- 极光推送
- iOS极光推送集成
- IOS极光推送
- iOS极光推送
- 极光推送iOS
- iOS 极光推送
- 【Balkan2002】【BZOJ1336】Alien最小圆覆盖
- XML文本转为MAP对象的简便方法(利用jackson-dataformat-xml)
- Streaming Media
- hive 1.0.1 安装配置 hadoop 2.6.0
- 关于springMVC访问静态文件404
- iOS极光推送-具体步骤
- listview 卡顿终极原因解析
- liblinear简单使用说明
- CSS之Sass Compass
- java格式化输出 printf 例子
- Android 对程序异常崩溃的捕捉
- MyBatis学习总结(一)——MyBatis快速入门
- POJ 1733 Parity game(离散化+带权并查集)
- Piont in a circle