使用ASP.NET服务器添加iPhone推送通知 [英] Add iPhone push notification using ASP.NET server

查看:123
本文介绍了使用ASP.NET服务器添加iPhone推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的概述。

我要推送通知添加到一个iPhone应用程序。服务器端是ASP.NET在C#。

I need to add push notification to an iPhone app. Server side is ASP.NET in c#.

我想是有些教练经历的过程工作。我随后会将该通用code为iPhone项目,并一步一步的指示一起,以便其他人可以了解一个ASP.NET Web应用程序。

What I would like is some coaching to work through the process. I will then post generic code for an iPhone project and an ASP.NET web app along with step-by-step instructions so that others can learn.

下面是我的理解:


  1. 申请APNS证书,并把它添加到钥匙串。 (不知道如何把这个给ASP.NET)

  2. 有iPhone手机与registerForRemoteNotificationWithTypes注册,送价值,您的服务器和存储在一个数据库。看起来这code注册应该很容易,但我不能找到一个很好的样本。 (无问题发送值到ASP.NET服务器。)

  3. 您的服务器应用程序创建一个有效载荷的字符串,不JSON编码,使用他们的设备令牌保存到数据库的iPhone发送到APNS服务器为每个(也可以是团体)。

所以要开发另外,这里有件:

So to develop the addition, here are the pieces:


  • 在iPhone注册code

  • The iPhone registration code

code发送iPhone注册code到服务器,并保存到DB(这是容易的,我已经有了这件)。

Code that sends iPhone registration code to server and saves to DB (this is easy and I already have these pieces).

在服务器端APNS接触code在C#。这也包括如何使用是在苹果开发者网站上生成的证书。

The server side APNS contact code in c#. This also includes how to use the certificate that was generated on the Apple Developer web site.

另外,可以将有效载荷是可与发送回服务器的结果回答选择题

Also, can the payload be a multiple choice question that can be answered with the result sent back to the server?

在此先感谢您的帮助。我会在把这个为别人的教程。

Thanks in advance for the help. I will turn this in to a tutorial for others.

推荐答案

这花了我永远搞清楚,但我终于从细微的线索人们留下拼凑在一起。您需要下载证书为您的开发者门户注册APPID。该证书必须被转换成可在Windows中使用的P12的格式。在UNIX这些命令终于做到了我:

This took me forever to figure out but I finally pieced it all together from the minor clues people left. You need to download the certificate for the APPID that you register on the developer portal. That certificate must be converted into a P12 format to be used on Windows. These commands in UNIX finally did it for me:

第1步:

openssl x509 -in aps_developer_identity.cer -inform DER -out aps_developer_identity.pem -outform PEM}

在哪里aps_developer_identity.cer你是从门户网站下载文件

Where aps_developer_identity.cer is the file you download from the portal

第二步:

openssl pkcs12 -nocerts -out APSCertificates.pem -in APSCertificates.p12

在哪里APSCertificates.p12你是从Mac钥匙扣导出文件。这是至关重要的,必须从门户证书导入钥匙串。发现它在我的证书,打开显示三角形,突出证书和私钥,然后右键单击并导出。给他们一个密码,并将它们保存到P12文件。

Where APSCertificates.p12 is a file you export from the Mac Keychain. This is critical, you must import the certificate from the portal into keychain. Find it in My Certificates, open the disclosure triangle and highlight both the certificate and the private key, then right click and export them. Give them a password and save them to a p12 file.

步骤3:

openssl pkcs12 -export -in aps_developer_identity.pem -out aps_developer_identity.p12 -inkey APSCertificates.pem

您将被提示输入您用于导出在钥匙串的证书和私钥密码几次,再次提示的新密码重新加密这一切,但最终你将文件aps_developer_identity.p12这你需要移动到窗口,然后将其导入证书管理的MMC两种个人和受信任的根部分。然后在C#中,当你使用MoonAPNS并要求你把它交给该证书的路径PushNotification类。另外,还要确保从设备令牌删除空格。

You will be prompted a few times for the password you used to export the certificate and private key in Keychain and prompted again for new passwords to re-encrypt it all, but in the end you will have the file aps_developer_identity.p12 which you need to move to windows, then import it into both the Personal and Trusted Root sections of certificate manager in MMC. Then in C# when you use MoonAPNS and call the PushNotification class you give it a path to that certificate. Also make sure to remove spaces from the device token.

这篇关于使用ASP.NET服务器添加iPhone推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆