views:

925

answers:

1

I want to use push notification in my app.i want to know that do i need to include certificate in my app to get device token or i just need to install certificate in key chain and implement only the methods which are described in PushNotificationGuide? actually I'm a bit confused about whether i integrate certificate in my app or not.I just want to know a step by step method for client side implementation. sorry for posting this question cause i know there are a lot posts on stack overflow.thanks all for your support.

+1  A: 

You should NOT integrate the certificate into your app. If you do that it will be possible for anyone to spoof your push server and send pushes to all of your users. The way push works is roughly:

  1. Your app gets a device token
  2. Your app send the device token to your server

At some point in the future you use that token to initiate a push connection in roughly the way shown in this image from Apple's documentation: APNS Diagram

  1. Your server (Provider) initiates an SSL connection to APNS using your cert to encrypt the connection and the device token to identify which device the push should go to.
  2. Apple pushes out the data in the request to the device that has that device token.

This is a decent blog post explaining how to build an app and server, and Apple has sample code showing how to get the device token here.

Louis Gerbarg