push notification获取device token
第一步:申请证书:

第二步:申请app ids,应用名字必须一致。然后再进入进行编辑,使其enable,绿灯。

第三步:申请provisioning profile,生成.mobileprovision,双击该证书才能正确导入手机设备,不能拖。


第四步:创建应用,使其名字一致。

第五步:写代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// return YES;
UIRemoteNotificationType types =
(UIRemoteNotificationTypeBadge
|UIRemoteNotificationTypeSound
|UIRemoteNotificationTypeAlert);
//注册消息推送
[[UIApplication sharedApplication]registerForRemoteNotificationTypes:types];
return YES;
}
//获取DeviceToken成功
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSLog(@"DeviceToken: {%@}",deviceToken);
//这里进行的操作,是将Device Token发送到服务端
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:nil message:[NSStringstringWithFormat:@"DeviceToken:%@",deviceToken] delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定",nil];
[alert show];
}
//注册消息推送失败
- (void)application:(UIApplication *)application
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(@"Register Remote Notifications error:{%@}",error);
// NSLog(@"Register Remote Notifications error:{%@}",error.localizedDescription);
}
//处理收到的消息推送
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSLog(@"Receive remote notification : %@",userInfo);
UIAlertView *alert =
[[UIAlertView alloc] initWithTitle:@"温馨提示"
message:@"推送成功!"
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alert show];
}
push notification获取device token的更多相关文章
- 远程通知APNs(Apple Push Notification Server)
推送通知是由应用服务提供商发起的,通过苹果的APNs(Apple Push Notification Server)发送到应用客户端.下面是苹果官方关于推送通知的过程示意图: 推送通知的过程可以分为以 ...
- 苹果APNs’ device token特性和过期更新
APNs全名是Apple Push Notification Service.用iPhone的应该都习惯了,每次安装完一个新应用启动后,几乎都会弹出个警告框,“XXX应用”想要给您发送推送通知.这个警 ...
- iOS13适配/黑暗模式的适配/KVC访问私有属性/模态弹窗ViewController 默认样式改变 /LaunchImage即将废弃/蓝牙的权限申请/推送Device Token适配/UIKit 控件变化/StatusBar新增样式
目录 1. KVC访问私有属性 2. 模态弹窗ViewController 默认样式改变 3. 黑暗模式的适配 4. LaunchImage即将废弃 5. 新增一直使用蓝牙的权限申请 6. Sign ...
- [转]com.devicepush.cordova-phonegap Device Push Notification Plugin
本文转自:https://www.npmjs.com/package/com.devicepush.cordova-phonegap Device Push Notification Plugin D ...
- push notification for iphone
由于公司业务需求,以前一直做PHP开发,突然让我研究push notification ,一下子迷糊啦,不知所措,抓狂!但是在自己的努力下还是初有成效!现拿出来显摆一下! 1:push notific ...
- (转)苹果推送通知服务教程 Apple Push Notification Services Tutorial
本文译自http://www.raywenderlich.com/.原文由iOS教程团队 Matthijs Hollemans 撰写,经原网站管理员授权本博翻译. 在iOS系统,考虑到手机电池电量,应 ...
- iOS上简单推送通知(Push Notification)的实现
iOS上简单推送通知(Push Notification)的实现 根据这篇很好的教程(http://www.raywenderlich.com/3443/apple-push-notification ...
- apple 官方文档 Push Notification Programming
iOS Developer LibraryDeveloper Search Local and Push Notification Programming Guide PDF Table of Con ...
- Provider Communication with Apple Push Notification Service
This chapter describes the interfaces that providers use for communication with Apple Push Notificat ...
随机推荐
- [译]学习IPython进行交互式计算和数据可视化(四)
第三章 使用Python进行数字计算 尽管IPython强大的shell和扩展后的控制台能被任何Python程序员使用,但是这个工具最初是科学奖为科学家设计的.它的主要设计目标就是为使用Python进 ...
- STOP:c0000218 {Registry File Failure}
这几天够折腾的了,一台很老很老的服务器,在启动之后,一个阵列磁盘掉线了: 也许是磁盘坏了: 服务器4个硬盘做的是RAID1,正常来说,坏了其中一二个硬盘是没有问题的.现更换了一个好的硬盘之后,系统无法 ...
- Entity Framework 实体框架的形成之旅--为基础类库接口增加单元测试,对基类接口进行正确性校验(10)
本篇介绍Entity Framework 实体框架的文章已经到了第十篇了,对实体框架的各个分层以及基类的封装管理,已经臻于完善,为了方便对基类接口的正确性校验,以及方便对以后完善或扩展接口进行回归测试 ...
- jquery列表顺序倒转排序效果
html文件代码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type&quo ...
- C# 表达式学习积累
/// <summary> /// 读取html里面的body内容(不包括<body>标签) /// </summary> /// <param name=& ...
- div css仿京东订单流程图样式代码
效果展示 http://hovertree.com/texiao/css/25/ 本效果适合PC,也适合移动端 手机扫描二维码查看效果: 效果图: 代码如下: <!DOCTYPE html> ...
- [教学] Firemonkey 之 StringGrid Header 自订显示
StringGrid Header 高度设定方法: uses FMX.Header; procedure TForm1.StringGrid1ApplyStyleLookup(Sender: TObj ...
- 数据查询语言DQL 与 内置函数(聚合函数)
数据查询语言DQL 从表中获取符合条件的数据 select select*from表的名字 查询表所有的数据.(select跟from必须一块用 成对出现的) * 表示所有字段,可以换成想要查询的 ...
- R语言-GA算法脚本
? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 ...
- rabbitmq启动异常之error,{not_a_dets_file recovery.dets
中午,公司群里面测试人员@笔者说,早上测试服务器异常,MQ起不来,重启os了也起不来,报错,上去看下了早上又因为内存oom被内核killed了,启动了下,确实启动报错,erl vm进程起来了,但是be ...