{"_id":"59ba4643124ec000248a8261","project":"5540ce1b31827a0d007ab1cc","version":{"_id":"5540ce1c31827a0d007ab1cf","project":"5540ce1b31827a0d007ab1cc","__v":31,"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"},"category":{"_id":"5540e5f131827a0d007ab212","__v":15,"project":"5540ce1b31827a0d007ab1cc","pages":["5540e66b31827a0d007ab217","5540e67731827a0d007ab219","55ac917b5863b817008ae3b4","55acaa4c6b4ff90d00784a92","55acb96418eefd0d0071d553","55acc8aa18eefd0d0071d596","55accd2818eefd0d0071d5a8","55acd06518eefd0d0071d5b6","55acddd7fb7b3c19003739cc","55ace14bfb7b3c19003739d3","55ace3a9fb7b3c19003739d7","55acea24f93f0c0d005b880f","55acf15bf93f0c0d005b8821","55acf3cd18eefd0d0071d5fb","55d1f1c0486de50d00326f17"],"version":"5540ce1c31827a0d007ab1cf","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-29T14:08:49.271Z","from_sync":false,"order":4,"slug":"android","title":"Android"},"user":"59ba356300b054001c3cee02","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-09-14T09:05:07.898Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"[**Download SDK**](https://github.com/Pushwoosh/pushwoosh-android-sdk)\n[**Sample Project**](https://github.com/Pushwoosh/pushwoosh-android-sdk/tree/master/Samples/Android-Simple)\n[**SDK API Docs**](https://rawgit.com/Pushwoosh/pushwoosh-android-sdk/master/Documentation/index.html)\n[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"\",\n  \"body\": \"Firebase Cloud Messaging library is available starting with version 5.1.0 of Pushwoosh SDK only.\"\n}\n[/block]\n**1.** Include the following Maven repository URL in project's **build.gradle**:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"allprojects {\\n    repositories {\\n        jcenter ()\\n        maven {\\n            url \\\"https://maven.google.com\\\"\\n         }\\n    } \\n}\",\n      \"language\": \"java\",\n      \"name\": \"build.gradle\"\n    }\n  ]\n}\n[/block]\n**2.** Add **pushwoosh** and **android support v4 services** library dependencies into your application's **build.gradle**:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"compile 'com.pushwoosh:pushwoosh:5.+'\\ncompile 'com.android.support:support-v4:26.+'\",\n      \"language\": \"java\",\n      \"name\": \"build.gradle\"\n    }\n  ]\n}\n[/block]\nReplace \"**+**\" with the current version of Pushwoosh and Android Support libraries.\n\n**3.** Open your project in Android Studio. Go **Tools** > **Firebase** > **Cloud Messaging** and click \"Set up Firebase Cloud Messaging\":\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/a82dc43-Screen_Shot_2017-09-14_at_14.31.37.png\",\n        \"Screen Shot 2017-09-14 at 14.31.37.png\",\n        1920,\n        1009,\n        \"#e5e6e5\"\n      ]\n    }\n  ]\n}\n[/block]\n**4.** Connect your app with Firebase, grant Android Studio access to your Google account (if needed), and create a new Firebase project:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/676c8f3-Connect_to_Firebase_and_MainActivity_java_-_MyApplication_-____Downloads_pushwoosh-phonegap-cordova-sample_Cordova_platforms_MyApplication__png.png\",\n        \"Connect_to_Firebase_and_MainActivity_java_-_MyApplication_-____Downloads_pushwoosh-phonegap-cordova-sample_Cordova_platforms_MyApplication__png.png\",\n        669,\n        569,\n        \"#e9e9e9\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"\",\n  \"body\": \"If you have an existing Firebase project, choose it from the list.\"\n}\n[/block]\n**5.** Add FCM to your application and accept changes:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/0475fd1-Add_FCM_to_your_app_and_MainActivity_java_-_MyApplication_-____Downloads_pushwoosh-phonegap-cordova-sample_Cordova_platforms_MyApplication__png.png\",\n        \"Add_FCM_to_your_app_and_MainActivity_java_-_MyApplication_-____Downloads_pushwoosh-phonegap-cordova-sample_Cordova_platforms_MyApplication__png.png\",\n        601,\n        420,\n        \"#e6e6e5\"\n      ]\n    }\n  ]\n}\n[/block]\n**6.** Set up the Android platform in [**Pushwoosh Control Panel**](https://go.pushwoosh.com/) following the steps from the [**configuration guide**](http://docs.pushwoosh.com/v1.0/docs/android-configuration).\n\n**7.** Add the following metadata to **AndroidManifest.xml**:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<meta-data android:name=\\\"com.pushwoosh.appid\\\" android:value=\\\"XXXXX-XXXXX\\\" />\\n<meta-data android:name=\\\"com.pushwoosh.senderid\\\" android:value=\\\":::at:::string/fcm_sender_id\\\" /> \",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\nWhere:\n* `com.pushwoosh.appid` is your Pushwoosh Application Code\n* `com.pushwoosh.senderid` is the Sender ID you received from Firebase Console \n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Please note that you need to add **fcm_sender_id** to **res/values/strings.xml** of your Android project:\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<resources>\\n    <string name=\\\"fcm_sender_id\\\">123456789012</string>\\n</resources>\",\n      \"language\": \"xml\",\n      \"name\": \"string.xml\"\n    }\n  ]\n}\n[/block]\n**8 .** Register for push notifications:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Pushwoosh.getInstance().registerForPushNotifications();\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","excerpt":"Follow the steps below to get your Android application ready to receive pushes.","slug":"fcm-integration","type":"basic","title":"Getting Started"}

Getting Started

Follow the steps below to get your Android application ready to receive pushes.

[**Download SDK**](https://github.com/Pushwoosh/pushwoosh-android-sdk) [**Sample Project**](https://github.com/Pushwoosh/pushwoosh-android-sdk/tree/master/Samples/Android-Simple) [**SDK API Docs**](https://rawgit.com/Pushwoosh/pushwoosh-android-sdk/master/Documentation/index.html) [block:callout] { "type": "success", "title": "", "body": "Firebase Cloud Messaging library is available starting with version 5.1.0 of Pushwoosh SDK only." } [/block] **1.** Include the following Maven repository URL in project's **build.gradle**: [block:code] { "codes": [ { "code": "allprojects {\n repositories {\n jcenter ()\n maven {\n url \"https://maven.google.com\"\n }\n } \n}", "language": "java", "name": "build.gradle" } ] } [/block] **2.** Add **pushwoosh** and **android support v4 services** library dependencies into your application's **build.gradle**: [block:code] { "codes": [ { "code": "compile 'com.pushwoosh:pushwoosh:5.+'\ncompile 'com.android.support:support-v4:26.+'", "language": "java", "name": "build.gradle" } ] } [/block] Replace "**+**" with the current version of Pushwoosh and Android Support libraries. **3.** Open your project in Android Studio. Go **Tools** > **Firebase** > **Cloud Messaging** and click "Set up Firebase Cloud Messaging": [block:image] { "images": [ { "image": [ "https://files.readme.io/a82dc43-Screen_Shot_2017-09-14_at_14.31.37.png", "Screen Shot 2017-09-14 at 14.31.37.png", 1920, 1009, "#e5e6e5" ] } ] } [/block] **4.** Connect your app with Firebase, grant Android Studio access to your Google account (if needed), and create a new Firebase project: [block:image] { "images": [ { "image": [ "https://files.readme.io/676c8f3-Connect_to_Firebase_and_MainActivity_java_-_MyApplication_-____Downloads_pushwoosh-phonegap-cordova-sample_Cordova_platforms_MyApplication__png.png", "Connect_to_Firebase_and_MainActivity_java_-_MyApplication_-____Downloads_pushwoosh-phonegap-cordova-sample_Cordova_platforms_MyApplication__png.png", 669, 569, "#e9e9e9" ] } ] } [/block] [block:callout] { "type": "info", "title": "", "body": "If you have an existing Firebase project, choose it from the list." } [/block] **5.** Add FCM to your application and accept changes: [block:image] { "images": [ { "image": [ "https://files.readme.io/0475fd1-Add_FCM_to_your_app_and_MainActivity_java_-_MyApplication_-____Downloads_pushwoosh-phonegap-cordova-sample_Cordova_platforms_MyApplication__png.png", "Add_FCM_to_your_app_and_MainActivity_java_-_MyApplication_-____Downloads_pushwoosh-phonegap-cordova-sample_Cordova_platforms_MyApplication__png.png", 601, 420, "#e6e6e5" ] } ] } [/block] **6.** Set up the Android platform in [**Pushwoosh Control Panel**](https://go.pushwoosh.com/) following the steps from the [**configuration guide**](http://docs.pushwoosh.com/v1.0/docs/android-configuration). **7.** Add the following metadata to **AndroidManifest.xml**: [block:code] { "codes": [ { "code": "<meta-data android:name=\"com.pushwoosh.appid\" android:value=\"XXXXX-XXXXX\" />\n<meta-data android:name=\"com.pushwoosh.senderid\" android:value=\"@string/fcm_sender_id\" /> ", "language": "xml" } ] } [/block] Where: * `com.pushwoosh.appid` is your Pushwoosh Application Code * `com.pushwoosh.senderid` is the Sender ID you received from Firebase Console [block:callout] { "type": "info", "body": "Please note that you need to add **fcm_sender_id** to **res/values/strings.xml** of your Android project:" } [/block] [block:code] { "codes": [ { "code": "<resources>\n <string name=\"fcm_sender_id\">123456789012</string>\n</resources>", "language": "xml", "name": "string.xml" } ] } [/block] **8 .** Register for push notifications: [block:code] { "codes": [ { "code": "Pushwoosh.getInstance().registerForPushNotifications();", "language": "java" } ] } [/block]