标签:
1.注册极光推送开发者账号
https://www.jpush.cn
2.登陆极光网站--创建应用
3.上传推送的开发证书和产品证书
注:上传p12证书,所以上传前要把cer证书转成p12证书,也就是交换证书
创建好应用后,记录下APP_KEY
4.在项目中集成极光推送
下载极光推送SDK
https://www.jpush.cn/common/products#product-sdk
注:服务器端开发需要下载对应的SDK
5.必要的框架
6.创建并配置PushConfig.plist文件
7.添加代码到项目
1 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 2 { 3 self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 4 self.window.backgroundColor = [UIColor whiteColor]; 5 [self.window makeKeyAndVisible]; 6 7 // Required 8 #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1 9 if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) { 10 //可以添加自定义categories 11 [APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | 12 UIUserNotificationTypeSound | 13 UIUserNotificationTypeAlert) 14 categories:nil]; 15 } else { 16 //categories 必须为nil 17 [APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | 18 UIRemoteNotificationTypeSound | 19 UIRemoteNotificationTypeAlert) 20 categories:nil]; 21 } 22 #else 23 //categories 必须为nil 24 [APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | 25 UIRemoteNotificationTypeSound | 26 UIRemoteNotificationTypeAlert) 27 categories:nil]; 28 #endif 29 // Required 30 [APService setupWithOption:launchOptions]; 31 32 return YES; 33 } 34 35 - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 36 37 // Required 38 [APService registerDeviceToken:deviceToken]; 39 } 40 41 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { 42 43 // Required 44 [APService handleRemoteNotification:userInfo]; 45 } 46 47 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { 48 49 50 // IOS 7 Support Required 51 [APService handleRemoteNotification:userInfo]; 52 completionHandler(UIBackgroundFetchResultNewData); 53 }
8.在极光官网--发送通知
8.1设置推送消息
8.2设置推送对象,一般勾选全部
9.极光还有统计功能
标签:
原文地址:http://www.cnblogs.com/oumygade/p/4232851.html