ImageVerifierCode 换一换
格式:DOCX , 页数:16 ,大小:462.26KB ,
资源ID:6089613      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6089613.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(net推送证书脚本.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

net推送证书脚本.docx

1、net推送证书脚本.net推送证书脚本openssl x509 -in aps_developer_identity.cer -inform DER -out aps_developer_identity.pem -outform PEMopenssl pkcs12 -nocerts -out PushChat_Noenc.pem -in PushChatKey.p12openssl pkcs12 -export -in aps_developer_identity.pem -inkey PushChat_Noenc.pem -certfile PushChat.certSigningRequ

2、est -name aps_developer_identity -out aps_developer_identity.p12-openssl x509 -in aps_production_identity.cer -inform DER -out aps_production_identity.pem -outform PEMopenssl pkcs12 -nocerts -out PushChat_Noenc.pem -in PushChatKey.p12openssl pkcs12 -export -in aps_production_identity.pem -inkey Push

3、Chat_Noenc.pem -certfile PushChat.certSigningRequest -name aps_production_identity -out aps_production_identity.p12推送证书for .netPush的原理:Push 的工作机制可以简单的概括为下图 图中,Provider是指某个iPhone软件的Push服务器,这篇文章我将使用.net作为Provider。APNS 是Apple Push Notification Service(Apple Push服务器)的缩写,是苹果的服务器。上图可以分为三个阶段。第一阶段:.net应用程序把

4、要发送的消息、目的iPhone的标识打包,发给APNS。第二阶段:APNS在自身的已注册Push服务的iPhone列表中,查找有相应标识的iPhone,并把消息发到iPhone。第三阶段:iPhone把发来的消息传递给相应的应用程序, 并且按照设定弹出Push通知。 从上图我们可以看到。 1、首先是应用程序注册消息推送。2、 IOS跟APNS Server要deviceToken。应用程序接受deviceToken。3、应用程序将deviceToken发送给PUSH服务端程序。4、 服务端程序向APNS服务发送消息。5、APNS服务将消息发送给iPhone应用程序。 无论是iPhone客户端跟

5、APNS,还是Provider和APNS都需要通过证书进行连接的。下面我介绍一下几种用到的证书。几种证书:一、*.certSigningRequest文件 1、生成Certificate Signing Request (CSR):2、填写你的邮箱和Common Name,这里填写为PushChat。选择保存到硬盘。这样就在本地生成了一个PushChat.certSigningRequest文件。二、生成*.p12文件1、导出密钥,并输入你的密码。输入你的密码:这样就生成了一个PushChatKey.p12文件。三、新建一个App ID 和SSL certificate文件1、用你的付过费的a

6、pple帐号登录到iOS Provisioning Portal。新建一个App ID。 Description:中输入PushChat Bundle Seed ID:默认选择Generate New Bundle Identifier:输入com.mysoft.PushChat 点击提交这样就会生成下面这条记录:点击配置:出现下面界面,点击继续:这里我们选择前面生成好的PushChat.certSigningRequest文件,点击生成。正在生成生成完毕,我们把它下载下来。命名为aps_developer_identity.cer。点击完成,你会发现状态变成Enabled。到现在为止,我们已

7、经生成了3个文件。1、PushChat.certSigningRequest2、PushChatKey.p123、aps_developer_identity.cer现在我们创建一个简单的iPhone应用程序。1、打开Xcode,选择创建一个View-based Application。命名如下图:2、在PushChatAppDelegate中的didFinishLaunchingWithOptions方法中加入下面代码:- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDicti

8、onary *)launchOptionsself.window.rootViewController = self.viewController;self.window makeKeyAndVisible;/ Let the device know we want to receive push notificationsUIApplication sharedApplication registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRem

9、oteNotificationTypeAlert);return YES;通过registerForRemoteNotificationTypes方法,告诉应用程序,能接受push来的通知。3、在xcode中运行,会弹出下面的提示框:选择OK。表示此应用程序开启消息通知服务。在PushChatAppDelegate.m代码中添加下面方法获取deviceToken:- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken

10、NSLog(My token is: %, deviceToken);- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)errorNSLog(Failed to get token, error: %, error);获取到的deviceToken,我们可以通过webservice服务提交给.net应用程序,这里我简单处理,直接打印出来,拷贝到.net应用环境中使用。发送通知的.net应用程序出来需要知道deviceToken之外,

11、还需要一个与APNS连接的证书。这个证书可以通过我们前面生成的两个文件中得到。使用OpenSSL生成.net和APNS通信的证书文件。1、将aps_developer_identity.cer转换成 aps_developer_identity.pem格式。openssl x509 -in aps_developer_identity.cer -inform DER -out aps_developer_identity.pem -outform PEM2、将p12格式的私钥转换成pem,需要设置4次密码,这里密码都设置为:abc123。openssl pkcs12 -nocerts -out

12、 PushChat_Noenc.pem -in PushChat.p123、用certificate和the key创建PKCS#12格式的文件。openssl pkcs12 -export -in aps_developer_identity.pem -inkey PushChat_Noenc.pem -certfile PushChat.certSigningRequest -name aps_developer_identity -out aps_developer_identity.p12这样我们就得到了在.net应用程序中使用的证书文件:aps_developer_identity.

13、p12。在.net应用程序中发送通知。有个开源的类库:apns-sharp。地址是:我们下载源代码,对里面的JdSoft.Apple.Apns.Notifications做相应的调整就能用了。我们根据DeviceToken和p12File对JdSoft.Apple.Apns.Notifications.Test代码做相应的调整,如下图。这样就OK了。效果:通知的代码:for (int i = 1; i = count; i+)/Create a new notification to sendNotification alertNotification = new Notification(t

14、estDeviceToken);alertNotification.Payload.Alert.Body = string.Format(Testing 0., i);alertNotification.Payload.Sound = default;alertNotification.Payload.Badge = i;/Queue the notification to be sentif (service.QueueNotification(alertNotification)Console.WriteLine(Notification Queued!);elseConsole.Writ

15、eLine(Notification Failed to be Queued!);/Sleep in between each messageif (i count)Console.WriteLine(Sleeping + sleepBetweenNotifications + milliseconds before next Notification.);System.Threading.Thread.Sleep(sleepBetweenNotifications);用手机拍的ipad上面的显示:总结:这篇文章主要是详细的讲述了ios消息推送机制的实现,如何通过.net应用程序发送消息给ios应用程序。

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1