apns备忘

2023-11-23 03:58
文章标签 备忘 apns

本文主要是介绍apns备忘,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

以前生成的develop证书过期了,今天死活client都无法获取tockenid了,报告“未找到应用程序的xxx的全力字符串”,经过一翻调试,重做证书后,ok

1 push(certification)证书必须和开发证书(key)一起才能导出为p12

2 必须手动把支持push的profile加入到device,之前一直用team develop的证书,可以运行,但是不支持push,导致有上面的错误。

3 第一次安装后启动程序会提示是否允许通知,以后即使卸载后再次安装都不会再有提示,即使通知被禁用也不会提示打开

//***************************************************

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ProvisioningDevelopment/ProvisioningDevelopment.html

Provisioning and Development

Sandbox and Production Environments

To develop and deploy the provider side of a client/server application, you must get SSL certificates from the iPhone Provisioning Portal. Each certificate is limited to a single application, identified by its bundle ID. Each certificate is also limited to one of two development environments, each with its own assigned IP address:

  • Sandbox: The sandbox environment is used for initial development and testing of the provider application. It provides the same set of services as the production environment, although with a smaller number of server units. The sandbox environment also acts a virtual device, enabling simulated end-to-end testing.

    You access the sandbox environment at gateway.sandbox.push.apple.com, outbound TCP port 2195.

  • Production: Use the production environment when building the production version of the provider application. Applications using the production environment must meet Apple’s reliability requirements.

    You access the production environment at gateway.push.apple.com, outbound TCP port 2195.

You must get separate certificates for the sandbox (development) environment and the production environment. The certificates are associated with an identifier of the application that is the recipient of push notifications; this identifier includes the application’s bundle ID. When you create a provisioning profile for one of the environments, the requisite entitlements are automatically added to the profile, including the entitlement specific to push notifications, <aps-environment>. The two provisioning profiles are called Development and Distribution. The Distribution provisioning profile is a requirement for submitting your application to the App Store.

You can determine in Xcode which environment you are in by the selection of a code-signing identity. If you see an “iPhone Developer: Firstname Lastname” certificate/provisioning profile pair, you are in the sandbox environment. If you see an “iPhone Distribution: Companyname” certificate/provisioning profile pair, you are in the production environment. It is a good idea to create a Distribution release configuration in Xcode to help you further differentiate the environments.

Although an SSL certificate is not put into a provisioning profile, the <aps-environment> is added to the profile because of the association of the certificate and a particular application ID. As a result this entitlement is built into the application, which enables it to receive push notifications.

Provisioning Procedures

In the iOS Developer Program, each member on a development team has one of three roles: team agent, team admin, and team member. The roles differ in relation to iPhone development certificates and provisioning profiles. The team agent is the only person on the team who can create Development (Sandbox) SSL certificates and Distribution (Production) SSL certificates. The team admin and the team agent can both create both Development and Distribution provisioning profiles. Team members may only download and install certificates and provisioning profiles. The procedures in the following sections make reference to these roles.

Note: The iPhone Provisioning Portal. makes available to all iOS Developer Program members theProgram Portal User Guide and a series of videos that explain all aspects of certificate creation and provisioning. The following sections focus on APNs-specific aspects of the process and summarize other aspects. To access the portal, iOS Developer Program members should go to the iOS Dev Center (http://developer.apple.com/devcenter/ios), log in, and click the Program Portal button.

 

Creating the SSL Certificate and Keys

In the program portal of the iOS Dev Center, the team agent selects the application IDs for APNs. He also completes the following steps to create the SSL certificate:

  1. Click App IDs in the sidebar on the left side of the window.

    The next page displays your valid application IDs. An application ID consists of an application’s bundle ID prefixed with a ten-character code generated by Apple. The team admin must enter the bundle ID. For a certificate, it must incorporate a specific bundle ID; you cannot use a “wildcard” application ID.

  2. Locate the application ID for the sandbox SSL certificate (and that is associated with the Development provisioning profile) and click Configure.

    You must see “Available” under the Apple Push Notification Service column to configure a certificate for this application ID.

  3. In the Configure App ID page, check the Enable Push Notification Services box and click the Configure button.

    Clicking this button launches an APNs Assistant, which guides you through the next series of steps.

  4. The first step requires that you launch the Keychain Access application and generate a Certificate Signing Request (CSR).

    Follow the instructions presented in the assistant. When you are finished generating a CSR, click Continue in Keychain Access to return to the APNs Assistant.

    When you create a CSR, Keychain Access generates a private and a public cryptographic key pair. The private key is put into your Login keychain by default. The public key is included in the CSR sent to the provisioning authority. When the provisioning authority sends the certificate back to you, one of the items in that certificate is the public key.

  5. In the Submit Certificate Signing Request pane, click Choose File. Navigate to the CSR file you created in the previous step and select it.

  6. Click the Generate button.

    While displaying the Generate Your Certificate pane, the Assistant configures and generates your Client SSL Certificate. If it succeeds, it displays the message “Your APNs Certificate has been generated.” Click Continue to proceed to the next step.

  7. In the next pane, click the Download Now button to download the certificate file to your download location. Navigate to that location and double-click the certificate file (which has an extension of cer) to install it in your keychain. When you are finished, click Done in the APNs Assistant.

    Double-clicking the file launches Keychain Access. Make sure you install the certificate in your login keychain on the computer you are using for provider development. In Keychain Access, ensure that your certificate user ID matches your application’s bundle ID. The APNs SSL certificate should be installed on your notification server.

When you finish these steps you are returned to the Configure App ID page of the iOS Dev Center portal. The certificate should be badged with a green circle and the label “Enabled”.

To create a certificate for the production environment, repeat the same procedure but choose the application ID for the production certificate.

Creating and Installing the Provisioning Profile

The Team Admin or Team Agent must next create the provisioning profile (Development or Distribution) used in the server side of remote-notification development. The provisioning profile is a collection of assets that associates developers of an application and their devices with an authorized development team and enables those devices to be used for testing. The profile contains certificates, device identifiers, the application’s bundle ID, and all entitlements, including <aps-environment>. All team members must install the provisioning profile on the devices on which they will run and test application code. Refer to theProgram Portal User Guide for the details of provisioning-profile creation.

To download and install the provisioning profile, team members should complete the following steps:

  1. Go to the Provisioning page in the program portal.

  2. Create a new provisioning profile that contains the App ID you registered for APNs.

  3. Modify any existing profile before you download the new one.

    You have to modify the profile in some minor way (for example, toggle an option) for the portal to generate a new provisioning profile. If the profile isn't so “dirtied,” you're given the original profile without the push entitlements.

  4. From the download location, drag the profile file (which has an extension of mobileprovision) onto the Xcode or iTunes application icons.

    Alternatively, you can move the profile file to ~/Library/MobileDevice/Provisioning Profiles. Create the directory if it does not exist.

  5. Verify that the entitlements in the provisioning-profile file are correct. To do this, open the .mobileprovision file in a text editor. The contents of the file are structured in XML. In the Entitlements dictionary locate the aps-environment key. For a development provisioning profile, the string value of this key should be development; for a distribution provisioning profile, the string value should beproduction.

  6. In the Xcode Organizer window, go the Provisioning Profiles section and install the profile on your device.

When you build the project, the binary is now signed by the certificate using the private key.

Installing the SSL Certificate and Key on the Server

You should install the SSL distribution certificate and private cryptographic key you obtained earlier on the server computer on which the provider code runs and from which it connects with the sandbox or production versions of APNs. To do so, complete the following steps:

  1. Open Keychain Access utility and click the My Certificates category in the left pane.

  2. Find the certificate you want to install and open its disclosure triangle.

    When you open the disclosure triangle, you'll see both a certificate and a private key.

  3. Select both the certificate and key, select Export Items from the File menu, and export them as a Personal Information Exchange (.p12) file.

  4. 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:

    1. In KeyChain Access, select the certificate and choose Export Items from the File menu. Choose the Personal Information Exchange (.p12) option, select a save location, and click Save.

    2. Launch the Terminal application and enter the following command after the prompt:

      openssl pkcs12 -in CertificateName.p12 -out CertificateName.pem -nodes

  5. Copy the .pem certificate to the new computer and install it in the appropriate place.

 

这篇关于apns备忘的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/415167

相关文章

Vi操作备忘

Vi操作备忘       Vi是Linux系统里面的一个屏幕编辑程序,在终端中使用。Vi对文件的修改是在文件的副本上进行的,除非编辑顺利,并保存之后才会用修改的副本替代原始文件,否则,修改的内容会全部放弃,重新回到原始文件。       Vi是一个优秀的代码工程师所必备的技能。故在此简述vi备忘。 1、可以在终端上,输入以下形式的命令行,进入vi编辑程序:       vi filename

Java100:javaSE备忘

char c='\u4e00' //汉字开始 char c='\u9fa5'//汉字结束 java 正则   正则表达式:  java.util.regex.Pattern     [] 匹配的一个字符     [^a] 一个非a的字符     [^abcd]一个非a,b,c,d的字符     [A-Z] 一个 A-Z 的字符     [a-z] 一个a-z的字符     [0-9] 一个0

java99:java 基础备忘

程序 = 算法+数据结构     算法:解决问题的步骤      数据结构:将数据按照某种结构来保存     好的数据结构 => 好的算法 char 可以存储一个中文字符(1个char是两个字节,一个中文字符也是两个字节) && 短路 常用 三目运算 int a = 1; int b = 2; int c = a > b ? c =0101 : c = 1010 boolean ? 1:2

Docker在CentOS上硬盘使用被占满的问题(备忘)

摘录至 https://github.com/yeasy/docker_practice/blob/master/image/rm.md#centosrhel-的用户需要注意的事项 在CentOS上,遇到过这个问题。没有细究过。正好看到,记录之 内容如下: CentOS/RHEL 的用户需要注意的事项 在 Ubuntu/Debian 上有 UnionFS 可以使用,如 aufs 或者 o

RocketMQ安装、部署(备忘)

RocketMQ 这段时间接触了不少 MQ 产品,印象最为深刻的,当属 RocketMQ 个人认为其架构设计的十分合理 官方地址: https://github.com/apache/rocketmq 使用下来,最开始的安装、部署,遇到不少问题,因此特地备忘下 主要问题均来至 JDK 版本比官方的新 安装相关 官方文档: https://rocketmq.apache.org/doc

golang 编译期设置变量值(备忘)

说明 本文演示给程序打上时间戳,并输出 目录结构 fananchong@localhost:~/test$ tree.├── go.mod├── g.sh├── main.go└── version└── version.go main.go package mainimport ("fmt""os""test/version")func main() {args := o

VSCode 中画 UML 图(备忘)

vscode-drawio vscode-drawio 是一款 vscode 插件,支持在 vscode 中画流程图、思维导图、 UML 图 github 地址: https://github.com/hediet/vscode-drawio 安装 在 vscode 插件窗口内,搜索 vscode-drawio ,安装即可 使用 在 vscode 中打开 .drawio 扩展名的文件,

IOS本地,APNS远程推送(具体过程)

IOS本地,APNS远程推送(具体过程) 本地推送 添加本地推送 [cpp]  view plain copy ///本地添加  -(void)addLocalPushNotification:(UIButton*)sender;  {                  NSLog(@"%s",__FUNCTION__);      UILocalNotificati

YOLO环境搭建备忘教程

注:该文本是在完成anaconda、pycharm后进行的过程,请注意! 1、conda下创建一个新环境: conda create -n 环境名称 python=版本号   #注意各类代码的具体Python版本号 conda create -n Pysidey6 python==3.8.1   #注意:3.8.0运行PySide6会报错,运行不起来 2、删除环境: conda

space-vim安装及快捷键备忘

用了这么长时间的space-vim,逐渐衍生出更加复杂的需求。故这里做一个备忘: 1、标题在没有网络(不能连外网,可以连局域网)的机器上,安装space-vim 首先在另一台机器上,完全配置好space-vim打包以下几个目录的文件(我配置了file-manager,用于 【在~/.space-vim里面,配置let g:spacevim_layers += ['file-manager']】