您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
IOS 远程通知
1.证书推送安装
证书的操作过程我就不说了,网上一大堆,首先我要说一下为什么要这些证书其实就是告诉苹果服务器三点:
1.我们要为哪个应用做推送
2.哪台电脑上做推送调试
3.哪台手机设备上做推送调试
我把调试做了高亮,因为总有人问为什么我要在mac上双击安装cer文件和mobileprovision文件,就是因为你要调试,如果你不调试你可以生成后不安装.
2.代码实现
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. if (IS_iOS_8) { //获取当前UIUserNotificationType状态 UIUserNotificationType oType = application.currentUserNotificationSettings.types; if (oType == UIUserNotificationTypeNone) { NSLog(@"通知被禁止"); }else{ UIUserNotificationType type = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound; UIUserNotificationSettings* settings = [UIUserNotificationSettings settingsForTypes:type categories:nil]; [application registerUserNotificationSettings:settings]; [application registerForRemoteNotifications]; } }else{ UIRemoteNotificationType type = UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound; [application registerForRemoteNotificationTypes:type]; } return YES; }
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{ //苹果服务器告诉我们的设备编号 NSLog(@"%@,%@",NSStringFromSelector(_cmd),deviceToken); } - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{ //我们公司服务器推送给我们的通知 NSLog(@"%@",userInfo); }
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。