{"__v":3,"_id":"57595cfaa613a517004674c8","category":{"project":"5540ce1b31827a0d007ab1cc","version":"5540ce1c31827a0d007ab1cf","_id":"57595bbb18760817001e8bbe","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-06-09T12:06:19.325Z","from_sync":false,"order":24,"slug":"react-native","title":"React Native"},"parentDoc":null,"project":"5540ce1b31827a0d007ab1cc","user":"5540e0f5bb9e762d00f594c0","version":{"__v":31,"_id":"5540ce1c31827a0d007ab1cf","project":"5540ce1b31827a0d007ab1cc","createdAt":"2015-04-29T12:27:08.390Z","releaseDate":"2015-04-29T12:27:08.390Z","categories":["5540ce1c31827a0d007ab1d0","5540d91bbb9e762d00f594ad","5540e5f131827a0d007ab212","5540e5febb9e762d00f594d3","5540e61331827a0d007ab213","5540e6195cf9682100d61afa","5540e62631827a0d007ab214","5540e63031827a0d007ab215","5540e63531827a0d007ab216","5540e63e5cf9682100d61afc","5540e6445cf9682100d61afd","5540e64a5cf9682100d61afe","55a4ff5b2e70c0250038050f","55acb28318eefd0d0071d504","55ae1abe8576b92300291c80","55ae453ef302af23000ac109","55af586d555b900d0036d296","55af91dac8a85321007a53c3","55b9fee204775a2f00628071","55b9ff0e04775a2f00628072","55b9ff4604775a2f00628073","55b9ff5fd72d1e1900276a38","55b9ff7f04775a2f00628074","55b9ff90eb08801900f833e5","55b9ffa5d72d1e1900276a39","55b9ffca04775a2f00628075","55b9fffdd72d1e1900276a3a","56bc2f033ee9e70d008b46af","56c2f6efbbf9ec2d00e0fe4f","57595bbb18760817001e8bbe","57d8d9793916800e003dde53"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-06-09T12:11:38.753Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"[**Download Sample**](https://github.com/Pushwoosh/pushwoosh-react-native-sample)\n[**Module API Docs**](http://docs.pushwoosh.com/docs/reactnative-api-reference) \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Step 1 - Install plugin\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"npm install pushwoosh-react-native-plugin --save\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Step 2 - Include pushwoosh plugin library project\"\n}\n[/block]\nIn** android/settings.gradle** file, make the following changes:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"include ':pushwooshplugin'\\nproject(':pushwooshplugin').projectDir = new File(rootProject.projectDir, '../node_modules/pushwoosh-react-native-plugin/src/android')\",\n      \"language\": \"javascript\",\n      \"name\": \"settings.gradle\"\n    }\n  ]\n}\n[/block]\nIn **android/app/build.gradle** add **pushwooshplugin** dependency:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"dependencies {\\n    ...\\n    compile project(':pushwooshplugin')\\n}\",\n      \"language\": \"groovy\",\n      \"name\": \"build.gradle\"\n    }\n  ]\n}\n[/block]\nIn **MainApplication.java** add:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"...\\nimport com.pushwoosh.reactnativeplugin.PushwooshPackage;\\n\\npublic class MainApplication extends Application implements ReactApplication {\\n\\n    ...\\n\\n    :::at:::Override\\n    protected List<ReactPackage> getPackages() {\\n        return Arrays.<ReactPackage>asList(\\n            new MainReactPackage(),\\n            new PushwooshPackage() // register Pushwoosh plugin here\\n        );\\n    }\\n}\",\n      \"language\": \"java\",\n      \"name\": \"MainActivity.java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Step 3 - Use module\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import Pushwoosh from 'pushwoosh-react-native-plugin';\\n\\nPushwoosh.init({ \\\"pw_appid\\\" : \\\"YOUR_PUSHWOOSH_PROJECT_ID\\\" , \\\"project_number\\\" : \\\"YOUR_GCM_PROJECT_NUMBER\\\" });\\nPushwoosh.register();\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"react-native-pushwoosh-push-notifications-module-for-android","type":"basic","title":"React Native Android Module"}

React Native Android Module


[**Download Sample**](https://github.com/Pushwoosh/pushwoosh-react-native-sample) [**Module API Docs**](http://docs.pushwoosh.com/docs/reactnative-api-reference) [block:api-header] { "type": "basic", "title": "Step 1 - Install plugin" } [/block] [block:code] { "codes": [ { "code": "npm install pushwoosh-react-native-plugin --save", "language": "shell" } ] } [/block] [block:api-header] { "type": "basic", "title": "Step 2 - Include pushwoosh plugin library project" } [/block] In** android/settings.gradle** file, make the following changes: [block:code] { "codes": [ { "code": "include ':pushwooshplugin'\nproject(':pushwooshplugin').projectDir = new File(rootProject.projectDir, '../node_modules/pushwoosh-react-native-plugin/src/android')", "language": "javascript", "name": "settings.gradle" } ] } [/block] In **android/app/build.gradle** add **pushwooshplugin** dependency: [block:code] { "codes": [ { "code": "dependencies {\n ...\n compile project(':pushwooshplugin')\n}", "language": "groovy", "name": "build.gradle" } ] } [/block] In **MainApplication.java** add: [block:code] { "codes": [ { "code": "...\nimport com.pushwoosh.reactnativeplugin.PushwooshPackage;\n\npublic class MainApplication extends Application implements ReactApplication {\n\n ...\n\n @Override\n protected List<ReactPackage> getPackages() {\n return Arrays.<ReactPackage>asList(\n new MainReactPackage(),\n new PushwooshPackage() // register Pushwoosh plugin here\n );\n }\n}", "language": "java", "name": "MainActivity.java" } ] } [/block] [block:api-header] { "type": "basic", "title": "Step 3 - Use module" } [/block] [block:code] { "codes": [ { "code": "import Pushwoosh from 'pushwoosh-react-native-plugin';\n\nPushwoosh.init({ \"pw_appid\" : \"YOUR_PUSHWOOSH_PROJECT_ID\" , \"project_number\" : \"YOUR_GCM_PROJECT_NUMBER\" });\nPushwoosh.register();", "language": "javascript" } ] } [/block]