iOS: iphone在真机测试以及apns的设置

本文详细介绍了在iOS开发中如何进行真机测试和设置Apple Push Notification Service(APNS),包括创建证书请求文件、导出私钥、生成开发证书、注册设备、创建App ID、启用APNS、创建Provisioning Profile以及搭建PHP和C#版本的推送服务器。通过这些步骤,开发者可以成功在真机上调试应用并实现推送通知功能。
摘要由CSDN通过智能技术生成

以开发一个"MobileCAP" app为例


Step 1: Create cert request file。(当你在apple web site "provisioning portal"里生成"Development Certificate" 和 "Push SSL Certificate"时就会用到它

1. Access "keychain access" by selecting "Application > Utilities > keychain access"

2. select menu "keychain access > certificate assistant > request certificate from a certificate authority"

3. set "User Email Address" as the same email address that you used to sign up for the iOS Developer Program, and set "Common Name" as "MobileCAP", leave "CA Email address" empty, and tick "Save to disk" option, click Continue button

4. set “Save the file” as “MobileCAP.certSigningRequest”.

当完成step 1后,就会在Keychain Access的“Keys” section里生成了name为"MobileCAP"的public key and private key pair


在Step 1过程中,有可能出error ''The specified item could not be found in the keychain"。解决方法是:restart keychain tool, and then 在keychain tool里,不要选择"keys" item,应该选择"all items",and then try again! (make sure you see "Let me specify key pair information" option in first wizard window, if you can't see it, may still fail)

参考链接 http://blog.csdn.net/totogogo/article/details/18632211


Step 2: export "MobileCAP" private key to a ".p12" file(该文件会在后面生成apns provider的.p12 or .pem file时用到)

1. right click "MobileCAP“ private key and select "Export MobileCAP..."

2. Save the private key as “MobileCAPKey.p12” file, click Save button

3. 这时会让你输入2次用于加密该.p12 file的密码,例如用"123456",接着会要求你输入一次your mac account password


Step 3: Generate a "development certificate" file and download it (会生成一个cert file,该cert会被import to keychain access里,若你要在真机上调试app,这步是必须的,另外该development certificate会在后面创建provisioning profile时用到)

注意:"development certificate"是与developer account对应的,即一个developer account只能生成一个"development certificate"。如果你之前已经创建过该cert, then just download it

1. 在apple web site "provisioning portal > Certificates" page, click "request certificate" button

2. 然后选定step 1生成的cert request file "MobileCAP.certSigningRequest"

3. follow the wizard, 就会生成一个cert file "ios_development.cer" file, and then click the "download" link to download it


Step 4: 创建Registered device (这是把你要进行调试app的device添加到apple web site "provisioning portal > Devices" page,若你要在真机上调试app,这步是必须的,另外在后面创建provisioning profile时要把该device包含进去,否则无法在该device上调试)

1. 在apple web site "provisioning portal > Devices" page, click "Add Device" button

2. 输入device name (任意名字)and device id (把你的device连接到电脑后,在iTunes可以查到device id)


Step 5: Create App ID (若你要在真机上调试app,这步是必须的,另外它会在后面创建provisioning profile时用到,每个provisioning profile只对应一个app ID)

关于App ID和你创建的project的product name, company identifier的关系参看 http://blog.csdn.net/totogogo/article/details/7377870

App ID是开发和预配置系统的重要组件。这个唯一的ID允许应用程序与Apple Push Notification服务以及与外部硬件附件通信。App ID也可以用于在一组应用程序内共享密钥链数据,比如密码。另外它还用于configuration data between your applications using

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值