極光推送總結
1-證書申請
證書指南官方連結
http://docs.jiguang.cn/jpush/client/iOS/ios_cer_guide/
2-工程配置
匯入SDK
將SDK包解壓,在Xcode中選擇“Add files to 'Your project name'...”,將解壓後的lib子資料夾(包含JPUSHService.h、jpush-ios-x.x.x.a)新增到你的工程目錄中。
新增Framework
CFNetwork.framework
CoreFoundation.framework
CoreTelephony.framework
SystemConfiguration.framework
CoreGraphics.framework
Foundation.framework
UIKit.framework
Security.framework
Xcode7需要的是libz.tbd;Xcode7以下版本是libz.dylib
Adsupport.framework (獲取IDFA需要;如果不使用IDFA,請不要新增)
UserNotifications.framework(Xcode8及以上)
Build Settings
如果你的工程需要支援小於7.0的iOS系統,請到Build Settings 關閉 bitCode 選項,否則將無法正常編譯通過。
設定 Search Paths 下的 User Header Search Paths 和 Library Search Paths,比如SDK資料夾(預設為lib)與工程檔案在同一級目錄下,則都設定為"$(SRCROOT)/{靜態庫所在資料夾名稱}"即可。

Capabilities
如使用Xcode8及以上環境開發,請開啟Application Target的Capabilities->Push Notifications選項,如圖:

允許Xcode7支援Http傳輸方法
如果您使用的是2.1.9以後的版本則不需要配置此步驟如果用的是Xcode7或更新版本,需要在App專案的plist手動配置下key和值以支援http傳輸:
選擇1:根據域名配置
在專案的info.plist中新增一個Key:NSAppTransportSecurity,型別為字典型別。
然後給它新增一個NSExceptionDomains,型別為字典型別;
把需要的支援的域新增給NSExceptionDomains。其中jpush.cn作為Key,型別為字典型別。
每個域下面需要設定2個屬性:NSIncludesSubdomains、NSExceptionAllowsInsecureHTTPLoads。兩個屬性均為Boolean型別,值分別為YES、YES。

選擇2:全域性配置
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
初始化程式碼
在AppDelegate.m中匯入#import "JPUSHService.h"
在以下方法中新增程式碼:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
#pragma mark --鐳射推送--
// 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
// 如需繼續使用pushConfig.plist檔案宣告appKey等配置內容,
請依舊使用[JPUSHService setupWithOption:launchOptions]方式初始化。
[JPUSHService setupWithOption:launchOptions appKey:@"appKey"
channel:nil
apsForProduction:FALSE // FALSE開發環境下的測試,YES為生產環境下的測試
advertisingIdentifier:nil];
}
// 請在AppDelegate.m實現該回撥方法並新增回撥方法中的程式碼
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
/// Required - 註冊 DeviceToken
[JPUSHService registerDeviceToken:deviceToken];
}
通知
此時可前往極光控制檯傳送推送訊息

自定義訊息
如果需要應用接收自定義訊息,我們需要新增一個觀察者。
(自定義訊息是長連線需要應用在前臺,如果應用在後臺會儲存為離線)
在以下方法中新增觀察者
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self
selector:@selector(networkDidReceiveMessage:)
name:kJPFNetworkDidReceiveMessageNotification
object:nil];
}
實現回撥
- (void)networkDidReceiveMessage:(NSNotification *)notification {
NSLog(@"did receive messagr %@",notification);
}

列印結果

自定義訊息可以新增多個欄位,新增完成後點選立即傳送

列印結果

如有疑問檢視官方教程
JPush iOS SDK 教程
連結: http://docs.jpush.io/client/ios_tutorials/
相關文章
- iOS —— 極光推送和極光IMiOS
- Flutter應用整合極光推送Flutter
- 在 Laravel 中使用 極光推送Laravel
- Laravel 極光推送驅動,使用極光不再那麼麻煩!Laravel
- 極光筆記|極光推送在APICloud平臺的使用教程筆記APICloud
- APP訊息推送 極光推送 示例程式碼APP
- .NET對接極光訊息推送
- .NET快速對接極光訊息推送
- 極光筆記丨iOS 15推送新特性筆記iOS
- 極光推送申請iOS推送證書p12及配置流程iOS
- 極光推送申請iOS推送證書p12及配置教程iOS
- [外掛擴充套件]APP極光推送外掛!套件APP
- 快捷地整合極光推送(JPush)到 Laravel 專案中Laravel
- 極光推送demo在android studio中無法執行Android
- WEB 實時推送技術的總結Web
- ElasticSearch極簡入門總結Elasticsearch
- Android推送平臺試用總結報告Android
- 極光筆記 | 極光服務的信創改造實踐筆記
- 在Android裝置上使用極光推送id重複的原因分析和解決辦法Android
- 極光筆記丨Spark SQL 在極光的建設實踐筆記SparkSQL
- 極光筆記 | 極光PUSH服務助力企業提升搶單速度筆記
- 一篇極好的Git 總結Git
- Selenium和PhantomJS 終極最全使用總結JS
- 極光筆記|百億級KV儲存在極光的運維實踐之路筆記運維
- iOS 點選推送訊息跳轉指定介面 —總結篇iOS
- 極光財報:2020年Q2極光營收1.308億元 同比下降55%營收
- Amazing!!CSS 也能實現極光?CSS
- GUET 2024夢極光pwn2
- 極光財報:2019年Q3極光毛利潤為5690萬元 同比增長7%
- 多元函式的極限與連續 概念總結函式
- 極光筆記 | 極光推出“運營增長”解決方案,開啟企業增長新引擎筆記
- Auraknot 光環結
- 極光星空天文攝影LR預設
- 關於呼叫三方平臺介面與推送介面的總結(2020.7.25)
- 共赴璀璨約定!《光與夜之戀》極光測試今日開啟
- WebGPU+光線追蹤Ray Tracing 開發三個月總結WebGPU
- FLUKE FTK1000光纖公開課實操亮點總結
- 【Flutter 專題】63 圖解 Flutter 整合極光 JPush 小結|8月更文挑戰Flutter圖解
- 極光筆記 | 大語言模型外掛筆記模型