With the XtremePush module for PhoneGap you can add XtremePush to both iOS and Android apps built with PhoneGap.
XtremePush supports push notifications for iOS devices via Apples's Push Notification Service (APNs for short). And push notifications for Android devices via Google’s GCM (Google Cloud Messaging for Android) service. This page contains PhoneGap specific instructions but It is also recommended you read the native documentation for these platforms. This includes the quick start guides:
These docs deal with important topics like:
- Connecting your app to the platform
- Setting up APNs Certificates for iOS
- GCM setup for Android
- Sending your first push notification
Both platforms also have documentation on setting up advanced features when integrating XtremePush into your Application:
Advanced features include: tagging of events, custom push notification handling and location services.
First, download the current XtremePush PhoneGap SDK here. Inside of the ZIP you will find the following directories:
- Example_Apps/ : This folder contains a sample app for each OS supported. The apps are in a folder named after the OS they are related to, for example the iOS example app is in the ios/ folder.
- www/: This folder contains the javascript part of the plugin. OS specific portion of the plugin in a folder named after that OS i.e. src/iOS/ or src/Android/.
Full integration guides are given for iOS and Android below.
- Navigate to you iOS PhoneGap project in platforms/ios directory.
- Download the XtremePush iOS library here and add it to your iOS project following these instructions
- Navigate to your application directory, and type command: cordova plugin add https://github.com/xtremepush/XtremePush_Phonegap
XtremePush has two methods for tagging activity in your app one for tagging page impressions and one for tagging any other activity.
To tag page impression add the following method where your page loads:
// Send impression to server to track page impressions
XTremePush.hitImpression(successCallback, failCallback, "your_impression_name");
To tag any other events send a tag to server using the following method:
// E.g. you might want to tag a button press
XTremePush.hitTag(successCallback, failCallback, "your_tag_name");
-
When you have downloaded the latest plugin version (here) it comes with example apps.
-
Extract the archive, it contains the folder XtremePush_phonegap/ and the iOS example app can be found in Example_Apps/ios/
-
To experiment with this sample app open it in Xcode. It is a simple app with all the XtremePush library methods mapped to a series of buttons:
- You can see how the plugin has been configured in the test app in key locations such as: the plugin folders, app delegate, cordova_plugins.js, config.xml, index.js and index.html (see image below).
- Add XtremePush Android Library to your Project. Please follow instructions.
- Navigate to your application directory, and type command: cordova plugin add https://github.com/xtremepush/XtremePush_Phonegap
-
When you have downloaded the latest plugin version (here it comes with example apps.
-
Extract the archive, it contains the folder XtremePush_phonegap/ and the Android example app can be found in Example_Apps/android/
-
To experiment with this sample app open it in your IDE. It is a simple app with all the XtremePush library methods mapped to a series of buttons:
- You can see how the plugin has been configured in the test app in key locations such as: the src/ folder, assets/www/ folder or res/xml/config.xml.