當(dāng)我們把推送證書配置好再把極光SDK拖入項目配置馋记,然后注冊極光推送,完成代理昵宇,這樣沒有太多意外你就能收到消息了,但是我們都知道還需要做一些處理儿子,都是哪些呢瓦哎?
●
當(dāng)收到消息時,app在前臺如何處理
● 在后臺如何處理柔逼?
● 未啟動如何處理蒋譬?
● 當(dāng)app在前臺收到消息如何跳轉(zhuǎn)到指定頁面?
● 在后臺收到系統(tǒng)通知卒落,點擊通知欄又如何跳轉(zhuǎn)指定頁面羡铲?
● 未啟動時點擊通知欄又如何跳轉(zhuǎn)指定頁面?
● 收到自定義通知如何顯示儡毕?
● 怎么給指定用戶發(fā)送消息也切?
● 當(dāng)有多個類型通知的時候,怎么拿到服務(wù)器發(fā)送過來的extras的內(nèi)容腰湾,然后根據(jù)類型做出正確的跳轉(zhuǎn)雷恃?
● 怎么在app內(nèi)部開啟、關(guān)閉通知费坊?
● 你測試包(真機調(diào)試)收到通知后倒槐,怎么確定上架包也能收到消息?
今天小伙伴問我Badge
怎么弄附井,我這邊徽章個數(shù)是從服務(wù)器請求的讨越,使用WZLBadge這個三方繪制的两残。另外,我個人遇到的一個崩潰問題 覺得有必要讓大家看下把跨。
在上面我拋出了一些問題人弓,基本都是我們集成極光后前端需要處理的事情,下面我一個個解決這些問題着逐。我個人沒有總結(jié)太多崔赌,肯定有缺失,這里只是給不知道的伙伴列舉一些常見的耸别。若有誤健芭,請指出。
○
當(dāng)收到消息時秀姐,app在前臺如何處理慈迈?如何跳轉(zhuǎn)?
當(dāng)應(yīng)用在前臺時囊扳,接收到通知消息首先會調(diào)用極光的這個代理
#pragma mark- JPUSHRegisterDelegate
// iOS 10 Support
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler {
// Required
NSDictionary * userInfo = notification.request.content.userInfo;
if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]
]) {
[JPUSHService handleRemoteNotification:userInfo];
}
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
// 需要執(zhí) 這個 法吩翻,選擇 是否提醒 戶兜看,有Badge锥咸、Sound、Alert三種類型可以選擇設(shè)置
completionHandler(UNNotificationPresentationOptionSound);
}else if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {//后臺
// 需要執(zhí) 這個 法细移,選擇 是否提醒 戶搏予,有Badge、Sound弧轧、Alert三種類型可以選擇設(shè)置
completionHandler(UNNotificationPresentationOptionAlert);
}else {//未啟動
// 需要執(zhí) 這個 法雪侥,選擇 是否提醒 戶,有Badge精绎、Sound速缨、Alert三種類型可以選擇設(shè)置
completionHandler(UNNotificationPresentationOptionAlert);
}
}
在上面代理中有幾個判斷,當(dāng)app在前臺代乃、后臺旬牲、未運行。三種狀態(tài)搁吓,解釋下
Badge:應(yīng)用角標(biāo)
Sound:通知聲音
Alert:通知欄
如果你同時需要通知欄展示原茅,聲音,角標(biāo)堕仔,只需要以|
符號連接即可擂橘,不需要的直接刪除。
如果你在應(yīng)用內(nèi)收到通知(非自定義消息摩骨,后面會詳細(xì)說這個)通贞,應(yīng)該在這個 if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {}
判斷中進行提示朗若、跳轉(zhuǎn)。你可以在這里寫一個UIAlertController提示昌罩,也可以像我一樣提示在頂部捡偏,取決你們UI設(shè)計。
我的代碼
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
/*
* 當(dāng)應(yīng)用在前臺 接到通知
*/
NSString *messageAlert = [[userInfo objectForKey:@"aps"]objectForKey:@"alert"];
//獲取頂層控制器
UIViewController *currentVC = [self currentViewController];
[TSMessage showNotificationInViewController:currentVC.navigationController
title:@"系統(tǒng)通知"
subtitle:messageAlert
image:[UIImage imageNamed:@"notifi"]
type:TSMessageNotificationTypeMessage
duration:TSMessageNotificationDurationAutomatic
callback:^{
if (currentVC.navigationController) {
if ([Person currentLoginUser].userId.length == 11) {
//先跳轉(zhuǎn)指定tab然后push到指定頁面
BaseTabBarController *myTbabar = (BaseTabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
myTbabar.selectedIndex = 2;
//改變bar后再次獲取當(dāng)前控制器
UIViewController *VC = [self currentViewController];
MyServiceViewController *vc = [[MyServiceViewController alloc] init];
[vc setHidesBottomBarWhenPushed:YES];
[VC.navigationController pushViewController:vc animated:YES];
}else {
[SVProgressHUD showInfoWithStatus:@"請登錄后峡迷,前往我的服務(wù)查看银伟。"];
}
}else {
[SVProgressHUD showErrorWithStatus:@"跳轉(zhuǎn)失敗,請自行前往個人中心查看绘搞。"];
}
}
buttonTitle:nil
buttonCallback:^{
}
atPosition:TSMessageNotificationPositionNavBarOverlay
canBeDismissedByUser:YES];
completionHandler(UNNotificationPresentationOptionSound); // 需要執(zhí) 這個 法彤避,選擇 是否提醒 戶,有Badge夯辖、Sound琉预、Alert三種類型可以選擇設(shè)置
}
上面代碼我選擇了一個提示的第三方TSMessage在點擊消息的時候做了一個跳轉(zhuǎn)。在調(diào)用這個三方的時候你首先要獲取當(dāng)前頂層控制器賦值給這個三方蒿褂。 UIViewController *currentVC = [self currentViewController];
//獲取Window當(dāng)前顯示的ViewController
- (UIViewController*)currentViewController{
//獲得當(dāng)前活動窗口的根視圖
UIViewController* vc = [UIApplication sharedApplication].keyWindow.rootViewController;
while (1) {
//根據(jù)不同的頁面切換方式圆米,逐步取得最上層的viewController
if ([vc isKindOfClass:[UITabBarController class]]) {
vc = ((UITabBarController*)vc).selectedViewController;
}
if ([vc isKindOfClass:[UINavigationController class]]) {
vc = ((UINavigationController*)vc).visibleViewController;
}
if (vc.presentedViewController) {
vc = vc.presentedViewController;
}else{
break;
}
}
return vc;
}
有個細(xì)節(jié)是,當(dāng)你跳轉(zhuǎn)指定控制器的時候啄栓,你有必要判斷當(dāng)前控制器是否可以push過去娄帖,即有沒有導(dǎo)航欄,如果沒有則不能push昙楚,當(dāng)然也可以像我這樣先跳轉(zhuǎn)到個人中心近速,保證有導(dǎo)航欄,但是這樣的處理也許不適用你的app.
○
在后臺收到消息如何處理堪旧?如何跳轉(zhuǎn)削葱?
當(dāng)你在后臺,收到消息淳梦,通知欄會彈出一個系統(tǒng)alert析砸,一旦你點擊了這個alert,目標(biāo)app會被喚起爆袍,同時調(diào)用下面代理函數(shù)首繁。
// iOS 10 Support
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler;
在這個函數(shù)中我們做這樣的提示螃宙、跳轉(zhuǎn)處理蛮瞄。
// Required
NSDictionary *userInfo = response.notification.request.content.userInfo;
if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
/*
* 應(yīng)用在后臺 點擊了通知欄
*/
UIViewController *currentVC = [self currentViewController];
if (currentVC.navigationController) {
if ([Person currentLoginUser].userId.length == 11) {
//先跳轉(zhuǎn)指定tab然后push到指定頁面
BaseTabBarController *myTbabar = (BaseTabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
myTbabar.selectedIndex = 2;
MyServiceViewController *vc = [[MyServiceViewController alloc] init];
[vc setHidesBottomBarWhenPushed:YES];
//改變bar后再次獲取當(dāng)前控制器
UIViewController *VC = [self currentViewController];
[VC.navigationController pushViewController:vc animated:YES];
}else {
[SVProgressHUD showInfoWithStatus:@"請登錄后,前往我的服務(wù)查看谆扎。"];
}
}else {
//避免沒有導(dǎo)航欄跳轉(zhuǎn)崩潰的問題
[SVProgressHUD showErrorWithStatus:@"跳轉(zhuǎn)失敗挂捅,請自行前往個人中心查看。"];
}
[JPUSHService handleRemoteNotification:userInfo];
}
completionHandler(); // 系統(tǒng)要求執(zhí) 這個 法
以上跳轉(zhuǎn)代碼沙郭、獲取當(dāng)前頂層控制器都是相同的路克,不再解釋。
○
未啟動時受到消息如何處理紊服?如何跳轉(zhuǎn)
這種情況是最不容易找到的伺糠,因為當(dāng)你的應(yīng)用未啟動蒙谓,點擊了通知欄,它沒有調(diào)用任何極光的代理训桶,這時候需要我們?nèi)雍瘮?shù)進行判斷累驮。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self appStateInactive:launchOptions];
}
在上面啟動函數(shù)中調(diào)用一個方法,來判斷是否是收到通知啟動的舵揭。最后谤专,進行目標(biāo)控制器跳轉(zhuǎn)。
- (void)appStateInactive:(NSDictionary *)launchOptions {
/*
* 當(dāng)應(yīng)用不在后臺 點擊通知欄
*/
NSDictionary* pushInfo = [launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
if (pushInfo) {
NSDictionary *apsInfo = [pushInfo objectForKey:@"aps"];
if(apsInfo) {
[self.mainTab.tabBar showBadgeOnItemIndex:2];
UIViewController *currentVC = [self currentViewController];
if (currentVC.navigationController) {
if ([Person currentLoginUser].userId.length == 11) {
//先跳轉(zhuǎn)指定tab然后push到指定頁面
BaseTabBarController *myTbabar = (BaseTabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
myTbabar.selectedIndex = 2;
MyServiceViewController *vc = [[MyServiceViewController alloc] init];
[vc setHidesBottomBarWhenPushed:YES];
//更改后bar后再次獲取當(dāng)前控制器
UIViewController *VC = [self currentViewController];
[VC.navigationController pushViewController:vc animated:YES];
}else {
[SVProgressHUD showInfoWithStatus:@"請登錄后午绳,前往我的服務(wù)查看置侍。"];
}
}
}
}
}
○
收到自定義通知如何顯示?
自定義消息拦焚,這個比較特殊蜡坊,它必須是在app正在前臺的時候才能收到消息,收到消息的位置而且不在代理中赎败,而是在一個通知中秕衙。
當(dāng)注冊極光后可以加入下面代碼。注冊一個通知螟够。
// 注冊通知 當(dāng)收到自定義消息的時候
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(networkDidReceiveMessage:)
name:kJPFNetworkDidReceiveMessageNotification
object:nil];
這個通知類型極光文檔是這樣解釋的
kJPFNetworkDidReceiveMessageNotification // 收到消息(非APNS)
實現(xiàn)這個通知方法
/*
* 當(dāng)在前臺 接收到 自定義消息 通知
*/
- (void)networkDidReceiveMessage:(NSNotification *)notification {
//有沒有未讀消息
[self.mainTab.tabBar showBadgeOnItemIndex:2];
NSDictionary *userInfo = [notification userInfo];
NSString *content = [userInfo valueForKey:@"content"];
//獲取頂層
UIViewController *currentVC = [self currentViewController];
[TSMessage showNotificationInViewController:currentVC.navigationController
title:@"系統(tǒng)通知"
subtitle:content
image:[UIImage imageNamed:@"notifi"]
type:TSMessageNotificationTypeMessage
duration:TSMessageNotificationDurationAutomatic
callback:^{
//判斷是否有導(dǎo)航欄
if (currentVC.navigationController) {
if ([Person currentLoginUser].userId.length == 11) {
//先跳轉(zhuǎn)指定tab然后push到指定頁面
BaseTabBarController *myTbabar = (BaseTabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
myTbabar.selectedIndex = 2;
//改變bar后再次獲取當(dāng)前控制器
UIViewController *VC = [self currentViewController];
MyServiceViewController *vc = [[MyServiceViewController alloc] init];
[vc setHidesBottomBarWhenPushed:YES];
[VC.navigationController pushViewController:vc animated:YES];
}else {
[SVProgressHUD showInfoWithStatus:@"請登錄后灾梦,前往我的服務(wù)查看峡钓。"];
}
}else {//沒有導(dǎo)航欄
[SVProgressHUD showErrorWithStatus:@"跳轉(zhuǎn)失敗妓笙,請自行前往個人中心查看。"];
}
}
buttonTitle:nil
buttonCallback:^{
}
atPosition:TSMessageNotificationPositionNavBarOverlay
canBeDismissedByUser:YES];
}
上面代碼幾乎和在前臺收通知的代碼是一樣的能岩。有點需要說明的是這里我直接取的content
這個key
寞宫。我這邊讓后臺傳的是這個,當(dāng)然也有后臺會放extras
這個字段的json
數(shù)據(jù)拉鹃,我后面會有代碼詳細(xì)說這個解析辈赋。
○
怎么給指定用戶發(fā)送消息?
通知一般不是廣播式的膏燕,有時候需要針對不同用戶群體或者個體發(fā)送通知钥屈,例如優(yōu)惠券等。極光提供了幾種區(qū)分用戶的方法坝辫,在Web
中我們可以看到
設(shè)備標(biāo)簽篷就、別名、ID近忙、群推
標(biāo)簽和別名差不多竭业。只說別名≈侨螅現(xiàn)在有這個場景:我想給我所有的注冊用戶推送消息,沒注冊的不想推未辆。
這時候窟绷,你需要在極光登錄成功(非常重要,否則你可能出現(xiàn)注冊別名無效的情況)的通知方法中向極光服務(wù)器注冊Alias
。如下代碼咐柜,建議以userId或者服務(wù)器登錄返回tag
值注冊兼蜈,這樣后臺方便發(fā)送消息。登錄成功的通知名稱:kJPFNetworkDidLoginNotification
[JPUSHService setAlias:userId callbackSelector:@selector(alias:) object:self];
這樣你在web選擇對應(yīng)別名發(fā)送通知拙友,就可以推送到希望推送到的手機上了饭尝。
○
當(dāng)有多個類型通知的時候,怎么拿到服務(wù)器發(fā)送過來的extras的內(nèi)容献宫,然后根據(jù)類型做出正確的跳轉(zhuǎn)钥平?
在上面我們一直說的都是在控制臺直接發(fā)送消息,然而實際上我們推送都是后臺開發(fā)人員以API
的形式對接極光的服務(wù)器姊途。通知往往攜帶一些所需的參數(shù)涉瘾,例如紅包里面的金額cost...
不多說廢話,直接看我的解析代碼吧捷兰!
//json解析
- (NSDictionary *)jsonWithString:(NSString *)dataString {
NSData *data = [dataString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
return dic;
}
//內(nèi)部收到消息立叛,提示
- (void)showMessageWithUserInfo:(NSDictionary *)userInfo {
//獲取頂層控制器
[self.mainTab.tabBar showBadgeOnItemIndex:2];
UIViewController *currentVC = [self currentViewController];
NSString *messageAlert = [[userInfo objectForKey:@"aps"] objectForKey:@"alert"];
NSString *extras = [userInfo objectForKey:@"extras"];
NSDictionary *dic = [self jsonWithString:extras];
NSString *notifiType = [NSString stringWithFormat:@"%@",dic[@"messag_type"]];
[TSMessage showNotificationInViewController:currentVC.navigationController title:@"系統(tǒng)通知" subtitle:messageAlert image:[UIImage imageNamed:@"notifi"] type:TSMessageNotificationTypeMessage duration:TSMessageNotificationDurationAutomatic callback:^{
if (currentVC.navigationController) {
if ([Person currentLoginUser].userId.length == 11) {
if ([notifiType isEqualToString:@"1"]) {//消息類型
CommentViewController *vc = [[CommentViewController alloc] initWithNibName:@"CommentViewController" bundle:nil];
vc.orderTitle = dic[@"item_title"];
vc.remark = dic[@"comments"];
vc.time = dic[@"item_time"];
vc.orderId = [NSString stringWithFormat:@"%@",dic[@"item_id"]];
[vc setHidesBottomBarWhenPushed:YES];
[currentVC.navigationController pushViewController:vc animated:YES];
}else {
//其他消息類型
}
}else {
[SVProgressHUD showInfoWithStatus:@"請登錄后,前往我的服務(wù)查看贡茅。"];
}
}else {
[SVProgressHUD showErrorWithStatus:@"跳轉(zhuǎn)失敗秘蛇,請自行前往個人中心查看。"];
}
} buttonTitle:nil buttonCallback:^{
} atPosition:TSMessageNotificationPositionNavBarOverlay
canBeDismissedByUser:YES];
}
//外部收到消息顶考。點擊了消息
- (void)touchAlertWithUserInfo:(NSDictionary *)userInfo {
[self.mainTab.tabBar showBadgeOnItemIndex:2];
UIViewController *currentVC = [self currentViewController];
NSString *extras = userInfo[@"extras"];
NSDictionary *dic = [self jsonWithString:extras];
NSString *notifiType = [NSString stringWithFormat:@"%@",dic[@"messag_type"]];
if (currentVC.navigationController) {
if ([Person currentLoginUser].userId.length == 11) {
if ([notifiType isEqualToString:@"1"]) {//消息類型
//先跳轉(zhuǎn)指定tab然后push到指定頁面
BaseTabBarController *myTbabar = (BaseTabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
myTbabar.selectedIndex = 1;
//改變bar后再次獲取當(dāng)前控制器
UIViewController *VC = [self currentViewController];
CommentViewController *vc = [[CommentViewController alloc] initWithNibName:@"CommentViewController" bundle:nil];
vc.orderTitle = dic[@"item_title"];
vc.remark = dic[@"comments"];
vc.time = dic[@"item_time"];
vc.orderId = [NSString stringWithFormat:@"%@",dic[@"item_id"]];
[vc setHidesBottomBarWhenPushed:YES];
[VC.navigationController pushViewController:vc animated:YES];
}
}else {
[SVProgressHUD showInfoWithStatus:@"請登錄后赁还,前往我的服務(wù)查看。"];
}
}else {
[SVProgressHUD showErrorWithStatus:@"跳轉(zhuǎn)失敗驹沿,請自行前往個人中心查看艘策。"];
}
}
我把以上方法獨立出來。方法都有注釋渊季,不再講解朋蔫。那么,這時候我僅僅需要在合適的位置調(diào)用這些方法即可却汉!
例如驯妄。在后臺的時候
// iOS 10 Support
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {
// Required
NSDictionary *userInfo = response.notification.request.content.userInfo;
if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
/*
* 應(yīng)用在后臺 點擊了通知欄
*/
[self touchAlertWithUserInfo:userInfo];
[JPUSHService handleRemoteNotification:userInfo];
}
completionHandler(); // 系統(tǒng)要求執(zhí) 這個 法
}
在前臺的時候
// iOS 10 Support
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler {
// Required
NSDictionary *userInfo = notification.request.content.userInfo;
if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]
]) {
[JPUSHService handleRemoteNotification:userInfo];
}
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
/*
* 當(dāng)應(yīng)用在前臺 接到通知
*/
NSLog(@"userInfo : %@",userInfo);
//提示
[self showMessageWithUserInfo:userInfo];
completionHandler(UNNotificationPresentationOptionSound); // 需要執(zhí) 這個 法,選擇 是否提醒 戶合砂,有Badge青扔、Sound、Alert三種類型可以選擇設(shè)置
}else if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {//后臺
completionHandler(UNNotificationPresentationOptionAlert); // 需要執(zhí) 這個 法,選擇 是否提醒 戶赎懦,有Badge雀鹃、Sound、Alert三種類型可以選擇設(shè)置
}else {//未啟動
completionHandler(UNNotificationPresentationOptionAlert); // 需要執(zhí) 這個 法励两,選擇 是否提醒 戶黎茎,有Badge、Sound当悔、Alert三種類型可以選擇設(shè)置
}
}
我們看到通過方法獨立出來傅瞻,我們的代碼更簡潔,邏輯也更清晰了盲憎。
○
怎么在app內(nèi)部開啟嗅骄、關(guān)閉通知?
一般都在app設(shè)置中有一個switch
的開關(guān)饼疙。來開啟關(guān)閉通知溺森,代碼很簡單,直接貼上來窑眯。有一點需要注意屏积,就是這個開關(guān)的狀態(tài)需要存到本地,有高要求的存服務(wù)器磅甩。
cell.textLabel.text = @"消息提醒";
UISwitch *swi = [[UISwitch alloc] initWithFrame:CGRectMake(CGRectGetWidth(cell.frame)-15,7.5, 45, 30)];
//存儲到本地
NSUserDefaults *defaults = [[NSUserDefaults alloc] init];
NSString *isNotification = [defaults objectForKey:@"isNotification"];
NSLog(@"noti %@",isNotification);
if ([isNotification isEqualToString:@"0"]) {
swi.on = NO;
}else {
swi.on = YES;
}
[swi addTarget:self action:@selector(onOrOff:) forControlEvents:UIControlEventValueChanged];
[cell.contentView addSubview:swi];
#pragma mark -- 消息推送的 開/關(guān)
- (void)onOrOff:(UISwitch *)swi {
NSUserDefaults *defaults = [[NSUserDefaults alloc] init];
if (!swi.on) {//存入本地
[[UIApplication sharedApplication] unregisterForRemoteNotifications];//關(guān)閉
[defaults setObject:@"0" forKey:@"isNotification"];
}else {
[[UIApplication sharedApplication] registerForRemoteNotifications];
[defaults setObject:@"1" forKey:@"isNotification"];
}
}
另外炊林,不要忘記!你需要在啟動代理中也進行判斷開關(guān)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//是否關(guān)閉了推送卷要?
NSUserDefaults *defaults = [[NSUserDefaults alloc] init];
NSString *isNotification = [defaults objectForKey:@"isNotification"];
if ([isNotification isEqualToString:@"0"]) {
[[UIApplication sharedApplication] unregisterForRemoteNotifications];//關(guān)閉
}else {
[[UIApplication sharedApplication] registerForRemoteNotifications];//開啟
}
}
○
你測試包(真機調(diào)試)收到通知后渣聚,怎么確定上架包也能收到消息?
想要測試上架包僧叉,首先更改極光注冊代碼奕枝。production
改為YES
[JPUSHService setupWithOption:launchOptions appKey:kJPushAPPKey channel:@"apsForProduction" apsForProduction:YES
advertisingIdentifier:nil];
(開發(fā)、生產(chǎn)證書配置不再說彪标,網(wǎng)上很多)這個就涉及到打包的知識了倍权,開發(fā)環(huán)境就是真機調(diào)試的我就不說了。我們這里使用蒲公英平臺安裝生產(chǎn)環(huán)境包捞烟,archive
后選擇
然后選擇Ad Hoc
這樣打包就是生產(chǎn)包了。如果你沒有對應(yīng)的證書可以去配置当船,同時你還需要配置對應(yīng)描述文件题画。
iOS技術(shù)交流群:511860085
成堆的技術(shù)視頻福利,歡迎加入德频!