[iOS 高级] iOS远程推送与本地推送大致流程
2018-03-31 10:41
337 查看
本地推送:
假设应用已退出。这时候要在以下的方法中来取出推送并处理
远程推送的大致流程例如以下:
1.使用appId注冊推送服务
2.获得推送用的token
3.app上传token到自己的server
4.自己的server将推送信息和token发送给apns
5.apns进行推送
示意图:
UILocalNotification *notification=[[UILocalNotification alloc] init]; if (notification!=nil) { NSDate *now=[NSDate new]; notification.fireDate=[now dateByAddingTimeInterval:60];//60秒后通知 notification.repeatInterval=0;//循环次数 notification.timeZone=[NSTimeZone defaultTimeZone]; notification.applicationIconBadgeNumber=1; //应用的红色数字 notification.soundName= UILocalNotificationDefaultSoundName;//声音 notification.alertBody=@"通知内容";//提示信息 弹出提示框 notification.alertAction = @"打开"; //提示框button //notification.hasAction = NO; //是否显示额外的button。为no时alertAction消失 // NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"]; //notification.userInfo = infoDict; //加入额外的信息 [[UIApplication sharedApplication] scheduleLocalNotification:notification]; }推送过后。假设应用处于后台状态,可实现代理方法来进行想要的操作
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{ }
假设应用已退出。这时候要在以下的方法中来取出推送并处理
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UILocalNotification * push=[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];//取出推送对象 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; }
远程推送的大致流程例如以下:
1.使用appId注冊推送服务
2.获得推送用的token
3.app上传token到自己的server
4.自己的server将推送信息和token发送给apns
5.apns进行推送
示意图:
相关文章推荐
- [iOS 高级] iOS远程推送与本地推送大致流程
- iOS-本地推送和远程推送,常用的三方推送和常用的测试方法,推送实现和原理详解
- iOS之[本地通知, 远程推送, 广播通知]
- iOS本地推送与远程推送详解(一图看懂)
- IOS本地,APNS远程推送(具体过程)
- ios远程推送与本地推送
- IOS本地,APNS远程推送(具体过程)
- 干货——iOS本地推送与远程推送详解
- ios 远程推送和本地推送
- IOS中程序如何进行推送消息(本地推送,远程推送)
- iOS学习 本地推送与远程推送
- iOS—接收到APNs远程推送消息时的处理流程
- IOS本地,APNS远程推送(具体过程)
- iOS APNs远程推送流程精简版
- ios 本地推送和远程推送(APNS)
- iOS本地推送与远程推送
- 【iOS】本地推送和模拟远程推送
- iOS 推送通知:本地通知(UILocalNotification)和远程通知(APNs)详解
- IOS开发之高级功能---远程推送
- iOS-本地推送和远程推送,常用的三方推送和常用的测试方法,推送实现和原理详解