APNS、GCM

APNS

APNs (full English name: Apple Push Notification service), Chinese translation is: Apple Push Notification service. The technology is provided by Apple's APNs service. (Apple's servers)



Notifications are data consisting of two main parts: a device token and a short message with a payload.


How it works:
//First, APNs will perform physical connection authentication on the user, and device token authentication (in short, Apple's server checks the certificate in the device to determine that it is an Apple device)

//Then, the server's information is received And save it in APNs, APNs find the IOS device from the list registered in it
// (device can be iPhone, iPad, iPod Touch, version is iOS3.0 and above) and send the information to the device;

//Finally, The device receives the data information to the corresponding APP, and pops up the Push information according to the settings.

Process:
//The first stage: The application packages the message to be sent and the identity of the destination iPhone and sends it to APNS.
//Second stage: APNS searches for the iPhone with the corresponding identifier in its own iPhone list that has registered the Push service, and sends the message to the iPhone.
//The third stage: The iPhone transmits the message to the corresponding application, and pops up a Push notification according to the settings.


//1. The first is the application registration message push.
//Initiate the request, the system has recorded that the application has registered with the push service, and is ready to receive the push information and push the information to that application
later. //2, IOS and APNS Server need deviceToken. The application accepts deviceToken.
//IOS system obtains a deviceToken from APNS Server (server), APNS Server will record the association between this device and this deviceToken,
//(a device may correspond to multiple deviceTokens (multiple applications (APP))) and then push the latter information to Whoever prepares, the deviceToken applied for by different applications may
// may be different, so that you can prepare for different applications
later.// 3. The application sends the deviceToken to the PUSH server program.
//The application gets the deviceToken and sends it to the business server (the server that decides what information to push), the business server records this
//deviceToken, and pushes information to those specified devices for subsequent events.
//4. The server program sends APNS The service sends a message.
//When some event occurs in the business server, send the pushed information and deviceToken to APNS Server,
//5. APNS service sends the message to the iPhone application
//APNS Server receives the information sent by the business server, and records it from the Find the device in the corresponding relationship between the deviceToken and the device, APNS Server and push it to the device,
//The device receives the push information, and the IOS system obtains the application software (APP) from it and registers the push service, and then sends the information to the corresponding application. Software (APP),
//The application software (APP) applies to the system to pop up an information box, and the information can be seen on the device


Information composition:
//The data that the provider needs to push consists of two parts:
//Device Token
/ /Payload

//Token is easy to understand, it is the authentication information that needs to be carried when verifying the double identity;
//The Payload is the main information that needs to be pushed, which also includes:
//Information displayed to the user
//icon displayed to the App Logo (commonly known as the little red dot) quantity information
// sound on the device side
// of course only 1 of them is required.




Features:
//It is recommended to use APNs service, which is stable and convenient. The fly in the ointment is that there is no receipt and statistics of push arrival, which is inconvenient for product operation. If there is a need in this regard, you can use a third-party push service such as a push to solve the





link :
//Information provider (provider)-->APNS-->IPohne (device)-->Application (APP)


//Provider is Refers to the Push server of an iPhone software
//APNS is the abbreviation of Apple Push Notification Service, which is Apple's server.



Whether it is iPhone client and APNS, or Provider and APNS, they all need to be connected through a certificate.


After the user device is connected to the Internet, it will keep track of The connection to the Apple APNs server, all pushes are sent to the user device through this connection, and the system will pop up a reminder according to the settings (it is a long connection) . The implementation principle of



GCM (Google Cloud Push)



is similar to that of





APNS . There are two communication methods between the server and GCM:
1.Http protocol
2.Xmpp protocol





registerId: The device relationship code applied by the client to GCM
1. Register the user and get the Project Number and APP key. The Project Number is the SENDER_ID we will use in the later programming.



//==================================================== =============================================
1.Sender ID //Project ID , request Registration Token (APP) from the GCM project and send information to it (application server)
2.API Key //A password to be used to access GCM
3.Registration Token //A and device obtained by APP from GCM Binding ID



//============================================== =================================================
Workflow:
/ /1. Create a Google API project, select Other>Create a new project, Google will automatically generate a project Id. This is your project ID,
// Please note that this Id Project ID: 382396212935 is used in many places below.
/ / 1.1 Get a Server API key //
2. APP obtains Registration Token from GCM's project Id by calling the interface to the system, and the system registers the relationship between the Registration Token and the APP.
// At the same time, GCM will record the Registration Token Token is associated with that device (possibly a socket)
//3. The Registration Token obtained by the APP submitted to the application server and the user ID (for the application server to bind the relationship)
//4. The application server saves the association between the Registration Token and the user ID
//5. When the message is to be pushed , send the request containing Sender ID, API Key, Registration Token, and message content to GCM
//6. After GCM receives the request, it gets the device (possibly socket) from the table in which Registration Token is associated with that device (possibly socket). is socket), and
send corresponding messages through this // (possibly socket) long connection.
//7. The APP system can receive this message. From the system (the relationship table between Registration Token and APP), we can know that this message is associated with which APP.
// The system sends the corresponding message to the APP, and the APP receives it. to the message




Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326723406&siteId=291194637
Recommended