diff --git a/readme.md b/readme.md index 9597c08..b1df299 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -Push Notification Sample App +Push Notification Sample App: ============================ A sample mobile application built with [Ionic](http://ionicframework.com) and [ngCordova](http://ngcordova.com/) to demonstrate how to register for and receive push notifications on iOS and Android. Once the device registration token is received, it is sent to a locally running node service where it will be stored for @@ -8,16 +8,16 @@ The setup to use node-pushserver is discussed more below but see the npm site fo #### ** See [related blog post](http://devgirl.org/2014/12/16/push-notifications-sample-app-with-ionic-and-ngcordova/) for more details! -### Push Notification Sample on iOS +### Push Notification Sample on iOS: ![](screenshots-blog/IMG_0009.jpg) ![](screenshots-blog/IMG_0012.jpg) ![](screenshots-blog/ios-swipe.png) ![](screenshots-blog/ios-app.png) -### Push Notification Sample on Android Nexus 7 +### Push Notification Sample on Android Nexus 7: ![](screenshots-blog/android-statusbar-pull.png) ![](android-foreground.png) ![](screenshots-blog/android-app.png) -### ** PRE-REQUISITES +### ** PRE-REQUISITES : You must install the following plugins for this app to work properly: @@ -40,13 +40,13 @@ You must install the following plugins for this app to work properly: -## Sending Push Notifications to your App +## Sending Push Notifications to your App: A couple options are included for sending push notifications to this application. You can use node-pushserver to store multiple device tokens from different platforms and send in bulk, or if you just want to test sending one simple message, there are two simple node services included to do that as well (node-apn and node-gcm). -### Send to Multiple Devices and Store Tokens (better approach) +### Send to Multiple Devices and Store Tokens (better approach): ####node-pushserver Check out [node-pushserver](https://www.npmjs.org/package/node-pushserver) to manage push notifications and device tokens with [mongodb](www.mongodb.org) database. This sample includes a subscribe.js file sample node/express service which can be used to subscribe a user for push notifications from the app. You can then send push notifications @@ -70,7 +70,7 @@ setup. If you're running your node-pushserver instance from localhost, you may h $http.post('http://192.168.1.5:8000/subscribe', JSON.stringify(user) -### Sending to *One Device* Manually (quick testing) +### Sending to *One Device* Manually (quick testing): *The app is currently setup to receive push notifications from this approach as well. You just need to update the sendMsg.js or sendGCM.js files to use your device tokens and certificates as needed.* @@ -139,7 +139,7 @@ you specific in controllers.js. [{"badge":"0","sound":"soundName","alert":"Jennifer L liked your photo","foreground":"0"}] -**Android Sample Message Payload** +**Android Sample Message Payload**: [{"message":"Tori432 commented on your photo: Awesome!","payload":{"message":"Tori432 commented on your photo: Awesome!"},"collapse_key":"optional","from":"824841663931","foreground":true,"event":"message"}]" ###Unregistering - When a user deletes/uninstalls your app @@ -154,14 +154,14 @@ In the sample app you will see that the local `unregister` method is simply remo So how do you determine when to remove a device token from your own 3rd party server so you don't have unnecessary overhead? The two services handle it differently, below are some details and further links to check out: -**GCM Handling** +**GCM Handling**: Google notes that 'When users uninstall an application, it is not automatically unregistered on GCM. It is only unregistered when the GCM server tries to send a message to the device and the device answers that the application is uninstalled or it does not have a broadcast receiver configured to receive com.google.android.c2dm.intent.RECEIVE intents. At that point, your server should mark the device as unregistered (the server will receive a NotRegistered error).' See [this link](http://developer.android.com/google/gcm/adv.html) for advanced concepts and other useful information surrounding this. -**Apple's Feedback Service** +**Apple's Feedback Service**: APNs provides a useful [Feedback Service](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW3) that can be queried to find any device tokens that are no longer valid, for instance if the user deleted your app from their device. Apple recommends you query the service once per day to find any invalid tokens and remove them from your own database to reduce unnecessary message overhead and improve overall system performance.