跳转至

【IM pushes Apple software device installation】

【imessage Apple software device installation】APP can always obtain DeviceToken

You'll see a complete output that lets you understand what OpenSSL is doing in the background. If the connection is successful, you can type some characters. When you press Enter, the service will disconnect. If there is a problem establishing the connection, OpenSSL will give you an error message, but you have to scroll up the LOG to find it.

The client is easy to make, just apply for a certificate, copy the code, and it's done.

On the server side, if it is PHP, it must use the .pem certificate. If it is Java, it must use the .p12 certificate. (You may also need to double-click the certificate to install it!)

The json package sent by the server is limited in size, with a maximum of 256 bytes, including a custom dictionary set.

You can add "\n" to the alert string in aps for line break.

In addition to alert, badge, and sound, the values in the json package can still be customized.

Additional custom values:

$payload['aps'] = array('alert' => 'This is the alert text', 'badge' => 1, 'sound' => 'default');

$payload['server'] = array('serverId' => $serverId, 'name' => $name);

\(output = json_encode(\)payload);

When the user presses "View", the custom server value will be passed to the program in the device. The JSON values are as follows:

{

"aps" :

{ "alert" :

{

"action-loc-key" : "performance" ,

"body" : "This is the alert text"

},

"badge" : 1,

"sound" : "default" },

"server" : { "serverId" : 1, "name" : "Server name")

}

The 256-byte limit applies to all payloads, including custom dictionary sets.

Native interface

In Server Density, once a reminder is generated, a payload will be created and inserted into the queue. Therefore, we can send multiple payloads at the same time if necessary.

Apple recommends this method because if you frequently connect and disconnect while sending each payload, APNS may block your IP.

As Apple describes:

The native interface uses native sockets, has binary content, adopts data flow technology, and does not generate feedback.

Expert’s summary:

APPLE push care service tutorial PART-1

APPLE push notification service tutorial PART-2

APPLE push notification service tutorial PART-3

Before IOS7, Apple generated the same DeviceToken for multiple apps on a device.

In IOS7 and later, Apple generates different DeviceTokens for multiple apps on a device.

This new change causes a mapping table of old and new tokens to be created on APNS. If you don't stop using the old token, that's fine. However, once the server uses the new DeviceToken, the records in the mapping table will be deleted. , which means that the old DeviceToken cannot be used and must fail to be sent.

To be verified: In IOS5 and IOS6, the APP can always obtain the DeviceToken. In other systems, if the user refuses or turns off the push, the DeviceToken cannot be obtained and a failure callback is performed.

Details are required to generate a certificate:

Apple developer accounts are divided into several roles

Agent: Agent, with the highest authority, can access iTunes Connect.

Admin: Administrator, has the authority to manage members, protect device lists, and maintain APPID and certificate lists.

Member: Ordinary member, read-only permission. {

"channels":

[

 "/Users/mac/Library/Application Support/Sublime Text 3/channel_v3.json"

]

} Note: After testing on September 11, 2013, I found that the certificate generation mechanism was updated when the Apple website was offline some time ago. Previously, manipulating the keychain generated a CSR file that could be used all the time. However, now whenever you want to generate a certificate, you need to regenerate a CSR file in advance. Otherwise, the certificates you generate will be invalid. Fake certificates, especially PUSH certificates, cannot be used by the server at all. APNS establishes a connection. This weird problem is super difficult to track! I hope everyone who reads this paragraph can avoid taking detours, no thanks!

I also encountered various problems while using PushMeBaby. First of all, although the .cer public key certificate has been used in the project, there must be a certificate with a private key in the local keychain, otherwise the connection cannot be successfully established. And it should be noted that the certificate is best placed in the "Login" group, otherwise the program will not be able to find the private key. Secondly, in the original project, there will be an infinite loop when scanningString, so the code needs to be modified as follows: