第一步:申请证书:

第二步:申请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的更多相关文章

  1. 远程通知APNs(Apple Push Notification Server)

    推送通知是由应用服务提供商发起的,通过苹果的APNs(Apple Push Notification Server)发送到应用客户端.下面是苹果官方关于推送通知的过程示意图: 推送通知的过程可以分为以 ...

  2. 苹果APNs’ device token特性和过期更新

    APNs全名是Apple Push Notification Service.用iPhone的应该都习惯了,每次安装完一个新应用启动后,几乎都会弹出个警告框,“XXX应用”想要给您发送推送通知.这个警 ...

  3. iOS13适配/黑暗模式的适配/KVC访问私有属性/模态弹窗ViewController 默认样式改变 /LaunchImage即将废弃/蓝牙的权限申请/推送Device Token适配/UIKit 控件变化/StatusBar新增样式

    目录 1. KVC访问私有属性 2. 模态弹窗ViewController 默认样式改变 3. 黑暗模式的适配 4. LaunchImage即将废弃 5. 新增一直使用蓝牙的权限申请 6. Sign ...

  4. [转]com.devicepush.cordova-phonegap Device Push Notification Plugin

    本文转自:https://www.npmjs.com/package/com.devicepush.cordova-phonegap Device Push Notification Plugin D ...

  5. push notification for iphone

    由于公司业务需求,以前一直做PHP开发,突然让我研究push notification ,一下子迷糊啦,不知所措,抓狂!但是在自己的努力下还是初有成效!现拿出来显摆一下! 1:push notific ...

  6. (转)苹果推送通知服务教程 Apple Push Notification Services Tutorial

    本文译自http://www.raywenderlich.com/.原文由iOS教程团队 Matthijs Hollemans 撰写,经原网站管理员授权本博翻译. 在iOS系统,考虑到手机电池电量,应 ...

  7. iOS上简单推送通知(Push Notification)的实现

    iOS上简单推送通知(Push Notification)的实现 根据这篇很好的教程(http://www.raywenderlich.com/3443/apple-push-notification ...

  8. apple 官方文档 Push Notification Programming

    iOS Developer LibraryDeveloper Search Local and Push Notification Programming Guide PDF Table of Con ...

  9. Provider Communication with Apple Push Notification Service

    This chapter describes the interfaces that providers use for communication with Apple Push Notificat ...

随机推荐

  1. Get sdcard directory by adb

    解决方案: adb shell echo $EXTERNAL_STORAGE  I am making an application, which pulls files(Saved by andro ...

  2. Winform开发主界面菜单的动态树形列表展示

    我在之前很多文章里面,介绍过Winform主界面的开发,基本上都是标准的界面,在顶部放置工具栏,中间区域则放置多文档的内容,但是在顶部菜单比较多的时候,就需要把菜单分为几级处理,如可以在顶部菜单放置一 ...

  3. Software license key and activation

    http://stackoverflow.com/questions/16222674/software-license-key-and-activationhttps://github.com/La ...

  4. request的各种方法大全

    request.setAttribute("result", district);//放进作用域,可以用el表达式在页面展示.(名字,调用方法的结果) pageContext.re ...

  5. 修复 XE7 update1 发布 iOS 8.x 实机问题

      1. 开启工程目录下面的 Entitlement.TemplateiOS.xml 档案. 2. 加入二行: <key>application-identifier</key> ...

  6. redis主从 以及认证配置

    以前用redis用的很多,各种数据类型用的飞起,算是用得很溜了.不过那都是封装好的方法,自己直接调用.以前的公司比较规范,开发只是开发,很少去做跟运维相关的事情. 换了一份工作,不过这边项目刚开始起步 ...

  7. 利用FileStream实现多媒体文件复制

        利用FileStream实现多媒体文件复制的主要思路在于利用两个FileStream对象,一个读取字节,另一个对象写入字节既可.     涉及知识点: 1.通常我们操作的File类,FileS ...

  8. Struts2框架的自定义类型转换器

    前言:对于java的基本数据类型及一些系统类(如Date类.集合类),Struts2提供了内置类型转换功能,但是也有一定的限制.所以就演示出自定义类型转换器 一.应用于局部类型转换器 eg.用户登录出 ...

  9. mysql hang and srv_error_monitor_thread using 100% cpu

    昨天晚上,运维过来说有台生产服务器的mysql cpu一直100%,新的客户端登录不了,但是已经在运行的应用都正常可用. 登录服务器后,top -H看了下,其中一个线程的cpu 一直100%,其他的几 ...

  10. rabbitmq启动异常之error,{not_a_dets_file recovery.dets

    中午,公司群里面测试人员@笔者说,早上测试服务器异常,MQ起不来,重启os了也起不来,报错,上去看下了早上又因为内存oom被内核killed了,启动了下,确实启动报错,erl vm进程起来了,但是be ...