iOS PUSH实现的简单步骤
来源:互联网 发布:冒险岛数据库中心市场 编辑:程序博客网 时间:2024/05/28 23:11
A>本地钥匙串生成证书请求文件,XXX.certSignningRequest
B>developer.apple.com,创建新的appId,用于新的项目.这里有一点需要注意,identify要和工程中plist中的属性保持一致
C>在完成B之后Configurable一下push相关的项目,可以根据实际需求,分别选择developement或者production.在configrable的时候会用到步骤A中生成的certSignningRequest,最后我们可以得到XXX.csr证书文件。下载双击进行安装
D>再回到developer.apple.com,在provision中create新的XX.mobileprovision,OK之后down下来,然后在xcode中的organizer中添加
E>xcode创建新的工程,配置相关信息,着重强调identify.
F>在工程中的AppDelegate重写以下方法
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:viewController.view];
[window makeKeyAndVisible];
NSLog(@"Registering for push notifications...");
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound)];
application.applicationIconBadgeNumber = 0; //程序开启,设置UIRemoteNotificationTypeBadge标识为0
}
//得到deviceToken
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSString *str = [NSString
stringWithFormat:@"Device Token=%@",deviceToken];
NSLog(str);
}
//注册失败后输出相关信息
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSString *str = [NSString stringWithFormat: @"Error: %@", err];
NSLog(str);
}
//应用接收到push信息后我们自己的处理
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
for (id key in userInfo) {
NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
}
}
当然了,最后还是要把一些本地的证书导出后给我们的服务器,这样服务器才能向APPLE发送消息,APPLE确定这些消息来源安全可靠的情况下,就会安装了对应APP的设备push消息了。服务器那边的设置我就不再累述了···
我写得简单了点。这里有更详细的描述。···
http://tiny4cocoa.com/thread-1406-1-1.html
PS:但是导出证书的地方步骤还没有官方来得简洁:https://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ProvisioningDevelopment/ProvisioningDevelopment.html#//apple_ref/doc/uid/TP40008194-CH104-SW1
{
Open Keychain Access utility and click the My Certificates category in the left pane.
Find the certificate you want to install and disclose its contents.
You'll see both a certificate and a private key.
Select both the certificate and key, choose File > Export Items, and export them as a Personal Information Exchange (.p12) file.
Servers implemented in languages such as Ruby and Perl often are better able to deal with certificates in the Personal Information Exchange format. To convert the certificate to this format, complete the following steps:
In KeyChain Access, select the certificate and choose File > Export Items. Select the Personal Information Exchange (.p12) option, select a save location, and click Save.
Launch the Terminal application and enter the following command after the prompt:
openssl pkcs12 -in
CertificateName.p12 -out
CertificateName.pem -nodes
Copy the
.pem
certificate to the new computer and install it in the appropriate place
}
- ios push实现的简单实现步骤
- iOS PUSH实现的简单步骤
- iOS PUSH实现的简单步骤
- ios的push实现
- iOS上简单推送通知(Push Notification)的实现
- iOS上简单推送通知(Push Notification)的实现
- iOS 转场动画简单实现 (push)
- 简单Server Push的实现
- iOS iOS应用PUSH功能的实现
- BAPI的简单实现步骤
- BAPI的简单实现步骤
- BAPI的简单实现步骤
- iOS push的问题
- iOS远程Push Notification实现
- 实现iOS应用PUSH功能
- 实现一个简单的服务端推送方案-实例篇Push
- 实现一个简单的服务端推送方案-实例篇Push
- Ruby语言实现IOS的push推送功能
- 深入浅出LDD-1-最简单的helloworld
- android判断网络是否连接一些注意事项(有代码)
- N皇后问题(DFS)
- 屏蔽烦人的flash和图片,firefox
- int与size_t类型比较问题
- iOS PUSH实现的简单步骤
- 苹果拒绝专利授权三星 诉讼或蔓延至中国地区
- 简洁大方,为自己的Android App添加一个ContextMenu
- Ajax里的onreadystatechange的作用
- 二分矩阵
- CSS文档流与块级元素(block)内联元素(inline)那点事(转自www.jqueryba.com)
- 1.一对一外键双向关联(人对身份证):object,hbm
- 腾讯高速增长初现天花板 微信或将成为未来门票
- 给Super-smack的gen-data程序添加整数长度控制