<commit_before># Cordova Push Notifications Plugin for Android and iOS

---

## DESCRIPTION

This plugin is for use with [Cordova](http://incubator.apache.org/cordova/), and allows your application to receive push notifications on both Android and iOS devices. The Android implementation uses [Google's GCM (Google Cloud Messaging) service](http://developer.android.com/guide/google/gcm/index.html), whereas the iOS version is based on [Apple APNS Notifications](http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html)

**Important** - Push notifications are intended for real devices. The registration process will fail on the iOS simulator. Notifications can be made to work on the Android Emulator. However, doing so requires installation of some helper libraries, as outlined [here,](http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/) under the section titled "Installing helper libraries and setting up the Emulator".

## LICENSE

	The MIT License
	
	Copyright (c) 2012 Adobe Systems, inc.
	portions Copyright (c) 2012 <NAME>
	
	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:
	
	The above copyright notice and this permission notice shall be included in
	all copies or substantial portions of the Software.
	
	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
	THE SOFTWARE.

## Manual Installation for Android


1) copy the contents of **src/android/com/** to your project's **src/com/** folder. 
   copy the contents of **libs/** to your **libs/** folder.
   The final hirearchy will likely look something like this;

	{project_folder}
		libs
			gcm.jar
			android-support-v13.jar
			cordova-2.7.0.jar
		src
			com
				plugin
					gcm
						CordovaGCMBroadcastReceiver.java
						GCMIntentService.java
						PushHandlerActivity.java
						PushPlugin.java						
				{company_name}
					{intent_name}
						{intent_name}.java						

2) Modify your **AndroidManifest.xml** and add the following lines to your manifest tag:

			<uses-permission android:name="android.permission.GET_TASKS" />
			<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
			<uses-permission android:name="android.permission.GET_ACCOUNTS" />
			<uses-permission android:name="android.permission.WAKE_LOCK" />
			<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
			<permission android:name="$PACKAGE_NAME.permission.C2D_MESSAGE" android:protectionLevel="signature" />
			<uses-permission android:name="$PACKAGE_NAME.permission.C2D_MESSAGE" />


3) Modify your **AndroidManifest.xml** and add the following **activity**, **receiver** and **service** tags to your **application** section. (See the Sample_AndroidManifest.xml file in the Example folder.)

			<activity android:name="com.plugin.gcm.PushHandlerActivity"/>
			<receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
				<intent-filter>
					<action android:name="com.google.android.c2dm.intent.RECEIVE" />
					<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
					<category android:name="$PACKAGE_NAME" />
				</intent-filter>
			</receiver>
			<service android:name="com.plugin.gcm.GCMIntentService" />

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)

	<plugin name="PushPlugin" value="com.plugin.gcm.PushPlugin" />

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.

    <script type="text/javascript" charset="utf-8" src="PushNotification.js"></script>

## Manual Installation for iOS

Copy the following files to your project's Plugins folder:

	AppDelegate+notification.h
	AppDelegate+notification.m
	PushPlugin.h
	PushPlugin.m
	
Add a reference for this plugin to the plugins section in **config.xml**:

	<plugin name="PushPlugin" value="PushPlugin" />


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.

    <script type="text/javascript" charset="utf-8" src="PushNotification.js"></script>

## Automatic Installation
This plugin is based on [plugman](https://github.com/apache/cordova-plugman). to install it to your app,
simply execute plugman as follows;

	plugman --platform [PLATFORM] --project [TARGET-PATH] --plugin [PLUGIN-PATH]
	
	where<commit_msg>Update the readme with new domain prefix and correct plugman instructions<commit_after># Cordova Push Notifications Plugin for Android and iOS

---

## DESCRIPTION

This plugin is for use with [Cordova](http://incubator.apache.org/cordova/), and allows your application to receive push notifications on both Android and iOS devices. The Android implementation uses [Google's GCM (Google Cloud Messaging) service](http://developer.android.com/guide/google/gcm/index.html), whereas the iOS version is based on [Apple APNS Notifications](http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html)

**Important** - Push notifications are intended for real devices. The registration process will fail on the iOS simulator. Notifications can be made to work on the Android Emulator. However, doing so requires installation of some helper libraries, as outlined [here,](http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/) under the section titled "Installing helper libraries and setting up the Emulator".

## LICENSE

	The MIT License
	
	Copyright (c) 2012 Adobe Systems, inc.
	portions Copyright (c) 2012 <NAME>
	
	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:
	
	The above copyright notice and this permission notice shall be included in
	all copies or substantial portions of the Software.
	
	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
	THE SOFTWARE.

## Manual Installation for Android


1) copy the contents of **src/android/com/** to your project's **src/com/** folder. 
   copy the contents of **libs/** to your **libs/** folder.
   The final hirearchy will likely look something like this;

	{project_folder}
		libs
			gcm.jar
			android-support-v13.jar
			cordova-2.7.0.jar
		src
			com
				plugin
					gcm
						CordovaGCMBroadcastReceiver.java
						GCMIntentService.java
						PushHandlerActivity.java
						PushPlugin.java						
				{company_name}
					{intent_name}
						{intent_name}.java						

2) Modify your **AndroidManifest.xml** and add the following lines to your manifest tag:

			<uses-permission android:name="android.permission.GET_TASKS" />
			<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
			<uses-permission android:name="android.permission.GET_ACCOUNTS" />
			<uses-permission android:name="android.permission.WAKE_LOCK" />
			<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
			<permission android:name="$PACKAGE_NAME.permission.C2D_MESSAGE" android:protectionLevel="signature" />
			<uses-permission android:name="$PACKAGE_NAME.permission.C2D_MESSAGE" />


3) Modify your **AndroidManifest.xml** and add the following **activity**, **receiver** and **service** tags to your **application** section. (See the Sample_AndroidManifest.xml file in the Example folder.)

			<activity android:name="com.plugin.gcm.PushHandlerActivity"/>
			<receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
				<intent-filter>
					<action android:name="com.google.android.c2dm.intent.RECEIVE" />
					<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
					<category android:name="$PACKAGE_NAME" />
				</intent-filter>
			</receiver>
			<service android:name="com.plugin.gcm.GCMIntentService" />

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)

	<plugin name="PushPlugin" value="com.plugin.gcm.PushPlugin" />

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.

    <script type="text/javascript" charset="utf-8" src="PushNotification.js"></script>

## Manual Installation for iOS

Copy the following files to your project's Plugins folder:

	AppDelegate+notification.h
	AppDelegate+notification.m
	PushPlugin.h
	PushPlugin.m
	
Add a reference for this plugin to the plugins section in **config.xml**:

	<gap:plugin name="com.phonegap.plugins.PushPlugin"/>


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.

    <script type="text/javascript" charset="utf-8" src="PushNotification.js"></script>

## Automatic Installation
This plugin is based on [plugman](https://github.com/apache/cordova-plugman). to install it to your app,
simply execute plugman as follows;

	plugman install --platform [PLATFORM] --project [TARGET-PATH] --plugin [PLUGIN-PATH]
	
	where
{'fraction_non_alphanumeric': 0.09420095007618536, 'fraction_numerical': 0.005736309043649726, 'mean_word_length': 4.615500754906895, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 2, 'lorem ipsum': 0, 'www.': 6, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6755056', 'n_tokens_mistral': 3381, 'n_tokens_neox': 3008, 'n_words': 1123}