【转】iOS8 推送 获取 devicetoken
打开AppDelegate.m
怎么做:
首先:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptionsadd Code like this#ifdef __IPHONE_8_0 //Right, that is the point UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeAlert) categories:nil]; [[UIApplication sharedApplication] registerUserNotificationSettings:settings];#else //register to receive notifications UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound; [[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];#endif |
接着:
添加如下函数
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#ifdef __IPHONE_8_0- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{ //register to receive notifications [application registerForRemoteNotifications];}- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler{ //handle the actions if ([identifier isEqualToString:@"declineAction"]){ } else if ([identifier isEqualToString:@"answerAction"]){ }}#endif |
然后你会在如下方法中获得deviceToken
|
1
|
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken |
如果该函数没有响应, 使用如下函数并NSLog error
|
1
|
-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error |
【转】iOS8 推送 获取 devicetoken的更多相关文章
- ios8推送问题
博文转载至 http://blog.csdn.net/cerastes/article/details/39546625 ios8push推送通知适配 ios8推送问题 registerForRem ...
- iOS 推送 获取手机设备的 deviceToken
第一步:申请证书: 第二步:申请app ids,应用名字必须一致.然后再进入进行编辑.使其enable,绿灯. 第三步:申请provisioning profile,生成.mobileprovisio ...
- iOS8推送消息的回复处理速度
iOS8我们有一个新的通知中心,我们有一个新的通报机制.当在屏幕的顶部仅需要接收一个推拉向下,你可以看到高速接口,天赋并不需要输入应用程序的操作.锁定屏幕,用于高速处理可以推动项目. 推送信息,再次提 ...
- iOS8推送消息的快速回复处理
http://blog.csdn.net/yujianxiang666/article/details/35260135 iOS8拥有了全新的通知中心,有全新的通知机制.当屏幕顶部收到推送时只需要往下 ...
- iOS7、iOS8推送通知的区别
iOS8版本以后的推送通知代码[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificati ...
- iOS8 推送注册方式改变的问题
不久之后iPhone 6/6 plus就会在国内如雨后春笋般遍地开花了.iOS 8早已现行一步,不过有的开发者也注意到了在iOS 8上推送通知的注册方式有所变化,报错提示为: 1 registerFo ...
- 信鸽推送(XGPush)
先放入两个链接: iOS信鸽接入官方文档:http://developer.qq.com/wiki/xg/iOS接入/iOS%20SDK完整接入/iOS%20SDK完整接入.html 信鸽开放平台:h ...
- IOS 本地通知推送消息
在现在的移动设备中,好多应用性的APP都用到了推送服务,但是有好多推送的内容,比如有的只是单纯的进行推送一个闹钟类型的,起了提醒作 用,有的则是推送的实质性的内容,这就分为推送的内容来区别用什么推送, ...
- iOS推送,看这篇足够了
一.注册推送: - (void)registerNotification { if ([[[UIDevice currentDevice] systemVersion] floatValue] > ...
随机推荐
- Java开发手册
<Java开发手册> 基本信息 作者: 桂颖 谷涛 出版社:电子工业出版社 ISBN:9787121209161 上架时间:2013-8-12 出版日期:2013 年7月 开本 ...
- GPL,LGPL和BSD等协议注意事项
使用开源软件必须注意GPL,LGPL和BSD等协议 简而言之,GPL协议就是一个开放源代码协议,软件的初始开发者使用了GPL协议并公开软件的源程序后,后续使用该软件源程序开发软件者亦应当根据GPL协议 ...
- java生成随机整数
1. 使用Random类的nextInt方法: Random rand = new Random(); rand.nextInt(max);, 此时输出[0,max),注意右边是开区间,如果需要设定最 ...
- Shadow Register 是什么?
ARM处理器有个Shadow Register的概念,查了很多资料,语焉不详,究竟是什么意思呢? 这其实是个和硬件有关的概念. 有些register是2层的,第一层是供CPU访问,第二层供Hw访问. ...
- [转]Ubuntu上的包管理:dpkg,apt和aptitude
一直以来对于ubuntu的包管理的概念就是apt-get,偶尔手动装个包就是dpkg -i,现在觉得是要系统地了解一下这几个包管理的命令. 原文转自: http://zhouliang.pro/201 ...
- 内存模型(memory models)和命名空间(namespace)
继续<C++ premier plus > 先来解释一下scope和linkage,所谓scope,是指变量的作用范围,所谓linkage,是指变量能否在不同文件中共享 1,自动变量(au ...
- SRM 409(1-250pt, 1-500pt)
DIV1 250pt 题意:称string s是vector<string> words的ordered superstring,如果它满足:存在一个数列{x0, x1, x2...xm} ...
- nginx做负载均衡器以及proxy缓存配置 - SegmentFault
nginx做负载均衡器以及proxy缓存配置 - SegmentFault nginx做负载均衡器以及proxy缓存配置
- android 随手记 倒计时
class CountDownUtils extends CountDownTimer { public CountDownUtils(long millisInFuture, long countD ...
- db2 alter table 语法
DB2 alter:add/delete/reset column 1.添加字段 alter table [table_name] add [column_name] [column_type] ...