極光推送流程
1.創(chuàng)建項(xiàng)目, 配置cocoapods;極光官網(wǎng)不支持Cocoapods, 這里僅是網(wǎng)友自己上傳的, 建議跳過該步驟.
$ pod search JPushSDK
2.注冊(cè)極光賬號(hào)
3.創(chuàng)建應(yīng)用, 按照要求填寫iOS相關(guān)要求, 之前文章中下載的p12證書派上用場(chǎng)了.
如果沒有創(chuàng)建參考iOS網(wǎng)絡(luò)推送前期配置


之后在代碼中需要使用該key

4.極光SDK概述, 之前已經(jīng)使用系統(tǒng)推送, 可以大致的瀏覽一下這個(gè)流程;
5.配置依賴庫, 下載SDK
第一. 前期配置
1. lib子文件夾(包含JPUSHService.h、jpush-ios-x.x.x.a)添加到你的工程目錄中。2. 必要的框架
CFNetwork.framework
CoreFoundation.framework
CoreTelephony.framework
SystemConfiguration.framework
CoreGraphics.framework
Foundation.framework
UIKit.framework
Security.framework
Xcode7添加libz.tbd;
Xcode7以下添加libz.dylib
2.創(chuàng)建plist文件--PushConfig.plist ====(可選)
1. CHANNEL: 指明應(yīng)用程序包的下載渠道,為方便分渠道統(tǒng)計(jì),具體值由你自行定
義,如:App Store。
2. APP_KEY: 創(chuàng)建應(yīng)用后自動(dòng)生成的AppKey值。
3. APS_FOR_PRODUCTION: 0 (默認(rèn)值)表示采用的是開發(fā)證書,1 表示采用生產(chǎn)
證書發(fā)布應(yīng)用。
第二. 調(diào)用極光推送代碼
1.注冊(cè)極光
#import "AppDelegate.h"
#import "JPUSHService.h"
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0)
{ //可以添加自定義categories [JPUSHService
registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];
}
else
{ //categories 必須為nil
[JPUSHService registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert) categories:nil];
} /*! * @abstract 啟動(dòng)SDK *
* @param launchingOption 啟動(dòng)參數(shù). * @param appKey 一個(gè)JPush 應(yīng)用必須
的,唯一的標(biāo)識(shí). 請(qǐng)參考 JPush 相關(guān)說明文檔來獲取這個(gè)標(biāo)識(shí). * @param channel
發(fā)布渠道. 可選. * @param isProduction 是否生產(chǎn)環(huán)境. 如果為開發(fā)狀態(tài),設(shè)置為
NO; 如果為生產(chǎn)狀態(tài),應(yīng)改為 YES. * @param advertisingIdentifier 廣告標(biāo)識(shí)符
(IDFA) 如果不需要使用IDFA,傳nil. * * @discussion 提供SDK啟動(dòng)必須的參
數(shù), 來啟動(dòng) SDK. * 此接口必須在 App 啟動(dòng)時(shí)調(diào)用, 否則 JPush SDK 將無法正常工
作. */
[JPUSHService setupWithOption:launchOptions
appKey:@"1ff9db3a7370c83a77f66cb0" channel:@"Test"
apsForProduction:NO advertisingIdentifier:nil]; return YES;
}
2.注冊(cè)DeviceToken
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{ /// Required - 注冊(cè) DeviceToken
[JPUSHService registerDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
// Required,For systems with less than or equal to iOS6 //處理收到的 APNs 消息
[JPUSHService handleRemoteNotification:userInfo];
}
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// IOS 7 Support Required
[JPUSHService handleRemoteNotification:userInfo];
completionHandler(UIBackgroundFetchResultNewData);
}
- (void)application:(UIApplication *)application
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{ //Optional
NSLog(@"did Fail To Register For Remote Notifications With Error: %@", error);
}
發(fā)送推送消息

*** 恭喜你, 極光遠(yuǎn)程推送基本使用已經(jīng)完成.***