1. 极光推送官方文档链接
推送通知是现在APP开发的必配功能之一,想要快速集成推送通知极光推送当然是最好的选择,开发文档详细全面,容易理解,下面就介绍最新版极光推送的集成教程
- 极光官网链接
- 注册链接 根据需求填写注册即可
- iOS SDK概述
- iOS 证书设置指南
- iOS SDK 集成指南
- iOS SDK 调试指南
- iOS 新特性更新汇总
- iOS API
2. 创建新应用
2.1 进入开发者服务

2.2 创建新应用

2.3 应用名称和图片

2.4 记下AppKey

3. iOS推送通知设置–.p12证书获取
3.1 配置方式1 — 证书配置

3.2 Xcode创建APP
记下Bundle ID

3.3 登录开发者账号创建APP ID

3.4 勾选通知服务


3.5 注册完成的APP ID和通知状态


3.6 创建通知的.cer证书
点击上图的Edit编辑按钮


需要CSR文件




3.8 .cer证书的安装

提示警告问题

解决方法,直接将证书拖进去即可

3.9 导出.p12证书


设置密码: 一定要记住,极光推送配置需要填写


4. 极光推送设置 上传.p12证书文件
上传.p12证书,密码就是.car文件导出.p12文件时设置的密码

验证成功

5. APP集成极光推送
5.1 cocoapods 集成
pod 'JPush'

5.2 Capabilities开启推送通知功能

5.3 ATS网络配置
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

5.4 AppDelegate设置JPush推送通知代码
#import "AppDelegate.h"
#import "ViewController.h"
#import "JPUSHService.h"
#ifdef NSFoundationVersionNumber_iOS_9_x_Max
#import <UserNotifications/UserNotifications.h>
#endif
#import <AdSupport/AdSupport.h>
@interface AppDelegate ()<JPUSHRegisterDelegate>
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
entity.types = JPAuthorizationOptionAlert | JPAuthorizationOptionBadge | JPAuthorizationOptionSound;
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
}
[JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
[JPUSHService setupWithOption:launchOptions appKey:@"2f46c56f8d130d971ca54fda"
channel:@"App Store"
apsForProduction:YES
advertisingIdentifier:nil];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];
[self.window makeKeyAndVisible];
self.window.backgroundColor = [UIColor whiteColor];
return YES;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[JPUSHService registerDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
NSLog(@"did Fail To Register For Remote Notifications With Error: %@", error);
}
#pragma mark- JPUSHRegisterDelegate
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler {
NSDictionary * userInfo = notification.request.content.userInfo;
if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
[JPUSHService handleRemoteNotification:userInfo];
}
completionHandler(UNNotificationPresentationOptionAlert);
}
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {
NSDictionary * userInfo = response.notification.request.content.userInfo;
if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
[JPUSHService handleRemoteNotification:userInfo];
}
completionHandler();
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[JPUSHService handleRemoteNotification:userInfo];
completionHandler(UIBackgroundFetchResultNewData);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[JPUSHService handleRemoteNotification:userInfo];
}



6. 真机启动,配置成功标识

7. 极光官网 配置推送通知内容

需要耐心等待一会才会有通知出来


8. 结束语
极光官方文档还是挺给力的,配置起来很快 |