An app must register with Apple Push Notification service (APNs) to receive remote notifications sent by the app’s push provider. In iOS 8 and later, registration has four stages:
- Register the notification types your app supports using
registerUserNotificationSettings:
. - Register to receive push notifications via APNs by calling your app’s
registerForRemoteNotifications
method. - Store the device token returned to the app delegate by the server for a successful registration, or handle registration failure gracefully.
- Forward the device token to the app’s push provider.
Need private key (*.p12
or *.pem
), key passphrase, deviceToken that get from client side everytime client connected to APNs.
Generate *.pem
from *.p12
(exported from keychain, selected cert & private key, export 2 items):
$ openssl pkcs12 -in private_key.p12 -out private_key.pem -nodes -clcerts
Server send notifications to gateway below:
- Development:
gateway.sandbox.push.apple.com
, outbound TCP port2195
- Production:
gateway.push.apple.com
, outbound TCP port2195
(more cmd tools: http://nomad-cli.com)
Dev:
$ apn push "<xxxxxxxx ... xxxxxxxx>" -c ~/private_key_of_apns_for_development.pem -e development -m "Hello"
Production:
$ apn push "<xxxxxxxx ... xxxxxxxx>" -c ~/private_key_of_apns_for_distribution.pem -e production -m "Hello"
- https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ProvisioningDevelopment.html
- https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW1
- http://stackoverflow.com/questions/21237445/send-ios-push-notification-from-php
Others that might helps:
- https://developer.apple.com/library/ios/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/AboutEntitlements.html
- https://developer.apple.com/library/ios/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/EnablingLocalAndPushNotifications.html#//apple_ref/doc/uid/TP40011195-CH3-SW1
- https://developer.apple.com/library/ios/technotes/tn2265/_index.html