- 浏览: 2488443 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
APNS(2)Try to Finish the first Example
Brief Overview
1. An app enables push notifications.
2. The app receives a "device token".
3. The app sends the device token to your server
4. The server sends a push notification to the Apple Push Notification Service
5. APNS sends the push notification to the user's device.
After the user's device receives the push notification, it shows an alert, plays a sound and/or updates the app's icon.
Need for Push Notifications
An iPhone or iPad
An iOS Developer Program membership
A VPS(Virtual Private Server)
Anatomy of a Push Notification
{
"aps":
{
"alert": "Hello, world!",
"sound": "default"
}
}
{
"aps":
{
"alert":
{
"action-loc-key": "Open",
"body": "Hello, world!"
},
"badge": 2
}
}
Push Notification Gotchas
They are not reliable. There is no guarantee. Push notifications are fire-and-forget, there is no way to find out what the status of a notification is. APNS will try to deliver the last notification after the device is back online, but once it times out, the push notification will be lost forever.
Provisioning Profile and Certificates
We need an SSL certificate.
Generating the Certificate Signing Request(CSR)
Use 'Command' + 'Blank' to find the Keychain Access application on my MAC book.
'Certificate Assistant' and choose 'Request a Certificate from a Certificate Authority…'
Enter my email which I register on the iOS developer. And give a 'Easy iOS sample' for common name and select the 'Save to disk'.
Save the file on the desktop as easyiossample.certSigningRequest.
Select 'login' on the top and 'Keys' at the left bottom, we will see the private and public key we just created. Select the private key and export to desktop with name EasyiOSSampleKey.p12 and use a password to protect it.
Making the App ID and SSL certificate
Go to this URL
https://developer.apple.com/ios/manage/overview/index.action
'App IDs' ---> 'New App ID'
Description: EasyiOSExample
Bundle Seed ID:
Bundle Identifier:
click on "Configure"
check the Enable for Apple Push Notification service box and click on the 'Configure' button for the Development Push SSL Certificate.
continue to find the Certificate Signing Request(CSR). ----> Generate -----> Done
click Download to get the certificate. It is named aps_development.cer.
Making a PEM file
Till now, I have 3 files:
The CSR
The private key as a p12 file
The SSL certificate, pas_developer.cer
I will combine the certificate and the private key into a single file that uses the PEM format.
>openssl x509 -in aps_development.cer -inform der -out easyiossample_cert.pem
>openssl pkcs12 -nocerts -out easyiossample_key.pem -in EasyiOSSampleKey.p12
Enter Import Password:
MAC verified OK
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
First password is for open the private key. Other 2 passwords are creating the protection for PEM file.
Put the 2 PEM files together
>cat easyiossample_cert.pem easyiossample_key.pem > ck.pem
I verify the certificate and key like this>
>telnet gateway.sandbox.push.apple.com 2195
>openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert easyiossample_cert.pem -key easyiossample_key.pem
But I got this error, Error Message:
Verify return code: 20 (unable to get local issuer certificate)
I will find out if this is a problem and solve it later.
Making the Provisioning Profile
Select the 'Provisioning' Menu. -----> New Profile
Profile Name: EasyiOSSample Development
certificates:
App ID:
Devices:
Before do that, I need to 'Certificates' --- Upload my CSR.
Go to the 'Devices' and active my devices.
We are creating provisioning profile, because each push app needs to have its own profile that is connected to the proper App ID.
After finish that, we can download and get a file named Easy iOS Sample.mobileprovision.
All these accounts things are done, I will go on to write the sample client.
References:
http://w54653520.iteye.com/blog/1319595
http://code.google.com/p/javapns/
http://www.ibm.com/developerworks/cn/mobile/mo-ios-push/
http://hz-chenwenbiao-rr.iteye.com/blog/1604589
http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12
http://www.raywenderlich.com/3525/apple-push-notification-services-tutorial-part-2
http://www.raywenderlich.com/tutorials
Brief Overview
1. An app enables push notifications.
2. The app receives a "device token".
3. The app sends the device token to your server
4. The server sends a push notification to the Apple Push Notification Service
5. APNS sends the push notification to the user's device.
After the user's device receives the push notification, it shows an alert, plays a sound and/or updates the app's icon.
Need for Push Notifications
An iPhone or iPad
An iOS Developer Program membership
A VPS(Virtual Private Server)
Anatomy of a Push Notification
{
"aps":
{
"alert": "Hello, world!",
"sound": "default"
}
}
{
"aps":
{
"alert":
{
"action-loc-key": "Open",
"body": "Hello, world!"
},
"badge": 2
}
}
Push Notification Gotchas
They are not reliable. There is no guarantee. Push notifications are fire-and-forget, there is no way to find out what the status of a notification is. APNS will try to deliver the last notification after the device is back online, but once it times out, the push notification will be lost forever.
Provisioning Profile and Certificates
We need an SSL certificate.
Generating the Certificate Signing Request(CSR)
Use 'Command' + 'Blank' to find the Keychain Access application on my MAC book.
'Certificate Assistant' and choose 'Request a Certificate from a Certificate Authority…'
Enter my email which I register on the iOS developer. And give a 'Easy iOS sample' for common name and select the 'Save to disk'.
Save the file on the desktop as easyiossample.certSigningRequest.
Select 'login' on the top and 'Keys' at the left bottom, we will see the private and public key we just created. Select the private key and export to desktop with name EasyiOSSampleKey.p12 and use a password to protect it.
Making the App ID and SSL certificate
Go to this URL
https://developer.apple.com/ios/manage/overview/index.action
'App IDs' ---> 'New App ID'
Description: EasyiOSExample
Bundle Seed ID:
Bundle Identifier:
click on "Configure"
check the Enable for Apple Push Notification service box and click on the 'Configure' button for the Development Push SSL Certificate.
continue to find the Certificate Signing Request(CSR). ----> Generate -----> Done
click Download to get the certificate. It is named aps_development.cer.
Making a PEM file
Till now, I have 3 files:
The CSR
The private key as a p12 file
The SSL certificate, pas_developer.cer
I will combine the certificate and the private key into a single file that uses the PEM format.
>openssl x509 -in aps_development.cer -inform der -out easyiossample_cert.pem
>openssl pkcs12 -nocerts -out easyiossample_key.pem -in EasyiOSSampleKey.p12
Enter Import Password:
MAC verified OK
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
First password is for open the private key. Other 2 passwords are creating the protection for PEM file.
Put the 2 PEM files together
>cat easyiossample_cert.pem easyiossample_key.pem > ck.pem
I verify the certificate and key like this>
>telnet gateway.sandbox.push.apple.com 2195
>openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert easyiossample_cert.pem -key easyiossample_key.pem
But I got this error, Error Message:
Verify return code: 20 (unable to get local issuer certificate)
I will find out if this is a problem and solve it later.
Making the Provisioning Profile
Select the 'Provisioning' Menu. -----> New Profile
Profile Name: EasyiOSSample Development
certificates:
App ID:
Devices:
Before do that, I need to 'Certificates' --- Upload my CSR.
Go to the 'Devices' and active my devices.
We are creating provisioning profile, because each push app needs to have its own profile that is connected to the proper App ID.
After finish that, we can download and get a file named Easy iOS Sample.mobileprovision.
All these accounts things are done, I will go on to write the sample client.
References:
http://w54653520.iteye.com/blog/1319595
http://code.google.com/p/javapns/
http://www.ibm.com/developerworks/cn/mobile/mo-ios-push/
http://hz-chenwenbiao-rr.iteye.com/blog/1604589
http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12
http://www.raywenderlich.com/3525/apple-push-notification-services-tutorial-part-2
http://www.raywenderlich.com/tutorials
发表评论
-
ionic UI(5)UI and Backend
2016-12-02 03:22 564ionic UI(5)UI and Backend 1 Pr ... -
Stanford Cource(2)Demo App Caculator
2014-06-24 01:29 865Stanford Cource(2)Demo App Ca ... -
Mono on MAC
2014-06-04 03:27 947Mono on MACJust fine the tool f ... -
IOS7 App Development Essentials(4)IPhone5, IPhone5s, IPhone5c
2014-04-11 03:59 943IOS7 App Development Essentia ... -
IOS7 App Development Essentials(3)NSUserDefaults
2014-04-11 02:58 969IOS7 App Development Essentia ... -
IPhone and Location(2)Documents Region Monitoring and Region Sample
2013-10-18 05:10 1699IPhone and Location(2)Documents ... -
IPhone and Location(1)Documents User Location
2013-10-18 03:50 1278IPhone and Location(1)Documents ... -
Learn Objective C(6)Programming with Objective-C - Working with Blocks and Deali
2013-10-18 00:02 895Learn Objective C(6)Programming ... -
Learn Objective C(5)Programming with Objective-C - Working with Protocols and Va
2013-10-17 23:47 967Learn Objective C(5)Programming ... -
Learn Objective C(4)Programming with Objective-C - Encapsulating Data and Custom
2013-10-17 23:23 907Learn Objective C(4)Programming ... -
Learn Objective C(3)Programming with Objective-C - Defining Classes, Working wit
2013-10-17 23:09 992Learn Objective C(3)Programmi ... -
Learn Objective C(2)Learn Objective-C in Day 6 - 4 ~ 6
2013-10-17 00:30 926Learn Objective C(2)Learn Obj ... -
Learn Object C(1) Learn Objective-C in Day 6 - 1 ~ 3
2013-10-17 00:22 1076Learn Object C(1) Learn Objec ... -
APNS(4)Recall the Process and Learn Java APNS
2013-04-18 02:48 3430APNS(4)Recall the Process and L ... -
Build the iOS Things with J2Objc
2013-04-12 03:25 2434Build the iOS Things with J2Obj ... -
APNS(3)Write the Easy Client App
2013-01-15 07:23 1608APNS(3)Write the Easy Client Ap ... -
Stanford Cource(1)MVC and Object-C
2012-12-14 14:04 1267Stanford Cource(1)MVC and Objec ... -
Some VI Tips
2012-11-15 04:48 1062Some VI Tips Today, I need to c ... -
MAC Mini Setup
2012-09-25 18:45 1288MAC Mini Setup I am dealing wit ... -
Android Talker(1)MAC Environment
2012-09-01 00:16 1892Android Talker(1)MAC Environmen ...
相关推荐
开源项目-sger-go-apns2.zip,Go package for HTTP/2 Apple Push Notification Service.
开源项目-sideshow-apns2.zip,Push notifications from Go with Apple's new HTTP/2 APNS protocol
Java APNS推送消息 HTTP/2协议, 基于JDK 11及以上
part of APNSPHP
apns.jar包,用于apns推送,直接导入就可以使用了
该项目是.net下的一个APNS推送,服务器到APNS端的一个示例。
阿里封装的APNS推送工具包 可以使用ios客户端的APNS推送功能
tornado_apns, 在PyAPNS上,基于 Tornado的异步 APNS tornado_apns用于与苹果推送通知服务( APNs ) 进行 Tornado 异步编程的python 库示例用法import timefrom apns import APNs, Payloadfrom
1.APNS2 推送测试程序,支持自定义参数 3.openssl制作pem证书方法 2.nghttp2 交叉编译说明
APNS2 使用带有JSON Web令牌的新HTTP / 2协议连接到Apple的Push Notification Service的节点客户端。 创建客户 使用签名密钥创建一个APNS客户端: const { APNS } = require ( 'apns2' ) const client = new APNS...
java apns推送示例,基于http/2亲测有效
apns4j 是 Apple Push Notification Service 的 Java 实现!Maven: <groupId>com.github.teaey</groupId> <artifactId>apns4j <version>1.0.1 示例代码:KeyStoreWraper keyStore = ...
苹果最新技术apns推送!!C#代码!和数据库 VS2008+sql2008
苹果APNS推送,C#实现通过APNS向客户手机推送消息,Apple Push Notification Service
php实现的APNs服务端,大家自行下载。如果有疑问,可以参看我的博客
IOS APNS 官方开发文档 英文版本
自己用java实现苹果的apns推送,调用压缩包的text文件里面的方法即可
vapor-apns, 用于蒸汽的简单APNS库( Swift ) VaporAPNS VaporAPNS是一个简单但优雅的Swift 库,允许你使用 Linux & macOS 中的http/2 协议发送苹果推送通知。 软件支持基于新的基于令牌的认证机制,但是如果需要,
APNS 苹果推送服务 C#实现