iOS Push通知资料.
来源:互联网 发布:java回调函数的作用 编辑:程序博客网 时间:2024/06/04 20:03
http://blog.csdn.net/think12/article/details/8863411 // IOS Push 证书的重新生成
本文着重讨论如何合成证书
1.将aps_developer_identity.cer转换成pem
openssl x509 -in aps_developer_identity.cer -inform der -out PushChatCert.pem
2.将Apple Development Push Services证书转换成pem
(push.p12文件是在钥匙串里面用证书生成的)
openssl pkcs12 -nocerts -out PushChatKey.pem -in Push.p12
3.合成两个pem证书
1)Java服务器所需的证书为p12格式
openssl pkcs12 -export -in PushChatCert.pem -inkey PushChatKey.pem -out pushCert.p12 -name “apns-cert”
2)PHP服务器所需证书为pem格式
cat PushChatCert.pem PushChatKey.pem > pushCert.pem
//这两行代码是用来测试的时候配合php测试来使用的,附件中的图片有详细介绍,附件有php运行源文件。
telnet gateway.sandbox.push.apple.com 2195
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert PushChatCert.pem -key PushChatKey.pem
PHP服务器推送代码
李建国 10:35:18
七 项目测试
建立我们的推送的项目(注意BundleIdentifier必须和我们推送应用的App id一致)
在AppDelegate里didFinishLaunchingWithOptions函数里写
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
……
//推送的形式:标记,声音,提示
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
return YES;
}
- (void)application:(UIApplication *)applicationdidRegisterForRemoteNotificationsWithDeviceToken:(NSData *)pToken {
NSLog(@"regisger success:%@",pToken);
//注册成功,将deviceToken保存到应用服务器数据库中
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
// 处理推送消息
NSLog(@"userinfo:%@",userInfo);
NSLog(@"收到推送消息:%@",[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]);
}
- (void)application:(UIApplication *)applicationdidFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
NSLog(@"Registfail%@",error);
}
我们运行程序的时候会有提示,说我们的程序要发送推送通知
//解析请求返回的deviceToken
const unsigned *tokenBytes = [deviceToken bytes];
NSString *hexToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",
ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
NSLog(@"regisger success:%@",hexToken);
- iOS Push通知资料.
- iOS接收push通知
- IOS-Push通知
- iOS开发-push远程通知
- Parse--iOS Push(推送通知)
- 浅析iOS中Push通知的使用
- 浅析iOS中Push通知的使用【图文+视频】
- iOS上简单推送通知(Push Notification)的实现
- 浅析iOS中Push通知的使用【图文+视频】
- 判断iOS设备的PUSH通知设置状态(打开。。。/关闭)
- 使用OpenSSL发送IOS推送通知 Apple Push Notification
- iOS上简单推送通知(Push Notification)的实现
- 使用OpenSSL发送IOS推送通知 Apple Push Notification
- 蛋疼的Apple IOS Push通知协议
- 蛋疼的Apple IOS Push通知协议
- 判断iOS设备的PUSH通知设置状态(打开。。。/关闭)
- iOS推送通知(Push Notification)的Erlang实现
- iOS - APNs(Apple Push Notification Services)推送通知
- SQL注入的一些笔记(一)
- Hibernate主键生成策略
- Basic Level 1001. 害死人不偿命的(3n+1)猜想 (15)
- Oracle RANK函数
- 开博第一篇,写点关于GPGPU的东西吧
- iOS Push通知资料.
- IMP导入错误 IMP-00003: ORACLE error 2298 encountered
- c#对象和json对象转换方法总结
- Spring框架的IoC和AOP
- shell ftp判断远程主机是否存在某目录
- objective-c基础教程——学习小结
- [LeetCode] Word Ladder II
- js 浏览器自适应例子
- 年会上用到的抽奖