{"_id":"577e4ce56172c720001285b2","category":{"_id":"56cedc8ce50c9c1b00830423","__v":1,"pages":["56d763c2693ef41d0003abec"],"project":"552829408962f339009a678d","version":"552829408962f339009a6790","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-25T10:50:52.142Z","from_sync":false,"order":8,"slug":"server-configuration","title":"Server Configuration"},"parentDoc":null,"project":"552829408962f339009a678d","user":"55282916d9e1db2d00cd923c","__v":9,"version":{"_id":"552829408962f339009a6790","project":"552829408962f339009a678d","__v":26,"createdAt":"2015-04-10T19:49:20.516Z","releaseDate":"2015-04-10T19:49:20.516Z","categories":["552829418962f339009a6791","55284ed68962f339009a67e1","55286c73391a362500d9b3f4","552918f6b316811900149f59","5529b255d739240d00a3483e","553287590a578a0d008d4ff5","55329385e7d1fa0d003fc946","5550b55200420e0d00d1312f","55525fca953c9c0d00f507d7","559199695631432f002d358a","559d8d96980b801700d5ec7e","55c5e833cccdeb2d004e24b9","55d76504f662951900fc0e7d","55ea213cc62aa02f008229cd","56157b750f5ed00d00483dd8","561981fbac0924170069f4e8","561b8b1ea430930d0037ea67","563417428b86331700b488ca","56cd785bface161300dae0ec","56cdcc6e70db8a15006395f4","56cdf1b749abf10b0036a34a","56cedc8ce50c9c1b00830423","56e97ba8d825061900d1ac83","570d505228e6900e00477229","573614ca2ab52e1700c8e851","57d556a2496a3117004d70cf"],"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-07-07T12:36:53.131Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"To enable push notifications on Android devices, you'll need:\n* [Get API key](#get-api-key)\n* [Configure GCM on server](#configure-gcm-on-server)\n* [Configure Android client](#configure-android-client)\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Get API key\"\n}\n[/block]\n## 1. Go to [Google Cloud Console](https://console.cloud.google.com)\n\n## 2. Go to API Manager page\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/UwDFqm3SXG5RXEXmrLWp_1.png\",\n        \"1.png\",\n        \"1392\",\n        \"885\",\n        \"#95446d\",\n        \"\"\n      ],\n      \"sizing\": \"full\",\n      \"border\": false\n    }\n  ]\n}\n[/block]\n## 3. Choose \"Google Cloud Messaging\"\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/MD6fx5OYSe2iRoLNQNSF_Screen%20Shot%202016-07-07%20at%2015.46.26.png\",\n        \"Screen Shot 2016-07-07 at 15.46.26.png\",\n        \"1276\",\n        \"652\",\n        \"#4e87d4\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n## 4. Click \"Enable\"\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/j4z16KrWTaSUhws2iLt9_2.png\",\n        \"2.png\",\n        \"1392\",\n        \"885\",\n        \"#4376c8\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n## 5. Go to \"Credentials\"\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/PeQSM6PTVShmc2XuV9w4_3.png\",\n        \"3.png\",\n        \"1392\",\n        \"885\",\n        \"#4376c8\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n## 6. In \"Create credentials\" menu choose \"API key\"\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/It2FoynRSQGooPculccm_4.png\",\n        \"4.png\",\n        \"1392\",\n        \"885\",\n        \"#4278d4\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n## 7. In popup menu choose \"Server key\"\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/5qK8G3JQRoCQBvPDmkbQ_5.png\",\n        \"5.png\",\n        \"1392\",\n        \"885\",\n        \"#c01917\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n## 8. Give a nice name to your server key, and click \"Create\"\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/qukwzlG4SzmgHy3MF5hI_6.png\",\n        \"6.png\",\n        \"1392\",\n        \"885\",\n        \"#4277d2\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n## 9. Popup with created server key will appear. You need to copy it\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/430UU243T0qnM4B9tvs6_7.png\",\n        \"7.png\",\n        \"1392\",\n        \"885\",\n        \"#224167\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n## 10. This key will be always available on \"Credentials page\"\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/jF3RCvJ6Q4mB3yyyVLJn_8.png\",\n        \"8.png\",\n        \"1392\",\n        \"885\",\n        \"#4579d4\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n## 11. For server configuration you will also need \"Project number\". You can find it on main page of Google console\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/8FImrz65Qzed8aEwuDk8_9.png\",\n        \"9.png\",\n        \"1392\",\n        \"885\",\n        \"#4078d7\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Configure GCM on server\"\n}\n[/block]\nUsing  **Project number** and **API key** you get previously, add following section to your `server.conf`:\n\n```\nservices {\n  google {\n    push {\n      keys: [\n        {\n          project-id: <Your \"Project number\">\n          key: <Your \"API key\">\n        }\n      ]\n    }\n  }\n}\n```\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"NOTE\",\n  \"body\": \"Server supports multiple push keys. You can add more keys by putting them in `keys` section of config. Like this:\\n```\\nkeys: [\\n  {\\n    project-id: <Project number 1>\\n    key: <API key 1>\\n  }\\n  {\\n    project-id: <Project number 2>\\n    key: <API key 2>\\n  }\\n]\\n```\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Configure Android client\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Google push dependency\",\n  \"body\": \"Google push notification won't work without additional `android-google-push` library. Don't forget to add it in your gradle build file. For example, with SDK version **1.0.375** it will be: \\n\\n```\\ncompile 'im.actor:android-google-push:1.0.375'\\n```\"\n}\n[/block]\nIn your Android app you should configure `pushId` through `ActorSDK` in the following way:\n\n```java\nLong projectNumber = <Your \"Project number\">;\nActorSDK.sharedActor().setPushId(projectNumber);\n```","excerpt":"Configure GCM integration","slug":"google-push-configuration","type":"basic","title":"Google push configuration"}

Google push configuration

Configure GCM integration

To enable push notifications on Android devices, you'll need: * [Get API key](#get-api-key) * [Configure GCM on server](#configure-gcm-on-server) * [Configure Android client](#configure-android-client) [block:api-header] { "type": "basic", "title": "Get API key" } [/block] ## 1. Go to [Google Cloud Console](https://console.cloud.google.com) ## 2. Go to API Manager page [block:image] { "images": [ { "image": [ "https://files.readme.io/UwDFqm3SXG5RXEXmrLWp_1.png", "1.png", "1392", "885", "#95446d", "" ], "sizing": "full", "border": false } ] } [/block] ## 3. Choose "Google Cloud Messaging" [block:image] { "images": [ { "image": [ "https://files.readme.io/MD6fx5OYSe2iRoLNQNSF_Screen%20Shot%202016-07-07%20at%2015.46.26.png", "Screen Shot 2016-07-07 at 15.46.26.png", "1276", "652", "#4e87d4", "" ], "sizing": "full" } ] } [/block] ## 4. Click "Enable" [block:image] { "images": [ { "image": [ "https://files.readme.io/j4z16KrWTaSUhws2iLt9_2.png", "2.png", "1392", "885", "#4376c8", "" ], "sizing": "full" } ] } [/block] ## 5. Go to "Credentials" [block:image] { "images": [ { "image": [ "https://files.readme.io/PeQSM6PTVShmc2XuV9w4_3.png", "3.png", "1392", "885", "#4376c8", "" ], "sizing": "full" } ] } [/block] ## 6. In "Create credentials" menu choose "API key" [block:image] { "images": [ { "image": [ "https://files.readme.io/It2FoynRSQGooPculccm_4.png", "4.png", "1392", "885", "#4278d4", "" ], "sizing": "full" } ] } [/block] ## 7. In popup menu choose "Server key" [block:image] { "images": [ { "image": [ "https://files.readme.io/5qK8G3JQRoCQBvPDmkbQ_5.png", "5.png", "1392", "885", "#c01917", "" ], "sizing": "full" } ] } [/block] ## 8. Give a nice name to your server key, and click "Create" [block:image] { "images": [ { "image": [ "https://files.readme.io/qukwzlG4SzmgHy3MF5hI_6.png", "6.png", "1392", "885", "#4277d2", "" ], "sizing": "full" } ] } [/block] ## 9. Popup with created server key will appear. You need to copy it [block:image] { "images": [ { "image": [ "https://files.readme.io/430UU243T0qnM4B9tvs6_7.png", "7.png", "1392", "885", "#224167", "" ], "sizing": "full" } ] } [/block] ## 10. This key will be always available on "Credentials page" [block:image] { "images": [ { "image": [ "https://files.readme.io/jF3RCvJ6Q4mB3yyyVLJn_8.png", "8.png", "1392", "885", "#4579d4", "" ], "sizing": "full" } ] } [/block] ## 11. For server configuration you will also need "Project number". You can find it on main page of Google console [block:image] { "images": [ { "image": [ "https://files.readme.io/8FImrz65Qzed8aEwuDk8_9.png", "9.png", "1392", "885", "#4078d7", "" ], "sizing": "full" } ] } [/block] [block:api-header] { "type": "basic", "title": "Configure GCM on server" } [/block] Using **Project number** and **API key** you get previously, add following section to your `server.conf`: ``` services { google { push { keys: [ { project-id: <Your "Project number"> key: <Your "API key"> } ] } } } ``` [block:callout] { "type": "info", "title": "NOTE", "body": "Server supports multiple push keys. You can add more keys by putting them in `keys` section of config. Like this:\n```\nkeys: [\n {\n project-id: <Project number 1>\n key: <API key 1>\n }\n {\n project-id: <Project number 2>\n key: <API key 2>\n }\n]\n```" } [/block] [block:api-header] { "type": "basic", "title": "Configure Android client" } [/block] [block:callout] { "type": "warning", "title": "Google push dependency", "body": "Google push notification won't work without additional `android-google-push` library. Don't forget to add it in your gradle build file. For example, with SDK version **1.0.375** it will be: \n\n```\ncompile 'im.actor:android-google-push:1.0.375'\n```" } [/block] In your Android app you should configure `pushId` through `ActorSDK` in the following way: ```java Long projectNumber = <Your "Project number">; ActorSDK.sharedActor().setPushId(projectNumber); ```