亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 系統 > iOS > 正文

iOS自定義推送消息提示框

2020-07-26 03:12:38
字體:
來源:轉載
供稿:網友

看到標題你可能會覺得奇怪 推送消息提示框不是系統自己彈出來的嗎? 為什么還要自己自定義呢? 

因為項目需求是這樣的:最近需要做 遠程推送通知 和一個客服系統 包括店鋪客服和官方客服兩個模塊 如果有新的消息推送的時候 如果用戶當前不在客服界面的時候  要求無論是在app前臺 還是app退到后臺 頂部都要彈出系統的那種消息提示框

這樣的需求 我們就只能自定義一個在app內 彈出消息提示框  

實現步驟如下: 

1.我們自定義一個view 為 STPushView 推送消息的提示框view 

#import <UIKit/UIKit.h>#import "STPushModel.h"@interface STPushView : UIView/** *推送數據模型 */@property(nonatomic,strong) STPushModel *model;+(instancetype)shareInstance;+ (void)show;+ (void)hide;@end 
#import "STPushView.h"#import "AppDelegate.h"@interface STPushView()@property (nonatomic, weak) UIImageView *imageV;@property (nonatomic,weak ) UILabel *timLabel;@property (nonatomic,weak ) UILabel *content;@end@implementation STPushViewstatic STPushView *_instance = nil;+(instancetype)shareInstance{ static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ _instance = [[STPushView alloc] init]; }); return _instance;}+(instancetype) allocWithZone:(struct _NSZone *)zone{ if (!_instance) { _instance = [super allocWithZone:zone]; } return _instance ;}- (instancetype)initWithFrame:(CGRect)frame{ if (self = [super initWithFrame:frame]) {  self.backgroundColor = CUSTOMCOLOR(15, 14, 12);  CGFloat margin = 12; UIImageView *imageV = [[UIImageView alloc] init]; imageV.userInteractionEnabled = NO; imageV.image = [UIImage imageNamed:@"logo"]; imageV.layer.cornerRadius = 5; [self addSubview:imageV]; self.imageV = imageV; [imageV mas_makeConstraints:^(MASConstraintMaker *make) {  make.left.equalTo(self).offset(margin);  make.centerY.equalTo(self.mas_centerY);  make.width.mas_equalTo(30);  make.height.mas_equalTo(30); }];   UILabel *titleLabel = [[UILabel alloc] init]; titleLabel.textColor = [UIColor whiteColor]; titleLabel.font = [UIFont boldSystemFontOfSize:12]; titleLabel.text = @"121店官方客服"; [self addSubview:titleLabel]; [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {  make.left.equalTo(imageV.mas_right).offset(margin);  make.top.equalTo(self.mas_top).offset(margin);  make.height.mas_equalTo(16); }]; [titleLabel sizeToFit];  UILabel *timLabel = [[UILabel alloc] init]; timLabel.font = [UIFont systemFontOfSize:12]; timLabel.userInteractionEnabled = NO; timLabel.textColor = [UIColor whiteColor]; timLabel.text = @"剛剛"; timLabel.textColor = [UIColor lightGrayColor]; [self addSubview:timLabel]; self.timLabel = timLabel; [timLabel mas_makeConstraints:^(MASConstraintMaker *make) {  make.left.equalTo(titleLabel.mas_right).offset(margin);  make.top.equalTo(self.mas_top).offset(margin);  make.width.mas_lessThanOrEqualTo(40);  make.height.mas_equalTo(16); }];   UILabel *content = [[UILabel alloc] init]; content.numberOfLines = 2; content.font = [UIFont systemFontOfSize:13]; content.textColor = [UIColor whiteColor]; content.userInteractionEnabled = NO; [self addSubview:content]; self.content = content; [content mas_makeConstraints:^(MASConstraintMaker *make) {  make.left.equalTo(imageV.mas_right).offset(margin);  make.top.equalTo(titleLabel.mas_bottom).offset(-3);  make.right.equalTo(self.mas_right).offset(-margin);  make.height.mas_equalTo(35); }];   UIView *toolbar = [[UIView alloc] init]; toolbar.backgroundColor = CUSTOMCOLOR(121, 101, 81); toolbar.layer.cornerRadius = 3; [self addSubview:toolbar]; [toolbar mas_makeConstraints:^(MASConstraintMaker *make) {  make.width.mas_equalTo(35);  make.height.mas_equalTo(6);  make.centerX.equalTo(self.mas_centerX);  make.bottom.equalTo(self.mas_bottom).offset(-2); }];  } return self;}- (void)setModel:(STPushModel *)model{ _model = model; self.timLabel.text = @"剛剛"; self.content.text = model.content;}+ (void)show{  [UIApplication sharedApplication].statusBarHidden = YES; STPushView *pushView = [STPushView shareInstance]; pushView.hidden = NO;  AppDelegate *app = (AppDelegate*)[UIApplication sharedApplication].delegate; [app.window bringSubviewToFront:pushView]; [UIView animateWithDuration:0.25 animations:^{  pushView.frame = CGRectMake(0, 0, SCREEN_WIDTH, pushViewHeight);  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{    [UIView animateWithDuration:0.25 animations:^{    pushView.frame = CGRectMake(0, -pushViewHeight, SCREEN_WIDTH, pushViewHeight);      } completion:^(BOOL finished) {    [UIApplication sharedApplication].statusBarHidden = NO;  pushView.hidden = YES;    }];   });  }];}+ (void)hide{ STPushView *pushView = [STPushView shareInstance]; [UIView animateWithDuration:0.25 animations:^{  pushView.frame = CGRectMake(0, -pushViewHeight, SCREEN_WIDTH, pushViewHeight);  } completion:^(BOOL finished) {  [UIApplication sharedApplication].statusBarHidden = NO; pushView.hidden = YES;  }];}@end 

上面pushView需要一個模型 實現代碼如下 

// push 推送的model推送過來的數據如下:/** content = dsfdsnfds; id = 5077; mid = 1270339; title = dsfdsnfds; url = "3?_from=push"; urlType = 3;  **/#import <Foundation/Foundation.h>@interface STPushModel : STBaseModel<NSCoding> //STBaseModel 是一個繼承自NSObject的類 我主要是在這個類中實現了字典轉模型的功能 你可以直接修改為NSObject/***id**/@property (copy,nonatomic) NSString* recordId;/***標題**/@property (copy, nonatomic) NSString *title;/***url**/@property (copy, nonatomic) NSString *url;/***url 類型**/@property (copy, nonatomic) NSString* urlType;/***圖標的高度**/@property (assign,nonatomic) NSString * mid;/***推送內容**/@property (copy, nonatomic) NSString* content;@end 

因為涉及到好幾個頁面需要使用同樣的推送消息數據 進行判斷而處理相應的業務 所有我對此模型做了歸檔處理

#import "STPushModel.h"@implementation STPushModel/** * 保存對象到文件中 * * @param aCoder <#aCoder description#> */-(void)encodeWithCoder:(NSCoder *)aCoder{ [aCoder encodeObject:self.recordId forKey:@"recordId"]; [aCoder encodeObject:self.title forKey:@"title"]; [aCoder encodeObject:self.url forKey:@"url"]; [aCoder encodeObject:self.urlType forKey:@"urlType"]; [aCoder encodeObject:self.mid forKey:@"mid"]; [aCoder encodeObject:self.content forKey:@"content"];}/** * 從文件中讀取對象 * * @param aDecoder <#aDecoder description#> * * @return <#return value description#> */-(id)initWithCoder:(NSCoder *)aDecoder{ //注意:在構造方法中需要先初始化父類的方法 if (self=[super init]) { self.recordId=[aDecoder decodeObjectForKey:@"recordId"]; self.title=[aDecoder decodeObjectForKey:@"title"]; self.url=[aDecoder decodeObjectForKey:@"url"]; self.urlType=[aDecoder decodeObjectForKey:@"urlType"]; self.mid=[aDecoder decodeObjectForKey:@"mid"]; self.content= [aDecoder decodeObjectForKey:@"content"]; } return self;}@end 

做好了上面的準備工作之后  接下來我們就需要 APPdelegate里面注冊遠程推送通知  并且監聽推送消息 

這里以個推為例子:

第一步在下面的方法中 實現個推的注冊方法 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 注冊個推推送服務 [[GeTuiApilmpl sharedInstance] geTuiRegister];} 

GeTuiApilmpl 是一個單例類 專門用于注冊個推的推送方法 實現代碼如下:

#import <Foundation/Foundation.h>#import "GeTuiSdk.h"@interface GeTuiApilmpl : NSObject <GeTuiSdkDelegate>+ (GeTuiApilmpl *) sharedInstance;- (void) geTuiRegister;@end 
#import "GeTuiApilmpl.h"@implementation GeTuiApilmpl+ (GeTuiApilmpl *) sharedInstance{ static id instance = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ instance = [[self alloc] init]; }); return instance;}- (id)init { self = [super init]; if (self) { NSString *path = [[NSBundle mainBundle] pathForResource:@"libGexin" ofType:@"plist"]; NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:path]; [GeTuiSdk startSdkWithAppId:[dic objectForKey:@"GT_APPID"]    appKey:[dic objectForKey:@"GT_APPKEY"]    appSecret:[dic objectForKey:@"GT_APPSECRET"]    delegate:self]; } return self;}#pragma mark - GeTuiSdkDelegate/** SDK啟動成功返回cid */- (void)GeTuiSdkDidRegisterClient:(NSString *)clientId { // [4-EXT-1]: 個推SDK已注冊,返回clientId NSLog(@"/n>>>[GeTuiSdk RegisterClient]:%@/n/n", clientId);}/** SDK遇到錯誤回調 */- (void)GeTuiSdkDidOccurError:(NSError *)error { // [EXT]:個推錯誤報告,集成步驟發生的任何錯誤都在這里通知,如果集成后,無法正常收到消息,查看這里的通知。 NSLog(@"/n>>>[GexinSdk error]:%@/n/n", [error localizedDescription]);}/** SDK收到透傳消息回調 */- (void)GeTuiSdkDidReceivePayload:(NSString *)payloadId andTaskId:(NSString *)taskId andMessageId:(NSString *)aMsgId andOffLine:(BOOL)offLine fromApplication:(NSString *)appId { // [4]: 收到個推消息 NSData *payload = [GeTuiSdk retrivePayloadById:payloadId]; NSString *payloadMsg = nil; if (payload) { payloadMsg = [[NSString alloc] initWithBytes:payload.bytes length:payload.length encoding:NSUTF8StringEncoding]; } NSString *msg = [NSString stringWithFormat:@" payloadId=%@,taskId=%@,messageId:%@,payloadMsg:%@%@", payloadId, taskId, aMsgId, payloadMsg, offLine ? @"<離線消息>" : @""]; NSLog(@"/n>>>[GexinSdk ReceivePayload]:%@/n/n", msg); /** *匯報個推自定義事件 *actionId:用戶自定義的actionid,int類型,取值90001-90999。 *taskId:下發任務的任務ID。 *msgId: 下發任務的消息ID。 *返回值:BOOL,YES表示該命令已經提交,NO表示該命令未提交成功。注:該結果不代表服務器收到該條命令 **/ [GeTuiSdk sendFeedbackMessage:90001 taskId:taskId msgId:aMsgId];}/** SDK收到sendMessage消息回調 */- (void)GeTuiSdkDidSendMessage:(NSString *)messageId result:(int)result { // [4-EXT]:發送上行消息結果反饋 NSString *msg = [NSString stringWithFormat:@"sendmessage=%@,result=%d", messageId, result]; NSLog(@"/n>>>[GexinSdk DidSendMessage]:%@/n/n", msg);}/** SDK運行狀態通知 */- (void)GeTuiSDkDidNotifySdkState:(SdkStatus)aStatus { // [EXT]:通知SDK運行狀態 NSLog(@"/n>>>[GexinSdk SdkState]:%u/n/n", aStatus);}/** SDK設置推送模式回調 */- (void)GeTuiSdkDidSetPushMode:(BOOL)isModeOff error:(NSError *)error { if (error) { NSLog(@"/n>>>[GexinSdk SetModeOff Error]:%@/n/n", [error localizedDescription]); return; } NSLog(@"/n>>>[GexinSdk SetModeOff]:%@/n/n", isModeOff ? @"開啟" : @"關閉");}-(void)geTuiRegister{ } 

然后再appDelegate 調用注冊遠程推送的方法  

/** 注冊用戶通知 */- (void)registerUserNotification { /* 注冊通知(推送) 申請App需要接受來自服務商提供推送消息 */ // 判讀系統版本是否是“iOS 8.0”以上 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 || [UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) { // 定義用戶通知類型(Remote.遠程 - Badge.標記 Alert.提示 Sound.聲音) UIUserNotificationType types = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound; // 定義用戶通知設置 UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil]; // 注冊用戶通知 - 根據用戶通知設置 [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; [[UIApplication sharedApplication] registerForRemoteNotifications]; } else { // iOS8.0 以前遠程推送設置方式 // 定義遠程通知類型(Remote.遠程 - Badge.標記 Alert.提示 Sound.聲音) UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound; // 注冊遠程通知 -根據遠程通知類型 [[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes]; }} 

然后再設置了窗口的跟控制器 之后 調用:addPushView方法 添加 消息提示框STPushView:  addPushView實現代碼如下 

#pragma mark 推送信息展示//添加推送view- (void)addPushView{ STPushView *topView = [STPushView shareInstance]; topView.frame = CGRectMake(0, -pushViewHeight, SCREEN_WIDTH, pushViewHeight); [_window addSubview:topView]; self.topView = topView; topView.hidden = YES;  UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hudClick)]; UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)]; [topView addGestureRecognizer:tap]; [tap requireGestureRecognizerToFail:pan]; topView.gestureRecognizers = @[tap,pan]; }#pragma mark addPushView相關事件- (void)hudClick{ self.topView.userInteractionEnabled = NO;  [UIView animateWithDuration:0.25 animations:^{ self.topView.frame = CGRectMake(0, -pushViewHeight, SCREEN_WIDTH, pushViewHeight); }completion:^(BOOL finished) { [UIApplication sharedApplication].statusBarHidden = NO; [self hudClickOperation];  }];}- (void)hudClickOperation{ [self push:nil]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ self.topView.userInteractionEnabled = YES; });}- (void)pan:(UIPanGestureRecognizer*)pan{ CGFloat distance = pushViewHeight-(pushViewHeight-[pan translationInView:self.window].y); if (distance<-20) { [UIView animateWithDuration:0.25 animations:^{  self.topView.frame = CGRectMake(0, -pushViewHeight, SCREEN_WIDTH, pushViewHeight); }completion:^(BOOL finished) {  [UIApplication sharedApplication].statusBarHidden = NO; }]; }}//顯示pushView- (void)displayPushView{ [STPushView show];} 

上面push方法的實現代碼如下: 處理邏輯 是根據我自己的項目中需求定的 在這里實現你需要處理的代碼

- (void)push:(NSDictionary *)params{  STPushModel *model = [ NSKeyedUnarchiver unarchiveObjectWithFile:KRAPI_PUSH_DATA];  //如果是h5 if ([model.urlType isEqualToString:@"h5"]) {  BOOL isStore = [[AnalysisUrl sharedInstance] analysisWebUrl:model.url]; BOOL isGoods = [[AnalysisUrl sharedInstance] analysisGoodsIdWebUrl:model.url]; BOOL isRedBag =[[AnalysisUrl sharedInstance] analyredBagWebUrl:model.url]; BOOL istrace =[[AnalysisUrl sharedInstance] analytraceWebUr:model.url]; BOOL islog =[[AnalysisUrl sharedInstance] analylogWebUrl:model.url]; if (isStore || isGoods) {  [[WYPageManager sharedInstance] pushViewControllerWithUrlString:model.url currentUrlString:TRAKER_URL_INDEX];   }else if (isRedBag) {  RedBageViewController * regBag =[[RedBageViewController alloc]init];  NSArray *array = [model.url componentsSeparatedByString:@"="];  NSString * string = [array lastObject];  regBag.messageID = string;  regBag.redType = @"coupon";  UITabBarController *tabVC = (UITabBarController *)self.window.rootViewController;  UINavigationController *pushClassStance = (UINavigationController *)tabVC.viewControllers[tabVC.selectedIndex];  // 跳轉到對應的控制器  regBag.hidesBottomBarWhenPushed = YES;  [pushClassStance pushViewController:regBag animated:YES];  return; }else if (istrace) {  RedBageViewController * regBag =[[RedBageViewController alloc]init];  NSString * string = [StrUtils getIdFromURLString:model.url interceptString:@"/trace/"];  regBag.messageID = string;  regBag.redType = @"trace";  UITabBarController *tabVC = (UITabBarController *)self.window.rootViewController;  UINavigationController *pushClassStance = (UINavigationController *)tabVC.viewControllers[tabVC.selectedIndex];  // 跳轉到對應的控制器  regBag.hidesBottomBarWhenPushed = YES;  [pushClassStance pushViewController:regBag animated:YES];  return; }else if (islog) {  RedBageViewController * regBag =[[RedBageViewController alloc]init];  NSString * string = [StrUtils getIdFromURLString:model.url interceptString:@"/log/"];  regBag.messageID = string;  regBag.redType = @"log";  UITabBarController *tabVC = (UITabBarController *)self.window.rootViewController;  UINavigationController *pushClassStance = (UINavigationController *)tabVC.viewControllers[tabVC.selectedIndex];  // 跳轉到對應的控制器  regBag.hidesBottomBarWhenPushed = YES;  [pushClassStance pushViewController:regBag animated:YES];  return; } else{  if (![model.url isEqualToString:@""]) {  UIStoryboard *setStoryboard = [UIStoryboard storyboardWithName:@"UserCenter" bundle:nil];  TotalWebViewController *setVC = [setStoryboard instantiateViewControllerWithIdentifier:@"TotalWebViewController"];  setVC.shopUrl = model.url;  setVC.shopTitle = [model.title isEqualToString:@""] ? @"121店" : model.title;  UITabBarController *tabVC = (UITabBarController *)self.window.rootViewController;  UINavigationController *pushClassStance = (UINavigationController *)tabVC.viewControllers[tabVC.selectedIndex];  setVC.hidesBottomBarWhenPushed = YES;  [pushClassStance pushViewController:setVC animated:YES];  } } }else if ([model.urlType isEqualToString:@"native"]){    if ([model.url isEqualToString:@"1"]) {  //一元體驗購 已經刪除    }else if ([model.url isEqualToString:@"2"]){  if (([[STCommonInfo getAuthType] intValue] != 1)) {   [self createGroundGlass];  }else{   STProFitViewController *vc = [[STProFitViewController alloc] init];   UITabBarController *tabVC = (UITabBarController *)self.window.rootViewController;   UINavigationController *pushClassStance = (UINavigationController *)tabVC.viewControllers[tabVC.selectedIndex];   vc.hidesBottomBarWhenPushed = YES;   [pushClassStance pushViewController:vc animated:YES];  }  }else if ([model.url isEqualToString:@"3"]){  if (([[STCommonInfo getAuthType] intValue] != 1)) {   [self createGroundGlass];  }else{      MessageMainVC *messageVC = [[MessageMainVC alloc] init];   messageVC.hidesBottomBarWhenPushed = YES;   UITabBarController *tabVC = (UITabBarController *)self.window.rootViewController;   UINavigationController *pushClassStance = (UINavigationController *)tabVC.viewControllers[tabVC.selectedIndex];   [pushClassStance pushViewController:messageVC animated:YES];  }  }else if ([model.url hasPrefix:@"http://"]&&([model.url rangeOfString:@"client"].location!=NSNotFound)){ //跳轉到客服接 界面    NSString *orgIdString =[[AnalysisUrl sharedInstance] extractOrgId:model.url];  NSString *siteIdString = [[AnalysisUrl sharedInstance] extractOrgIdStoreId:model.url];  [[WYPageManager sharedInstance] pushViewController:@"TLChatViewController" withParam:   @{   @"title_nameString":@"官方客服",   @"orgIdString":orgIdString,   @"siteIdString":siteIdString,   @"currentURL":model.url   } animated:YES];    } }} 

然后再AppDelegate 實現以下方法

/** 自定義:APP被“推送”啟動時處理推送消息處理(APP 未啟動--》啟動)*/- (void)receiveNotificationByLaunchingOptions:(NSDictionary *)launchOptions { if (!launchOptions) return; /* 通過“遠程推送”啟動APP UIApplicationLaunchOptionsRemoteNotificationKey 遠程推送Key */ NSDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if (userInfo) { NSLog(@"/n>>>[Launching RemoteNotification]:%@", userInfo); }}#pragma mark - 用戶通知(推送)回調 _IOS 8.0以上使用/** 已登記用戶通知 */- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { // 注冊遠程通知(推送) [application registerForRemoteNotifications];}#pragma mark - 遠程通知(推送)回調/** 遠程通知注冊成功委托 */- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSString *myToken = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]]; myToken = [myToken stringByReplacingOccurrencesOfString:@" " withString:@""]; NSUserDefaults *kr = [NSUserDefaults standardUserDefaults]; [kr setValue:myToken forKey:@"deviceToken"]; [kr synchronize]; [GeTuiSdk registerDeviceToken:myToken]; [[PostDeviceToken sharedInstance] postUpDeviceToken]; NSLog(@"/n>>>[DeviceToken Success]:%@/n/n", myToken);}/** 遠程通知注冊失敗委托 */- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [GeTuiSdk registerDeviceToken:@""]; NSLog(@"/n>>>[DeviceToken Error]:%@/n/n", error.description);}#pragma mark - APP運行中接收到通知(推送)處理/** APP已經接收到“遠程”通知(推送) - 透傳推送消息 */- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler { // 處理APN NSLog(@"/n>>>[Receive RemoteNotification - Background Fetch]:%@/n/n", userInfo); completionHandler(UIBackgroundFetchResultNewData);  NSString *payLoadString = [[MyPrevent sharedInstance] dictionary:userInfo objectForKey:@"payload"]; [[SpotPunch sharedInstance] spotPunch:@"999.999.1" pointTwo:@"21" info:payLoadString]; // NSUserDefaults *kr = [NSUserDefaults standardUserDefaults]; if (!([[STCommonInfo getAuthType] intValue] != 1)) { NSData *jsonData = [payLoadString dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:jsonData        options:NSJSONReadingMutableContainers         error:nil];  STPushModel *model = [STPushModel modelObjectWithDict:jsonDic]; [NSKeyedArchiver archiveRootObject:model toFile:KRAPI_PUSH_DATA];//如果應用程序在前臺 就顯示客服提示框 if (application.applicationState == UIApplicationStateActive) {  self.topView.model = model;  [self displayPushView]; //此方法 的實現 在上一步中 就是展示提示框出來 }  }} 

然后這些工作做好了之后 就是你需要在個推的后臺 配置推送證書  這個配置的步驟 大家可以到個推官網去參考文檔 配置  

這里我假設 你已經配置到證書了  經過上面的步驟 我們的遠程推送通知的方法 基本完成 現在我們運行 測試下 你會發現即使在前臺 有新消息推送的時候 頂部也會彈出和系統一樣的提示框 點擊 跳轉到對應的頁面的方法邏輯根據你的需要 去做跳轉處理 

測試效果如下:

用戶在后臺 收到的消息提示如下:

用戶在前臺 收到的消息提示如下:


本文已被整理到了《iOS推送教程》,歡迎大家學習閱讀。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
精品国模在线视频| 日韩美女免费线视频| 日韩欧美视频一区二区三区| 亚洲欧美一区二区三区四区| 热re91久久精品国99热蜜臀| 日韩精品丝袜在线| 欧美大片大片在线播放| 亚洲国产日韩欧美在线动漫| 九九精品在线视频| 日韩av最新在线观看| 播播国产欧美激情| 国产99视频精品免视看7| 国产欧美日韩中文字幕在线| 欧美激情精品久久久久久久变态| 精品人伦一区二区三区蜜桃免费| 中文字幕精品视频| 亚洲一区二区三区香蕉| 欧美激情一级精品国产| 久久99久国产精品黄毛片入口| 亚洲综合精品一区二区| 欧美裸体xxxx| 日本精品一区二区三区在线| 日韩中文字幕网| 国产精品aaa| 欧美成人精品一区| 国产欧美一区二区三区四区| 亚洲国产另类 国产精品国产免费| 亚洲欧洲xxxx| 66m—66摸成人免费视频| 欧美午夜激情小视频| 岛国av一区二区在线在线观看| 91精品国产777在线观看| 久久久999国产| 国产精品免费在线免费| 日韩欧美999| 亚洲欧美中文字幕在线一区| 国产91在线高潮白浆在线观看| 欧美亚洲视频一区二区| 亚洲精品在线91| 91久久精品国产91久久性色| 国产精品一香蕉国产线看观看| 亚洲国产欧美一区二区丝袜黑人| 成人看片人aa| 国产精品va在线| 91精品在线观看视频| 久久久噜噜噜久久久| 亚洲欧美一区二区三区四区| 国产日韩在线看| 亚洲字幕在线观看| 一区二区三区视频在线| 亚洲色图校园春色| 亚洲午夜未删减在线观看| 亚洲色在线视频| 国产免费一区二区三区在线能观看| 国产69久久精品成人看| 亚洲国产精品99| 尤物tv国产一区| 91在线色戒在线| 欧美日韩中文在线| 成人信息集中地欧美| 亚洲自拍欧美另类| 成人久久18免费网站图片| 68精品国产免费久久久久久婷婷| 国产精品无码专区在线观看| 国产欧美日韩丝袜精品一区| 97视频网站入口| 国产网站欧美日韩免费精品在线观看| 国产精品亚洲激情| 亚洲男人天天操| 中文字幕日韩有码| 91社区国产高清| 欧美激情xxxxx| 综合久久五月天| 欧美专区在线视频| 欧美成人合集magnet| 一区国产精品视频| 川上优av一区二区线观看| 国产精品jizz在线观看麻豆| 久久久久久网址| 一区二区三区四区精品| 91午夜在线播放| 青青a在线精品免费观看| 久久久精品视频在线观看| 久久成人综合视频| 亚洲精品国产品国语在线| 久久久噜久噜久久综合| 国产精品久久激情| 国产欧洲精品视频| 欧美乱妇高清无乱码| 91色在线观看| 亚洲白虎美女被爆操| 久久成人这里只有精品| 国产女同一区二区| 91福利视频在线观看| 激情懂色av一区av二区av| 欧美日韩免费区域视频在线观看| 少妇精69xxtheporn| 亚洲精品99久久久久| 日韩欧美在线字幕| 国产美女搞久久| 成人午夜高潮视频| 亚洲午夜精品久久久久久性色| 国产精品18久久久久久首页狼| 国产日本欧美在线观看| 日韩精品久久久久| 一道本无吗dⅴd在线播放一区| 成人免费看片视频| 欧美电影免费观看电视剧大全| 色播久久人人爽人人爽人人片视av| 欧美另类xxx| 欧美福利视频网站| 亚洲精品美女视频| 性夜试看影院91社区| 精品福利在线视频| 欧美午夜影院在线视频| 久久影视免费观看| 欧美激情视频一区二区三区不卡| 欧美中文字幕视频| 国产精品久久网| 国产一区二区三区高清在线观看| 清纯唯美日韩制服另类| 亚洲免费小视频| 欧美精品手机在线| 久久精品国产成人精品| 91sao在线观看国产| 亚洲欧美日韩高清| 91成人国产在线观看| 欧美日韩xxxxx| 免费不卡欧美自拍视频| 91av在线播放视频| 欧美精品激情视频| 性欧美视频videos6一9| 高跟丝袜一区二区三区| 国模叶桐国产精品一区| 日韩av资源在线播放| 欧美亚洲第一区| 国产91在线播放九色快色| 亚洲欧美另类在线观看| 欧洲精品在线视频| 69久久夜色精品国产69乱青草| 亚洲欧美制服另类日韩| 日韩欧美999| 色综久久综合桃花网| 日韩在线视频网站| 高跟丝袜一区二区三区| 国内精品一区二区三区四区| 亚洲国产中文字幕久久网| 91沈先生作品| 久久在线视频在线| 亚洲精品日产aⅴ| 欧美成人精品在线播放| 国产91精品在线播放| 在线观看日韩专区| 日韩精品极品在线观看| 亚洲另类激情图| 久久久女人电视剧免费播放下载| 91精品国产自产在线老师啪| 中文字幕日韩av电影| 欧美最顶级的aⅴ艳星| 欧美成人网在线| 中文字幕亚洲色图| 亚洲欧洲日产国产网站| 久久久久久国产| 在线观看免费高清视频97|