iOS 極光推送

來源:互聯網
上載者:User

標籤:

1.註冊極光推送開發人員帳號

https://www.jpush.cn

2.登陸極光網站--建立應用

3.上傳推送的開發認證和產品認證

  注:上傳p12認證,所以上傳前要把cer認證轉成p12認證,也就是交換認證

  建立好應用後,記錄下APP_KEY

4.在項目中整合極光推送

  下載極光推送SDK

  https://www.jpush.cn/common/products#product-sdk

    

  注:伺服器端開發需要下載對應的SDK

5.必要的架構

  • CFNetwork.framework
  • CoreFoundation.framework
  • CoreTelephony.framework
  • SystemConfiguration.framework
  • CoreGraphics.framework
  • Foundation.framework
  • UIKit.framework
  • Security.framework
  • libz.dylib

6.建立並配置PushConfig.plist檔案

  • CHANNEL:Publish channel 代表發布版本
  • APP_KEY:填步驟3.1獲得的APP_KEY. 極光官網的應用管理中心也是可以查到的
  • APS_FOR_PRODUCTION:
    • 1.3.1版本新增,表示應用是否採用生產認證發布( Ad_Hoc 或 APP Store ),0 (預設值)表示採用的是開發人員認證,1 表示採用生產認證發布應用。
    • 此處設定的值建議按對應認證來設定值。
    • 在1.2.2或之前版本的設定檔中,有 TEST_MODE 這個鍵,新版的SDK不再使用,可以將它刪除。

 

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     //可以添加自訂categories11     [APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |12                                                    UIUserNotificationTypeSound |13                                                    UIUserNotificationTypeAlert)14                                        categories:nil];15   } else {16     //categories 必須為nil17     [APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |18                                                    UIRemoteNotificationTypeSound |19                                                    UIRemoteNotificationTypeAlert)20                                        categories:nil];21   }22 #else23     //categories 必須為nil24   [APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |25                                                  UIRemoteNotificationTypeSound |26                                                  UIRemoteNotificationTypeAlert)27                                      categories:nil];28 #endif29     // Required30     [APService setupWithOption:launchOptions];31 32     return YES;33 }34 35 - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {36 37     // Required38     [APService registerDeviceToken:deviceToken];39 }40 41 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {42 43     // Required44     [APService handleRemoteNotification:userInfo];45 }46 47 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {48 49 50   // IOS 7 Support Required51   [APService handleRemoteNotification:userInfo];52   completionHandler(UIBackgroundFetchResultNewData);53 }

8.在極光官網--發送通知

  8.1設定推送訊息

  8.2設定推送對象,一般勾選全部

9.極光還有統計功能

iOS 極光推送

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.