第一步:申请证书:

第二步:申请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. canvas画简单电路图

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. SQL Server论坛楼层计算触发器

    代码: USE suya_dev GO IF EXISTS( SELECT * FROM sys.triggers WHERE name = N'BBS_Post_before_insert' ) D ...

  3. c#初学-多线程中lock用法的经典实例

    本文转载自:http://www.cnblogs.com/promise-7/articles/2354077.html 一.Lock定义     lock 关键字可以用来确保代码块完成运行,而不会被 ...

  4. C#中在AxWebBrowser控件注入JS脚本的方法

    /// <summary> /// 窗体加载 /// </summary> private void JS_Load(object sender, EventArgs e) { ...

  5. sql 指定值排序

    --SELECT [ButtonName] as text,[FunctionName] as handler,[iconCls] --FROM [ButtonTable] where PKID in ...

  6. EL表达式之sessionScope

    EL 全名为Expression Language EL 语法很简单,它最大的特点就是使用上很方便.接下来介绍EL主要的语法结构: ${sessionScope.user.sex} 所有EL都是以 $ ...

  7. Android中自定义ProgressBar

    <ProgressBar             android:id="@+id/more_vprogress_more"             android:layo ...

  8. 编译gcc

    下载源码 自GNU FTP站下载GCC. 自Infrastructure页面下载四个库的源代码,即GMP.MPFR.MPC以及ISL(ISL非必需). 也可以不手工下载,执行源码中的./contrib ...

  9. 2016弱校联盟十一专场10.2---Around the World(深搜+组合数、逆元)

    题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52305 problem  description In ICPCCamp, there ar ...

  10. 用java实现新浪爬虫,代码完整剖析(仅针对当前SinaSignOn有效)

    先来看我们的web.xml文件,如下 <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application ...