標籤:
1.SDK整合
具體需要的庫的認證匯入極光網這些,可以參考文檔。
2.實現推送
需要注意的地方是帶程式在前台的時候,收到的推送不會顯示,但是是可以收到資料,這裡就需要我們列印
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 極光推送 float systemVersion = [[UIDevice currentDevice].systemVersion floatValue]; if (systemVersion >= 8.0) { //可以添加自訂categories [APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil]; } else { //categories 必須為nil [APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert) categories:nil]; } // Required [APService setupWithOption:launchOptions];}#pragma mark - 註冊裝置推送-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{ [APService registerDeviceToken:deviceToken];}#pragma mark 推送訊息接收- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { // Required [APService handleRemoteNotification:userInfo]; NSLog(@"AppDelegate:%@",userInfo); }- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { // IOS 7 Support Required [APService handleRemoteNotification:userInfo]; completionHandler(UIBackgroundFetchResultNewData); NSLog(@"AppDelegate:%@",userInfo); }
iOS--極光推送