- 浏览: 2539721 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
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 589ionic UI(5)UI and Backend 1 Pr ... -
Stanford Cource(2)Demo App Caculator
2014-06-24 01:29 897Stanford Cource(2)Demo App Ca ... -
Mono on MAC
2014-06-04 03:27 973Mono on MACJust fine the tool f ... -
IOS7 App Development Essentials(4)IPhone5, IPhone5s, IPhone5c
2014-04-11 03:59 980IOS7 App Development Essentia ... -
IOS7 App Development Essentials(3)NSUserDefaults
2014-04-11 02:58 1005IOS7 App Development Essentia ... -
IPhone and Location(2)Documents Region Monitoring and Region Sample
2013-10-18 05:10 1725IPhone and Location(2)Documents ... -
IPhone and Location(1)Documents User Location
2013-10-18 03:50 1303IPhone and Location(1)Documents ... -
Learn Objective C(6)Programming with Objective-C - Working with Blocks and Deali
2013-10-18 00:02 924Learn Objective C(6)Programming ... -
Learn Objective C(5)Programming with Objective-C - Working with Protocols and Va
2013-10-17 23:47 996Learn Objective C(5)Programming ... -
Learn Objective C(4)Programming with Objective-C - Encapsulating Data and Custom
2013-10-17 23:23 933Learn Objective C(4)Programming ... -
Learn Objective C(3)Programming with Objective-C - Defining Classes, Working wit
2013-10-17 23:09 1013Learn Objective C(3)Programmi ... -
Learn Objective C(2)Learn Objective-C in Day 6 - 4 ~ 6
2013-10-17 00:30 959Learn Objective C(2)Learn Obj ... -
Learn Object C(1) Learn Objective-C in Day 6 - 1 ~ 3
2013-10-17 00:22 1109Learn Object C(1) Learn Objec ... -
APNS(4)Recall the Process and Learn Java APNS
2013-04-18 02:48 3466APNS(4)Recall the Process and L ... -
Build the iOS Things with J2Objc
2013-04-12 03:25 2461Build the iOS Things with J2Obj ... -
APNS(3)Write the Easy Client App
2013-01-15 07:23 1691APNS(3)Write the Easy Client Ap ... -
Stanford Cource(1)MVC and Object-C
2012-12-14 14:04 1315Stanford Cource(1)MVC and Objec ... -
Some VI Tips
2012-11-15 04:48 1092Some VI Tips Today, I need to c ... -
MAC Mini Setup
2012-09-25 18:45 1325MAC Mini Setup I am dealing wit ... -
Android Talker(1)MAC Environment
2012-09-01 00:16 1920Android Talker(1)MAC Environmen ...
相关推荐
而Go-apns2项目就是针对这一服务的客户端库,它简化了与APNs服务器通信的过程。 首先,让我们了解一下Go语言。Go,也被称为Golang,是由Google开发的一种静态类型的、编译式的、并发的、垃圾回收的、面向对象的编程...
APNs(Apple Push Notification service)是苹果公司提供的推送服务,允许开发者将消息推送到用户的iOS设备上。本教程将重点讲解如何使用Java实现基于HTTP/2协议的APNS推送,并假设你已经对JDK 11及以上版本有一定的...
2. 创建`ApnsService`实例:通过`ApnsServiceBuilder`指定服务器地址和证书。 3. 构建`ApnsNotification`:设置通知的各种属性,如设备令牌、标题、正文等。 4. 发送通知:调用`ApnsService`的`push()`方法,传入...
开源项目“sideshow-apns2”是一个用Go语言编写的工具,用于实现Apple的新型HTTP/2推送通知服务(APNs)协议。这个项目旨在帮助开发者更高效、更可靠地向iOS、iPadOS以及macOS设备发送推送通知。在本文中,我们将...
【苹果APNS2推送DEMO】是针对Apple Push Notification service(APNs)第二版的一个示例项目,旨在帮助开发者理解和实现iOS与macOS应用的远程通知功能。APNs是苹果公司提供的服务,允许应用程序在后台接收来自服务器...
.NET APNS推送是一个基于.NET框架实现的用于向Apple Push Notification Service (APNS)发送推送通知的项目。APNS是苹果公司提供的服务,允许开发者通过云端将实时消息推送到iOS、iPadOS、watchOS以及macOS设备上的...
【C# APNS推送】 APNS(Apple Push Notification Service)是苹果公司提供的一个服务,用于向iOS、iPadOS、watchOS、tvOS等设备发送实时通知。开发者可以通过使用APNS来实现在应用未运行时向用户发送消息的功能,...
Java整合APNS推送服务是将Java应用程序与Apple Push Notification Service(APNS)相结合,以便能够向iOS和tvOS设备发送即时消息。APNS是苹果公司提供的一个服务,它允许开发者在用户不打开应用的情况下,向他们的...
APNSPHP是一个专门为苹果推送通知服务(Apple Push Notification service,简称APNs)设计的PHP库。这个库的主要目的是帮助PHP开发者方便地与苹果服务器进行通信,以便向iOS、macOS和watchOS设备发送推送通知。从...
apns4j 是 Apple Push Notification Service 的 Java 实现!Maven: <groupId>com.github.teaey</groupId> <artifactId>apns4j <version>1.0.1 示例代码:KeyStoreWraper keyStore = ...
2. **构建连接**:使用Java的SSL套接字库建立与APNs服务器的SSL/TLS连接。你需要导入之前下载的.pem文件,将其转换为KeyStore,然后设置KeyManagerFactory和SSLContext来建立安全连接。 3. **构建推送消息**:APNs推...
需要注意的是,APNs对推送消息的大小有限制,一般不超过2KB。 6. **错误处理**: APNs会在接收推送消息时返回一个反馈,如果设备Token无效或者推送失败,会返回相应的错误代码。服务端需要正确处理这些反馈,以便...
2. **创建连接**:使用`System.Net.Security.SslStream`类,你可以建立一个安全的SSL/TLS连接到APNS服务器。有两个不同的环境:生产环境和沙盒环境,对应不同的服务器地址。确保根据应用的状态(发布或测试)选择...
apns.jar包,用于apns推送,直接导入就可以使用了
2. **APNs的认证过程** 在使用APNs时,开发者需要获取两个密钥:一个用于生产环境,另一个用于开发环境。这些密钥存储在.p8格式的文件中,并通过苹果的证书管理工具生成。这些密钥与Apple Developer Account关联,...
**苹果推送通知服务(Apple Push Notification service,简称APNS)** APNS是苹果公司提供的一项服务,用于向iOS、iPadOS、watchOS、tvOS以及macOS设备推送通知。通过APNS,应用开发者可以在他们的应用不在前台运行...
阿里封装的APNS推送工具包 可以使用ios客户端的APNS推送功能
APNS(Apple Push Notification service)是苹果公司提供的一项服务,用于向iOS、iPadOS、watchOS、tvOS以及macOS设备发送远程通知。通过APNS,应用开发者可以在他们的应用程序不在前台运行时,仍然能够向用户发送...