Changes for README.md: 78 added lines, 11 removed lines.
Original line number
Diff line number
Diff line
# Cordova Push Notifications Plugin for Android and iOS
# Cordova Push Notifications Plugin for Android, iOS and WP8
---
@@ -39,13 +39,13 @@ This plugin is for use with [Cordova](http://incubator.apache.org/cordova/), and
1) copy the contents of **src/android/com/** to your project's **src/com/** folder.
copy the contents of **libs/** to your **libs/** folder.
copy **{android_sdk_path}/extras/android/support/v13/android-support-v13.jar** to your **libs/** folder.
The final hirearchy will likely look something like this;
The final hierarchy will likely look something like this:
{project_folder}
libs
gcm.jar
android-support-v13.jar
cordova-2.7.0.jar
cordova-3.4.0.jar
src
com
plugin
@@ -86,7 +86,9 @@ This plugin is for use with [Cordova](http://incubator.apache.org/cordova/), and
4) Modify your **res/xml/config.xml** to include the following line in order to tell Cordova to include this plugin and where it can be found: (See the Sample_config.xml file in the Example folder)
5) Add the **PushNotification.js** script to your assets/www folder (or javascripts folder, wherever you want really) and reference it in your main index.html file. This file's usage is described in the **Plugin API** section below.
@@ -109,7 +111,9 @@ PushPlugin.m
Add a reference for this plugin to the plugins section in **config.xml**:
Add the **PushNotification.js** script to your assets/www folder (or javascripts folder, wherever you want really) and reference it in your main index.html file.
@@ -118,6 +122,27 @@ Add the **PushNotification.js** script to your assets/www folder (or javascripts
Copy the following files to your project's Commands folder and add it to the VS project:
```
PushPlugin.cs
```
Add a reference to this plugin in **config.xml**:
```xml
<featurename="PushPlugin">
<paramname="wp-package"value="PushPlugin"/>
</feature>
```
Add the **PushNotification.js** script to your assets/www folder (or javascripts folder, wherever you want really) and reference it in your main index.html file.
@@ -210,7 +237,7 @@ function errorHandler (error) {
}
```
**tokenHandler (iOS ony)** - called when the device has registeredwith a unique device token.
**tokenHandler (iOS only)** - called when the device has registeredwith a unique device token.
```js
functiontokenHandler(result){
@@ -302,6 +329,46 @@ Looking at the above message handling code for Android, a few things bear explai
Also make note of the **payload** object. Since the Android notification data model is much more flexible than that of iOS, there may be additional elements beyond **message**, **soundname**, and **msgcnt**. You can access those elements and any additional ones via the **payload** element. This means that if your data model should change in the future, there will be no need to change and recompile the plugin.
When not using PhoneGap Build, you can control the launch page when the user taps on your toast notification when the app is not running. Add the following code to your MainPage.xaml.cs:
if (this.NavigationContext.QueryString["NavigatedFrom"] == "toast") // this is set on the server
{
this.CordovaView.StartPageUri = new Uri("//www/index.html#notification-page", UriKind.Relative);
}
}
catch (KeyNotFoundException)
{
}
}
```
#### unregister
You will typically call this when your app is exiting, to cleanup any used resources. Its not strictly necessary to call it, and indeed it may be desireable to NOT call it if you are debugging your intermediarry push server. When you call unregister(), the current token for a particular device will get invalidated, and the next call to register() will return a new token. If you do NOT call unregister(), the last token will remain in effect until it is invalidated for some reason at the GCM side. Since such invalidations are beyond your control, its recommended that, in a production environment, that you have a matching unregister() call, for every call to register(), and that your server updates the devices' records each time.
This plugin allows your application to receive push notifications on both Android and iOS devices. The Android implementation uses Google Cloud Messaging whereas the iOS version is based on Apple APNS Notifications
This plugin allows your application to receive push notifications on Android, iOS and WP8 devices.