在進(jìn)行以下操作時(shí),開(kāi)發(fā)證書(shū)或者發(fā)布證書(shū)要申請(qǐng)成功
Mac鑰匙串--》鑰匙串訪問(wèn)--》證書(shū)助理--》從證書(shū)頒發(fā)機(jī)構(gòu)請(qǐng)求證書(shū)--》生成CSR文件
(證書(shū)密碼為極光推送上傳證書(shū)時(shí)的密碼)```
######登錄[開(kāi)發(fā)者](https://developer.apple.com/account)網(wǎng)站
創(chuàng)建AppID--》(#Bundle ID和應(yīng)用一致,測(cè)試推送功能記得勾選#Push Notifications)
--》創(chuàng)建證書(shū),此時(shí)需要CSR文件
下載證書(shū)
--》雙擊證書(shū),右鍵查看簡(jiǎn)介添加信任,在鑰匙串中導(dǎo)出為.p12文件
在極光注冊(cè)應(yīng)用時(shí)上傳開(kāi)發(fā)證書(shū)或者發(fā)布證書(shū)
--》完成注冊(cè)
描述文件有問(wèn)題的可以重新生成描述文件(主要作用是給應(yīng)用和AppID、證書(shū)建立關(guān)聯(lián))
####1.導(dǎo)入靜態(tài)庫(kù)
下載的極光推送SDK包解壓后,將其中的Lib文件拖入工程中,然后導(dǎo)入相關(guān)的靜態(tài)庫(kù)
下載SDK,將需要的兩個(gè)文件導(dǎo)入項(xiàng)目中:

```集成壓縮包內(nèi)容
包名為JPush-iOS-SDK-{版本號(hào)}
lib文件夾:包含頭文件 JPUSHService.h,靜態(tài)庫(kù)文件jpush-ios-x.x.x.a ,支持的iOS版本為 5.0 及以上版本。
//(請(qǐng)注意:模擬器不支持APNs)
pdf文件:集成指南
demo文件夾:示例```

####2.代碼配置
//在AppDelegate的相關(guān)方法中進(jìn)行代碼配置
import "JPUSHService.h"
import <AdSupport/AdSupport.h>
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString *advertisingId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
//Required
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];
}
//Required
// 如需繼續(xù)使用pushConfig.plist文件聲明appKey等配置內(nèi)容,請(qǐng)依舊使用[JPUSHService setupWithOption:launchOptions]方式初始化。
[JPUSHService setupWithOption:launchOptions
appKey:appKey
channel:channel//發(fā)布平臺(tái),nil
apsForProduction:isProduction//BOOL 值
advertisingIdentifier:advertisingId
];
}-
(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
[JPUSHService handleRemoteNotification:userInfo];
} -
(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// IOS 7 Support Required
[JPUSHService handleRemoteNotification:userInfo];
completionHandler(UIBackgroundFetchResultNewData);
// 應(yīng)用正處理前臺(tái)狀態(tài)下,不會(huì)收到推送消息,因此在此處需要額外處理一下
if (application.applicationState == UIApplicationStateActive) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"收到推送消息"
message:userInfo[@"aps"][@"alert"]
delegate:nil
cancelButtonTitle:@"取消"
otherButtonTitles:@"確定",nil];
[alert show];
}
} (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
//Optional
NSLog(@"did Fail To Register For Remote Notifications With Error: %@", error);
}(void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
[application setApplicationIconBadgeNumber:0];
return;
}
####3.Xcode設(shè)置
在info.plist文件中設(shè)置允許http訪問(wèn)
如果你的工程需要支持小于7.0的iOS系統(tǒng),請(qǐng)到Build Settings 關(guān)閉 bitCode 選項(xiàng),否則將無(wú)法正常編譯通過(guò)

設(shè)置允許推送

####4.然后鏈接真機(jī)運(yùn)行測(cè)試成功,Xcode會(huì)打印如下:

####5.在極光推送官網(wǎng)發(fā)送測(cè)試信息,測(cè)試時(shí)將應(yīng)用在真機(jī)退出到后臺(tái)運(yùn)行

資料:
[推送的自定義categories](http://my.oschina.net/u/1418722/blog/317422)
[iOS開(kāi)發(fā)中的遠(yuǎn)程推送實(shí)現(xiàn)(最新,支持iOS9)](https://zm10.sm-tc.cn/?src=http%3A%2F%2Fwww.mamicode.com%2Finfo-detail-1124741.html&uid=48a54dfb9031a7654198c539e9001d2f&hid=55b226f6266805a848e1c24be8b9cddd&pos=1&cid=9&time=1466556151388&from=click&restype=1&pagetype=0000004000000402&bu=structure_web_info&query=ios9)
[iOS: 極光推送](http://www.cnblogs.com/XYQ-208910/p/5463802.html)