-->

how to make my server support APNs?

2020-07-26 02:51发布

问题:

i read in some stackOverflow post that The host would need to have port 2195 open and support push notifications under apns.how do i make my server to support apns.

what does this line means in Push Notification guide

To establish a trusted provider identity, we should present this certificate to APNs at connection time using peer-to-peer authentication.

do i need to make a connection to APns through my native app? someone please explain this

回答1:

Pretty much any server that doesn't have restriction on what sockets you can open is ready to be an APNS provider. In your project code, you can just open a socket to Apple servers (or use a library).

My understanding that Google App Engine and basically any traditional shared web hosting block any port other than 80, so you cannot use them. However, you can look into Urban Airship that provides a RESTful API that basically use from any service. It might get pricy though.



回答2:

In short you need to establish an SSL connection, and then send the payload in the pre-defined binary format.

alt text http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Art/aps_provider_binary.jpg

See this guide for more details.



回答3:

I use appengine, so I solved this by renting a super cheap server in hetzner.de. It basically serves as proxy to my appengine app and uses this library: https://github.com/notnoop/java-apns

that library has a one line way to send the message, using the certificate.



回答4:

Google just opened up the ability to do Socket stuff on AppEngine, so I created a sample project that you can use to send push notifications using GCM and APNS in python. Feel free to use any of it that you like.

I've also included a sample iOS project and Android project that hook up nicely with the app engine solution.

https://github.com/GarettRogers/appengine-apns-gcm

** Full Disclosure ** this is my project, and I'm in no way trying to promote it because it's mine... it's simply the only available project that solves your problem at the moment. If you find anything that does a better job, please leave a comment.



回答5:

You may check out java-apns-gae.

It's an open-source Java APNS library that was specifically designed to work (and be used) on Google App Engine.

https://github.com/ZsoltSafrany/java-apns-gae