<commit_before># RealtimeMessaging-ReactNativeAndroidExample
Realtime Cloud Messaging React Native for Android Example (including GCM mobile push notifications)

This example is a simple app that allows you to send and receive messages between devices using React Native and the Realtime Messaging React Native SDK.
 
[Realtime Cloud Messaging](http://framework.realtime.co/messaging) is a highly-scalable pub/sub message broker, allowing you to broadcast messages to millions of users, reliably and securely. It's all in the cloud so you don't need to manage servers.

[React Native](http://facebook.github.io/react-native/) enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React.


##How to test this demo application

*	Create a new react-native project using the following command `react-native init RealtimeRCT`

*	Replace index.android.js for the one provided in this repository.

* Create a new react-native project. [Check react-native getting started](http://facebook.github.io/react-native/docs/getting-started.html#content)

* On the terminal, go to `PROJECT_DIR/node_modules/react-native`.

* Execute

		 npm install --save react-native-realtimemessaging-android

* Drag all files `node_modules/react-native-realtimemessaging-android` to your `src` package folder.

* Add compile `co.realtime:messaging-android:2.1.+` to app dependencies in your `build.gradle` file.

* Drag `RCTRealtimeMessagingAndroid.js` to the root of your project.

* Add `.addPackage(new CustomReactPackage())` to the `onCreate` method of `MainActivity`.

* **If you want to use push notifications**, set `MainActivity` extending `RealtimePushNotificationActivity`.

	* Edit AndroidManifest.xml
			
			...
			<permission android:name="[YOUR RECEIVER PACKAGE].permission.C2D_MESSAGE" android:protectionLevel="signature" />
			
		    <uses-permission android:name="[YOUR RECEIVER PACKAGE].permission.C2D_MESSAGE" />
		    
		    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
		    ...
		    
		    <application
		    ...
		    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
	        <receiver
	            android:name=".GcmReceiver"
	            android:permission="com.google.android.c2dm.permission.SEND" >
	            <intent-filter>
	                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
	                <category android:name="[YOUR RECEIVER PACKAGE]" />
	            </intent-filter>
	        </receiver>
			    ...
		    <application/>




 You are ready to go.

##Testing the custom push notifications delivery

To test the Realtime Custom Push Notifications you need to use the Realtime Mobile Push REST API to send a custom push with the following POST to `https://ortc-mobilepush.realtime.co/mp/publish`

	{
	   "applicationKey": "[INSERT YOUR APP KEY]",
	   "privateKey": "[INSERT YOUR APP PRIVATE KEY]",
	   "channel" : "[INSERT CHANNEL TO SEND PUSH]",
	   "message" : "[INSERT ALERT TEXT]",
	    "payload" : "{
	     \"sound\" : \"default\",
	     \"badge\" : \"1\",
	     \"name\" : \"Joe\",<commit_msg>Documentation update<commit_after># RealtimeMessaging-ReactNativeAndroidExample
Realtime Cloud Messaging React Native for Android Example (including GCM mobile push notifications)

This example is a simple app that allows you to send and receive messages between devices using React Native and the Realtime Messaging React Native SDK.
 
[Realtime Cloud Messaging](http://framework.realtime.co/messaging) is a highly-scalable pub/sub message broker, allowing you to broadcast messages to millions of users, reliably and securely. It's all in the cloud so you don't need to manage servers.

[React Native](http://facebook.github.io/react-native/) enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React.


##How to test this demo application

*	Create a new react-native project with name `RealtimeRCT`. [Check react-native getting started](http://facebook.github.io/react-native/docs/getting-started.html#content)

*	Replace index.android.js for the one provided in this repository.

*	Install the RCTRealtimeMessagingAndroid SDK, follow the [documentation](https://github.com/realtime-framework/RCTRealtimeMessagingAndroid) on realtime framework GitHub.

*	Create a Google project in [here](https://code.Google.com/apis/).

*	Create a Realtime messaging account and configure the Google Api key on the account, you can check more details of this process in the android native configuration guide for [push notification](http://messaging-public.realtime.co/documentation/starting-guide/mobilePushGCM.html). 
**Note: Theres no need to change Manifest.xml in react-native, that is just for android native.**	

*	Update index.android.js to use your Google project number and Realtime application key.

 You are ready to go.

##Testing the custom push notifications delivery

To test the Realtime Custom Push Notifications you need to use the Realtime Mobile Push REST API to send a custom push with the following POST to `https://ortc-mobilepush.realtime.co/mp/publish`

	{
	   "applicationKey": "[INSERT YOUR APP KEY]",
	   "privateKey": "[INSERT YOUR APP PRIVATE KEY]",
	   "channel" : "[INSERT CHANNEL TO SEND PUSH]",
	   "message" : "[INSERT ALERT TEXT]",
	    "payload" : "{
	     \"sound\" : \"default\",
	     \"badge\" : \"1\",
	     \"name\" : \"Joe\",
{'fraction_non_alphanumeric': 0.09856373429084381, 'fraction_numerical': 0.001615798922800718, 'mean_word_length': 3.9388297872340425, 'pattern_counts': {'":': 4, '<': 15, '<?xml version=': 0, '>': 14, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1605701', 'n_tokens_mistral': 1593, 'n_tokens_neox': 1463, 'n_words': 552}