Get Started
In this tutorial, you will lean how Push Notifications work and how to send Push Notifications to iPhone using an open source library - JavaAPNS.Apple Push Service Overview
1. An app registers to iOS to enable Push notification; iOS sends device`s UDID to APNS.
2. The app receives a “device token” from APNS. You can think of
the device token as the address that push notifications will be sent to.
3. The app sends the device token to your server.
4. When something of interest to your app happens, the
server sends a push notification to the Apple Push Notification Service with
device token id.
5. APNS sends the push notification to the user’s
device.
Enable Provisioning Profiles and Certificates
To enable push notifications in your app, it needs to
be signed with a provisioning profile that is configured for push. In addition,
your server needs to sign its communications to APNS with an SSL certificate.
There are also two types of push server certificates:
- Development. If your app is running in Debug mode
and is signed with the Development provisioning profile (Code Signing Identity
is “iPhone Developer”), then your server must be using the Development certificate.
- Production. Apps that are distributed as Ad Hoc or
on the App Store (when Code Signing Identify is “iPhone Distribution”) must
talk to a server that uses the Production certificate. If there is a mismatch
between these, push notifications cannot be delivered to your app.
Generating the Certificate Signing Request (CSR)
The first thing you need is your Push certificates.
These identify you when communicating with APNS over SSL.
Generating the Apple Push Notification SSL certificate
on Mac:
Enter your email address here. I’ve heard people
recommended you use the same email address that you used to sign up for the iOS
Developer Program, but it seems to accept any email address just fine.
Enter “PushChat” for Common Name. You can type anything
you want here, but choose something descriptive. This allows us to easily find
the private key later.
Check Saved to disk and click Continue. Save the file
as “PushChat.certSigningRequest”.
Generating the private key
If you go to the Keys section of Keychain Access, you
will see that a new private key has appeared in your keychain. Right click it
and choose Export.
Save the private key as “PushChatCert.p12”
and enter a passphrase.
4.
Making the App ID and SSL certificate
Log in to the iOS Provisioning Portal.
First, we are going to make a new App ID. Each push
app needs its own unique ID because push notifications are sent to a specific
application. (You cannot use a wildcard ID.)
Filled in the fields as follows:
Description: PushChat
Bundle Seed ID: Generate New (this is the default
option)
Bundle Identifier: com.hollance.PushChat
It is probably best if you choose your own Bundle
Identifier here – com.companyName.PushChat – instead of using mine. You will
need to set this same bundle ID in your Xcode project.
This certificate is linked with your App ID. Your
server can only send push notifications to that particular app, not to any
other apps.
After you have made the App ID, it shows up like this
in the list:
Click on the Configure link to open the Configure App
ID screen.
choose Certificate Signing Request file, “PushChat.certSigningRequest”
for the Development Push SSL Certificate.
Download SSL certificate.
Click Done to close the assistant and return to the
Configure App ID screen.
As you can see, we have a valid certificate and push
is now available for development. The development certificate is only valid for
3 months. When you are ready to release your app, repeat this process for the
production certificate. The steps are the same.
Note: The production certificate remains valid for a
year, but you want to renew it before the year is over to ensure there is no
downtime for your app.
Until now, we have generated three files:
1. Push.certSigningRequest
2. PushChatCert.p12
3. aps_developer.cer
No comments:
Post a Comment