{"__v":16,"_id":"55a93c4002becf2d007aac43","category":{"__v":6,"_id":"55a589e30f354f0d00fd0312","pages":["55a590d080c8a30d00b32402","55a591c20f354f0d00fd0347","55a591c780c8a30d00b3240e","55a9172a27a17d210052524e","55a9222dc8bd450d000dd1a8","56d5d72da0b5600b000b1f7b"],"project":"559a61d2dbcfd20d00710b39","version":"559a61d2dbcfd20d00710b3c","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-07-14T22:14:59.849Z","from_sync":false,"order":3,"slug":"android-sdk","title":"Android SDK"},"parentDoc":null,"project":"559a61d2dbcfd20d00710b39","user":"559a618bdbcfd20d00710b38","version":{"__v":23,"_id":"559a61d2dbcfd20d00710b3c","project":"559a61d2dbcfd20d00710b39","createdAt":"2015-07-06T11:09:06.510Z","releaseDate":"2015-07-06T11:09:06.510Z","categories":["559a61d3dbcfd20d00710b3d","55a589ddaaf9cf1900114dd0","55a589e30f354f0d00fd0312","55a589ea80c8a30d00b323cc","55a589f6aaf9cf1900114dd1","55a58d4e80c8a30d00b323e6","55a8e7a227a17d21005251a2","55a93098cf45e1390093f351","55afb085f202b12100cd9e83","55afb22e902fd51700f5f8bf","55afb260902fd51700f5f8c2","55afb28ec8a85321007a5462","55afb294f202b12100cd9e95","55afb29b902fd51700f5f8c5","55afb2a1c8a85321007a5463","55afb2a7902fd51700f5f8c7","55afb2ad902fd51700f5f8c8","55afb2b5902fd51700f5f8ca","55b74b2131bccb190081bedc","55bb441b54f9640d006e6cf2","565711085cb2420d00d70071","5681681330018c0d006bf7ff","588f38b5923d610f00c72dad"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"Version 1.0","version_clean":"1.0.0","version":"1"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-07-17T17:32:48.053Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"MOCA SDK easily integrates with GCM push notifications.\n\n- GCM token is automatically requested if you activate this feature.\n- Push notifications are automatically handled by the library.\n- Tracked received push notifications with MOCA SDK. \n- The tracked data can be analyzed in MOCA Analytics \u000b(Pushes, PushOpened, and more) -\n \nIf your app already uses push notification, you must *disable* automatic GCM push registration in MOCA.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"remotePushNotificationsService = true\",\n      \"language\": \"ruby\",\n      \"name\": \"MOCA.properties\"\n    },\n    {\n      \"code\": \" <application …>\\n\\n\\t<meta-data android:name=\\\"moca.AUTOMATIC_PUSH_SETUP_ENABLED\\\" android:value=\\\"true\\\"/>\",\n      \"language\": \"xml\",\n      \"name\": \"AndroidManifest.xml\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Integrating Push with MOCA\"\n}\n[/block]\nDeclare MOCAPushReceiver component in `AndroidManifest.xml\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<!-- Required by MOCA to receive GCM remote push notifications -->\\n<receiver\\n\\tandroid:name=\\\"com.innoquant.moca.push.GcmPushReceiver\\\"\\n\\tandroid:exported=\\\"true\\\"\\n\\tandroid:permission=\\\"com.google.android.c2dm.permission.SEND\\\">\\n  <intent-filter>\\n    <action android:name=\\\"com.google.android.c2dm.intent.RECEIVE\\\"/>\\n    <action android:name=\\\"com.google.android.c2dm.intent.REGISTRATION\\\"/>\\n   \\t<category android:name=\\\"${applicationId}p\\\"/>\\n  </intent-filter>\\n</receiver>\\n\\n  \\n<!-- MOCA GcmTokenListener listens to token registrations/updates -->\\n<service android:name=\\\"com.innoquant.moca.push.GcmTokenListener\\\"\\n\\t\\t\\t\\t android:exported=\\\"false\\\">\\n\\t<intent-filter>\\n\\t\\t<action android:name=\\\"com.google.android.gms.iid.InstanceID\\\"/>\\n\\t</intent-filter>\\n</service>\\n\\n\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\nThis receiver will handle registration process and incoming push notification messages generated by MOCA.\n\n- Ensure you have added your Google Sender Id:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"gcmSender = YOUR-GCM-SENDER-ID\",\n      \"language\": \"ruby\",\n      \"name\": \"MOCA.properties\"\n    },\n    {\n      \"code\": \" <!--Optional: Include it for remote push notifications-->\\n    <!--Be careful with the space before the number-->\\n    <meta-data android:name=\\\"moca.GCM_SENDER\\\" android:value=\\\"\\\\ YOUR_GCM_SENDER_ID\\\" />\",\n      \"language\": \"xml\",\n      \"name\": \"AndroidManifest.xml\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"NOTE\",\n  \"body\": \"For the `AndroidManifest.xml configuration, there is a `space` after the backslash `\\\\` in the `\\\"gcm_sender\\\"` field. **Do not delete the space character**, otherwise key won't be read correctly.\\n\\nvalue=\\\"\\\\\\\\` `YOUR_GCM_SENDER\\\"\"\n}\n[/block]","excerpt":"","slug":"push-notifications","type":"basic","title":"Push Notifications"}

Push Notifications


MOCA SDK easily integrates with GCM push notifications. - GCM token is automatically requested if you activate this feature. - Push notifications are automatically handled by the library. - Tracked received push notifications with MOCA SDK. - The tracked data can be analyzed in MOCA Analytics (Pushes, PushOpened, and more) - If your app already uses push notification, you must *disable* automatic GCM push registration in MOCA. [block:code] { "codes": [ { "code": "remotePushNotificationsService = true", "language": "ruby", "name": "MOCA.properties" }, { "code": " <application …>\n\n\t<meta-data android:name=\"moca.AUTOMATIC_PUSH_SETUP_ENABLED\" android:value=\"true\"/>", "language": "xml", "name": "AndroidManifest.xml" } ] } [/block] [block:api-header] { "type": "basic", "title": "Integrating Push with MOCA" } [/block] Declare MOCAPushReceiver component in `AndroidManifest.xml [block:code] { "codes": [ { "code": "<!-- Required by MOCA to receive GCM remote push notifications -->\n<receiver\n\tandroid:name=\"com.innoquant.moca.push.GcmPushReceiver\"\n\tandroid:exported=\"true\"\n\tandroid:permission=\"com.google.android.c2dm.permission.SEND\">\n <intent-filter>\n <action android:name=\"com.google.android.c2dm.intent.RECEIVE\"/>\n <action android:name=\"com.google.android.c2dm.intent.REGISTRATION\"/>\n \t<category android:name=\"${applicationId}p\"/>\n </intent-filter>\n</receiver>\n\n \n<!-- MOCA GcmTokenListener listens to token registrations/updates -->\n<service android:name=\"com.innoquant.moca.push.GcmTokenListener\"\n\t\t\t\t android:exported=\"false\">\n\t<intent-filter>\n\t\t<action android:name=\"com.google.android.gms.iid.InstanceID\"/>\n\t</intent-filter>\n</service>\n\n", "language": "xml" } ] } [/block] This receiver will handle registration process and incoming push notification messages generated by MOCA. - Ensure you have added your Google Sender Id: [block:code] { "codes": [ { "code": "gcmSender = YOUR-GCM-SENDER-ID", "language": "ruby", "name": "MOCA.properties" }, { "code": " <!--Optional: Include it for remote push notifications-->\n <!--Be careful with the space before the number-->\n <meta-data android:name=\"moca.GCM_SENDER\" android:value=\"\\ YOUR_GCM_SENDER_ID\" />", "language": "xml", "name": "AndroidManifest.xml" } ] } [/block] [block:callout] { "type": "danger", "title": "NOTE", "body": "For the `AndroidManifest.xml configuration, there is a `space` after the backslash `\\` in the `\"gcm_sender\"` field. **Do not delete the space character**, otherwise key won't be read correctly.\n\nvalue=\"\\\\` `YOUR_GCM_SENDER\"" } [/block]