I have a messaging app built using the Ionic framework (on cordova). I plan on building this for android, and I'd like a way to send and recieve push notifications from the app using javascript/ionic.
Are there any good tutorials out there on how to go about setting something like this up?
The latest phonegap-plugin-push allows you to register and receive push notifications in your ionic apps. It is maintained at the following Github link:
https://github.com/phonegap/phonegap-plugin-push
Installation:
Where the
XXXXXXX
inSENDER_ID="XXXXXXX"
maps to the project number in the Google Developer Console. To find the project number login to the Google Developer Console, select your project and click the menu item in the screen shot below to display your project number.If you are not creating an Android application you can put in anything for this value.
After installation you can now add code below to your main javascript file to register and receive push notifications:
ngCordova has a plugin that supports Push Notifications. It has sample code for iOS and Android. Check it out: http://ngcordova.com/docs/plugins/pushNotifications/
Use this plugin https://github.com/phonegap-build/PushPlugin.
Android devices receive push notifications through the Google Cloud Messaging (GCM) service, whereas iOS devices receive them from the Apple Push Notifications (APN) Service.
The way the notifications are received (by sound, alert etc) is a combination of the options set in the application code upon registration as well as the user’s device settings for notifications.
If you want more specific follow below tutorial :
http://devgirl.org/2013/07/17/tutorial-implement-push-notifications-in-your-phonegap-application/
There is example application made available by Holly Schinsky. The core of it is the usage of PushPlugin which is the standard method to handle push notifications on Cordova. There is quite extensive tutorial provided for this subject on their documentation on that GitHub repository. The main method is
pushNotification.register
which registers the device to listen for push notifications.If you instead need to trigger notification locally, you might want to take a look at Local notification plugin instead. With it you can add notifications to be shown on the device without the need for external services to send the push notifications.