{"_id":"55a590d580c8a30d00b32404","isReference":false,"link_external":false,"project":"559a61d2dbcfd20d00710b39","updates":[],"version":"559a61d2dbcfd20d00710b3c","category":"559a61d3dbcfd20d00710b3d","excerpt":"This page will help you get started with MOCA. You'll be up and running in a jiffy!","body":"There are a few important steps to get out of the way when integrating MOCA SDK with your iOS or Android app for the first time. Follow these instructions carefully to ensure that you will have a smooth development experience. We will take you through the basic technical steps for configuring Apple and MOCA services, show you how to add the first proximity-triggered experiences to your app and provide detailed examples and instructions for using advanced MOCA features.\n\n[block:embed]\n{\n  \"html\": \"<iframe class=\\\"embedly-embed\\\" src=\\\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F-PKE0Vrr3bw%3Ffeature%3Doembed&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D-PKE0Vrr3bw&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-PKE0Vrr3bw%2Fhqdefault.jpg&key=02466f963b9b4bb8845a05b53d3235d7&type=text%2Fhtml&schema=youtube\\\" width=\\\"854\\\" height=\\\"480\\\" scrolling=\\\"no\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\",\n  \"url\": \"https://www.youtube.com/watch?v=-PKE0Vrr3bw\",\n  \"title\": \"Getting Started With MOCA - Proximity Marketing and iBeacon Platform\",\n  \"favicon\": \"https://s.ytimg.com/yts/img/favicon-vflz7uhzw.ico\",\n  \"image\": \"https://i.ytimg.com/vi/-PKE0Vrr3bw/hqdefault.jpg\"\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/yTKMcnVdQPiF2cUtuX7Q_sdks.png\",\n        \"sdks.png\",\n        \"400\",\n        \"160\",\n        \"#e08e49\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Production & Development Apps in MOCA\"\n}\n[/block]\nWhen you create or edit an App in MOCA, you must select whether your app is **In development** or **In production** mode. When developing or testing your app, configure your app to *In development*. When submitting your app to AppStore, configure your app to *In production*. MOCA treats the two modes separately, we suggest making two apps in the MOCA Console. That way you can continue to build and develop your application even after releasing it without interrupting your users.\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"body\": \"Always create a Production Status MOCA app first and make sure your app code is pointing to the production app key. For more tips on what to check before you release your app, see [*Submitting Your App to the Store*](/docs/moca-ios-sdk-submitting-your-app-to-the-store) article.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Creating your first Campaign and Experiences\"\n}\n[/block]\nAfter adding your first app to your Moca account, you can start creating Campaigns and adding as many Proximity Experiences to them as you need.\n\nStart by selecting your app:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/IcE6Yc1sRu2gcuL1JQRf_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.38.42.png\",\n        \"Captura de pantalla 2015-09-23 a las 17.38.42.png\",\n        \"1731\",\n        \"727\",\n        \"#df333b\",\n        \"\"\n      ],\n      \"caption\": \"MocaApp for Testing\"\n    }\n  ]\n}\n[/block]\nThen select campaign and click on \"New campaign\":\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/bvHYtw3qSWGqskBoM2nt_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.41.50.png\",\n        \"Captura de pantalla 2015-09-23 a las 17.41.50.png\",\n        \"1731\",\n        \"679\",\n        \"#55718f\",\n        \"\"\n      ],\n      \"caption\": \"Campaign list\"\n    }\n  ]\n}\n[/block]\nChoose a name for your Campaign, add a start date and an end date, and optionally add a description and choose a target (Standard and Pro versions only):\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/cLz21QrdRXiktEpiZl1Y_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.44.43.png\",\n        \"Captura de pantalla 2015-09-23 a las 17.44.43.png\",\n        \"467\",\n        \"550\",\n        \"#436b98\",\n        \"\"\n      ],\n      \"caption\": \"Add Campaign View\"\n    }\n  ]\n}\n[/block]\nNow you'll see your new Campaign listed in your Campaigns' list. When ready remember to click the \"Start\" button to initiate the Campaign, otherwise your users won't receive any Proximity Experiences. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/N8EuWC41QoWi5AYLtx9U_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.46.25.png\",\n        \"Captura de pantalla 2015-09-23 a las 17.46.25.png\",\n        \"1497\",\n        \"349\",\n        \"#527da7\",\n        \"\"\n      ],\n      \"caption\": \"Campaign List\"\n    }\n  ]\n}\n[/block]\nNow let's add our first experience. Click on the campaign name and then click on the \"New experience\" button on the upper right corner.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/1MKnruM6ScKPJ1tOKg1w_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.46.25.png\",\n        \"Captura de pantalla 2015-09-23 a las 17.46.25.png\",\n        \"1497\",\n        \"349\",\n        \"#527da7\",\n        \"\"\n      ],\n      \"caption\": \"Campaign List\"\n    }\n  ]\n}\n[/block]\nThis will take you to the Proximity Experience editor.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/sgo9kiCGRGpetCVsT90z_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.51.25.png\",\n        \"Captura de pantalla 2015-09-23 a las 17.51.25.png\",\n        \"1487\",\n        \"1164\",\n        \"#906c64\",\n        \"\"\n      ],\n      \"caption\": \"Moca Proximity Experience Editor\"\n    }\n  ]\n}\n[/block]\nThere are several types of Experiences you can create, each for a different purpose. They can be classified by their in-app action and whether they have a Notification Message in the device's notification center.\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Type\",\n    \"h-1\": \"Notification Message\",\n    \"h-2\": \"InApp Action\",\n    \"h-3\": \"Limits\",\n    \"0-0\": \"Message\",\n    \"0-1\": \"Yes\",\n    \"0-2\": \"None\",\n    \"0-3\": \"OS Notification character limit.\",\n    \"1-0\": \"Image\",\n    \"1-1\": \"Yes\",\n    \"1-2\": \"An Image\",\n    \"1-3\": \"OS Notification character limit.\",\n    \"2-0\": \"URL\",\n    \"2-1\": \"Yes\",\n    \"2-2\": \"A URL to a website\",\n    \"2-3\": \"OS Notification character limit.\",\n    \"3-0\": \"HTML\",\n    \"3-1\": \"Yes\",\n    \"3-2\": \"InApp rendered HTML\",\n    \"3-3\": \"OS Notification character limit.\\n\\nmax. 50KB of HTML code\",\n    \"4-0\": \"Card\",\n    \"4-1\": \"Yes\",\n    \"4-2\": \"Barcode, perfect for event tickets.\",\n    \"4-3\": \"OS Notification character limit.\",\n    \"5-0\": \"Video\",\n    \"5-1\": \"Yes\",\n    \"5-2\": \"InApp video playback.\",\n    \"5-3\": \"OS Notification character limit.\",\n    \"6-0\": \"Sound\",\n    \"6-1\": \"No\",\n    \"6-2\": \"InApp sound playback\",\n    \"6-3\": \"None\",\n    \"7-0\": \"Tag (available only in Standard and Pro)\",\n    \"7-1\": \"No\",\n    \"7-2\": \"It's a virtual counter\",\n    \"7-3\": \"None\",\n    \"8-0\": \"Custom (available only in Standard and Pro)\",\n    \"8-1\": \"No\",\n    \"8-2\": \"Runs a callback function in your App's code\",\n    \"8-3\": \"None\"\n  },\n  \"cols\": 4,\n  \"rows\": 9\n}\n[/block]\nAfter choosing the type of Experience you want to deliver, we need to decide on what triggers the experience.\n\nThere are three different types of triggers:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Type\",\n    \"h-1\": \"Definition\",\n    \"0-0\": \"Place\",\n    \"0-1\": \"A place is a Geofence and it can be created in the \\\"Places\\\" option in the Moca console.\",\n    \"1-0\": \"Zone\",\n    \"1-1\": \"A zone is a group of beacons associated to a Place. You can add zones to any of your places.\",\n    \"2-0\": \"Beacon\",\n    \"2-1\": \"A beacon is, as its name implies, an actual beacon. These can be added independently or assigned to a zone.\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\nSince by default, each account comes with a Place pre-installed. Let's select place as the trigger. However, for this to work, remember to specify the location of your Place in the Place option.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/Djo4gLrcTtGaMQTXMhJR_Captura%20de%20pantalla%202015-09-23%20a%20las%2018.11.41.png\",\n        \"Captura de pantalla 2015-09-23 a las 18.11.41.png\",\n        \"1226\",\n        \"1112\",\n        \"#987166\",\n        \"\"\n      ],\n      \"caption\": \"Selecting Place as trigger\"\n    }\n  ]\n}\n[/block]\nAs you can see in the image above, after selecting \"Place\" as a trigger, we select \"On enter\" as the event of the trigger. This means that when a user enters the selected location the Experience should appear on his/her phone.\n\nFinally, after selecting the \"Place\" we want as a trigger, there are a few more settings for activating and setting a frequency for the Experience.\n\nWe'll leave it as it is:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/7sEBqDlRbmTzmukRXcLm_Captura%20de%20pantalla%202015-09-23%20a%20las%2018.15.12.png\",\n        \"Captura de pantalla 2015-09-23 a las 18.15.12.png\",\n        \"722\",\n        \"219\",\n        \"#9a6c5f\",\n        \"\"\n      ],\n      \"caption\": \"Experience extra settings\"\n    }\n  ]\n}\n[/block]\nThis means that, besides having the experience activated, if the user decides to stay near the trigger's area, the experience won't repeat itself for at least another 5min.\n\nAnd that's all. Once you're happy with the experience's settings, click the \"Save experience\" button and that'll take you back to the Experiences list, where you'll see your new and shiny experience ready for action!\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/Te5pyvUlRK2U5Qaegndh_Captura%20de%20pantalla%202015-09-23%20a%20las%2018.19.02.png\",\n        \"Captura de pantalla 2015-09-23 a las 18.19.02.png\",\n        \"1026\",\n        \"556\",\n        \"#688eb8\",\n        \"\"\n      ],\n      \"caption\": \"Experience List\"\n    }\n  ]\n}\n[/block]","createdAt":"2015-07-14T22:44:37.013Z","next":{"description":"","pages":[]},"order":0,"parentDoc":null,"slug":"moca-sdk-getting-started","api":{"settings":"","url":"","auth":"required","params":[],"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{}","name":""}]}},"user":"55a575ebaaf9cf1900114d73","sync_unique":"","type":"basic","hidden":false,"link_url":"","title":"Getting started with MOCA","__v":33,"githubsync":"","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Getting started with MOCA

This page will help you get started with MOCA. You'll be up and running in a jiffy!

There are a few important steps to get out of the way when integrating MOCA SDK with your iOS or Android app for the first time. Follow these instructions carefully to ensure that you will have a smooth development experience. We will take you through the basic technical steps for configuring Apple and MOCA services, show you how to add the first proximity-triggered experiences to your app and provide detailed examples and instructions for using advanced MOCA features. [block:embed] { "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F-PKE0Vrr3bw%3Ffeature%3Doembed&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D-PKE0Vrr3bw&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-PKE0Vrr3bw%2Fhqdefault.jpg&key=02466f963b9b4bb8845a05b53d3235d7&type=text%2Fhtml&schema=youtube\" width=\"854\" height=\"480\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "url": "https://www.youtube.com/watch?v=-PKE0Vrr3bw", "title": "Getting Started With MOCA - Proximity Marketing and iBeacon Platform", "favicon": "https://s.ytimg.com/yts/img/favicon-vflz7uhzw.ico", "image": "https://i.ytimg.com/vi/-PKE0Vrr3bw/hqdefault.jpg" } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/yTKMcnVdQPiF2cUtuX7Q_sdks.png", "sdks.png", "400", "160", "#e08e49", "" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "Production & Development Apps in MOCA" } [/block] When you create or edit an App in MOCA, you must select whether your app is **In development** or **In production** mode. When developing or testing your app, configure your app to *In development*. When submitting your app to AppStore, configure your app to *In production*. MOCA treats the two modes separately, we suggest making two apps in the MOCA Console. That way you can continue to build and develop your application even after releasing it without interrupting your users. [block:callout] { "type": "danger", "body": "Always create a Production Status MOCA app first and make sure your app code is pointing to the production app key. For more tips on what to check before you release your app, see [*Submitting Your App to the Store*](/docs/moca-ios-sdk-submitting-your-app-to-the-store) article." } [/block] [block:api-header] { "type": "basic", "title": "Creating your first Campaign and Experiences" } [/block] After adding your first app to your Moca account, you can start creating Campaigns and adding as many Proximity Experiences to them as you need. Start by selecting your app: [block:image] { "images": [ { "image": [ "https://files.readme.io/IcE6Yc1sRu2gcuL1JQRf_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.38.42.png", "Captura de pantalla 2015-09-23 a las 17.38.42.png", "1731", "727", "#df333b", "" ], "caption": "MocaApp for Testing" } ] } [/block] Then select campaign and click on "New campaign": [block:image] { "images": [ { "image": [ "https://files.readme.io/bvHYtw3qSWGqskBoM2nt_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.41.50.png", "Captura de pantalla 2015-09-23 a las 17.41.50.png", "1731", "679", "#55718f", "" ], "caption": "Campaign list" } ] } [/block] Choose a name for your Campaign, add a start date and an end date, and optionally add a description and choose a target (Standard and Pro versions only): [block:image] { "images": [ { "image": [ "https://files.readme.io/cLz21QrdRXiktEpiZl1Y_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.44.43.png", "Captura de pantalla 2015-09-23 a las 17.44.43.png", "467", "550", "#436b98", "" ], "caption": "Add Campaign View" } ] } [/block] Now you'll see your new Campaign listed in your Campaigns' list. When ready remember to click the "Start" button to initiate the Campaign, otherwise your users won't receive any Proximity Experiences. [block:image] { "images": [ { "image": [ "https://files.readme.io/N8EuWC41QoWi5AYLtx9U_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.46.25.png", "Captura de pantalla 2015-09-23 a las 17.46.25.png", "1497", "349", "#527da7", "" ], "caption": "Campaign List" } ] } [/block] Now let's add our first experience. Click on the campaign name and then click on the "New experience" button on the upper right corner. [block:image] { "images": [ { "image": [ "https://files.readme.io/1MKnruM6ScKPJ1tOKg1w_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.46.25.png", "Captura de pantalla 2015-09-23 a las 17.46.25.png", "1497", "349", "#527da7", "" ], "caption": "Campaign List" } ] } [/block] This will take you to the Proximity Experience editor. [block:image] { "images": [ { "image": [ "https://files.readme.io/sgo9kiCGRGpetCVsT90z_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.51.25.png", "Captura de pantalla 2015-09-23 a las 17.51.25.png", "1487", "1164", "#906c64", "" ], "caption": "Moca Proximity Experience Editor" } ] } [/block] There are several types of Experiences you can create, each for a different purpose. They can be classified by their in-app action and whether they have a Notification Message in the device's notification center. [block:parameters] { "data": { "h-0": "Type", "h-1": "Notification Message", "h-2": "InApp Action", "h-3": "Limits", "0-0": "Message", "0-1": "Yes", "0-2": "None", "0-3": "OS Notification character limit.", "1-0": "Image", "1-1": "Yes", "1-2": "An Image", "1-3": "OS Notification character limit.", "2-0": "URL", "2-1": "Yes", "2-2": "A URL to a website", "2-3": "OS Notification character limit.", "3-0": "HTML", "3-1": "Yes", "3-2": "InApp rendered HTML", "3-3": "OS Notification character limit.\n\nmax. 50KB of HTML code", "4-0": "Card", "4-1": "Yes", "4-2": "Barcode, perfect for event tickets.", "4-3": "OS Notification character limit.", "5-0": "Video", "5-1": "Yes", "5-2": "InApp video playback.", "5-3": "OS Notification character limit.", "6-0": "Sound", "6-1": "No", "6-2": "InApp sound playback", "6-3": "None", "7-0": "Tag (available only in Standard and Pro)", "7-1": "No", "7-2": "It's a virtual counter", "7-3": "None", "8-0": "Custom (available only in Standard and Pro)", "8-1": "No", "8-2": "Runs a callback function in your App's code", "8-3": "None" }, "cols": 4, "rows": 9 } [/block] After choosing the type of Experience you want to deliver, we need to decide on what triggers the experience. There are three different types of triggers: [block:parameters] { "data": { "h-0": "Type", "h-1": "Definition", "0-0": "Place", "0-1": "A place is a Geofence and it can be created in the \"Places\" option in the Moca console.", "1-0": "Zone", "1-1": "A zone is a group of beacons associated to a Place. You can add zones to any of your places.", "2-0": "Beacon", "2-1": "A beacon is, as its name implies, an actual beacon. These can be added independently or assigned to a zone." }, "cols": 2, "rows": 3 } [/block] Since by default, each account comes with a Place pre-installed. Let's select place as the trigger. However, for this to work, remember to specify the location of your Place in the Place option. [block:image] { "images": [ { "image": [ "https://files.readme.io/Djo4gLrcTtGaMQTXMhJR_Captura%20de%20pantalla%202015-09-23%20a%20las%2018.11.41.png", "Captura de pantalla 2015-09-23 a las 18.11.41.png", "1226", "1112", "#987166", "" ], "caption": "Selecting Place as trigger" } ] } [/block] As you can see in the image above, after selecting "Place" as a trigger, we select "On enter" as the event of the trigger. This means that when a user enters the selected location the Experience should appear on his/her phone. Finally, after selecting the "Place" we want as a trigger, there are a few more settings for activating and setting a frequency for the Experience. We'll leave it as it is: [block:image] { "images": [ { "image": [ "https://files.readme.io/7sEBqDlRbmTzmukRXcLm_Captura%20de%20pantalla%202015-09-23%20a%20las%2018.15.12.png", "Captura de pantalla 2015-09-23 a las 18.15.12.png", "722", "219", "#9a6c5f", "" ], "caption": "Experience extra settings" } ] } [/block] This means that, besides having the experience activated, if the user decides to stay near the trigger's area, the experience won't repeat itself for at least another 5min. And that's all. Once you're happy with the experience's settings, click the "Save experience" button and that'll take you back to the Experiences list, where you'll see your new and shiny experience ready for action! [block:image] { "images": [ { "image": [ "https://files.readme.io/Te5pyvUlRK2U5Qaegndh_Captura%20de%20pantalla%202015-09-23%20a%20las%2018.19.02.png", "Captura de pantalla 2015-09-23 a las 18.19.02.png", "1026", "556", "#688eb8", "" ], "caption": "Experience List" } ] } [/block]
There are a few important steps to get out of the way when integrating MOCA SDK with your iOS or Android app for the first time. Follow these instructions carefully to ensure that you will have a smooth development experience. We will take you through the basic technical steps for configuring Apple and MOCA services, show you how to add the first proximity-triggered experiences to your app and provide detailed examples and instructions for using advanced MOCA features. [block:embed] { "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F-PKE0Vrr3bw%3Ffeature%3Doembed&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D-PKE0Vrr3bw&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-PKE0Vrr3bw%2Fhqdefault.jpg&key=02466f963b9b4bb8845a05b53d3235d7&type=text%2Fhtml&schema=youtube\" width=\"854\" height=\"480\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "url": "https://www.youtube.com/watch?v=-PKE0Vrr3bw", "title": "Getting Started With MOCA - Proximity Marketing and iBeacon Platform", "favicon": "https://s.ytimg.com/yts/img/favicon-vflz7uhzw.ico", "image": "https://i.ytimg.com/vi/-PKE0Vrr3bw/hqdefault.jpg" } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/yTKMcnVdQPiF2cUtuX7Q_sdks.png", "sdks.png", "400", "160", "#e08e49", "" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "Production & Development Apps in MOCA" } [/block] When you create or edit an App in MOCA, you must select whether your app is **In development** or **In production** mode. When developing or testing your app, configure your app to *In development*. When submitting your app to AppStore, configure your app to *In production*. MOCA treats the two modes separately, we suggest making two apps in the MOCA Console. That way you can continue to build and develop your application even after releasing it without interrupting your users. [block:callout] { "type": "danger", "body": "Always create a Production Status MOCA app first and make sure your app code is pointing to the production app key. For more tips on what to check before you release your app, see [*Submitting Your App to the Store*](/docs/moca-ios-sdk-submitting-your-app-to-the-store) article." } [/block] [block:api-header] { "type": "basic", "title": "Creating your first Campaign and Experiences" } [/block] After adding your first app to your Moca account, you can start creating Campaigns and adding as many Proximity Experiences to them as you need. Start by selecting your app: [block:image] { "images": [ { "image": [ "https://files.readme.io/IcE6Yc1sRu2gcuL1JQRf_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.38.42.png", "Captura de pantalla 2015-09-23 a las 17.38.42.png", "1731", "727", "#df333b", "" ], "caption": "MocaApp for Testing" } ] } [/block] Then select campaign and click on "New campaign": [block:image] { "images": [ { "image": [ "https://files.readme.io/bvHYtw3qSWGqskBoM2nt_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.41.50.png", "Captura de pantalla 2015-09-23 a las 17.41.50.png", "1731", "679", "#55718f", "" ], "caption": "Campaign list" } ] } [/block] Choose a name for your Campaign, add a start date and an end date, and optionally add a description and choose a target (Standard and Pro versions only): [block:image] { "images": [ { "image": [ "https://files.readme.io/cLz21QrdRXiktEpiZl1Y_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.44.43.png", "Captura de pantalla 2015-09-23 a las 17.44.43.png", "467", "550", "#436b98", "" ], "caption": "Add Campaign View" } ] } [/block] Now you'll see your new Campaign listed in your Campaigns' list. When ready remember to click the "Start" button to initiate the Campaign, otherwise your users won't receive any Proximity Experiences. [block:image] { "images": [ { "image": [ "https://files.readme.io/N8EuWC41QoWi5AYLtx9U_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.46.25.png", "Captura de pantalla 2015-09-23 a las 17.46.25.png", "1497", "349", "#527da7", "" ], "caption": "Campaign List" } ] } [/block] Now let's add our first experience. Click on the campaign name and then click on the "New experience" button on the upper right corner. [block:image] { "images": [ { "image": [ "https://files.readme.io/1MKnruM6ScKPJ1tOKg1w_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.46.25.png", "Captura de pantalla 2015-09-23 a las 17.46.25.png", "1497", "349", "#527da7", "" ], "caption": "Campaign List" } ] } [/block] This will take you to the Proximity Experience editor. [block:image] { "images": [ { "image": [ "https://files.readme.io/sgo9kiCGRGpetCVsT90z_Captura%20de%20pantalla%202015-09-23%20a%20las%2017.51.25.png", "Captura de pantalla 2015-09-23 a las 17.51.25.png", "1487", "1164", "#906c64", "" ], "caption": "Moca Proximity Experience Editor" } ] } [/block] There are several types of Experiences you can create, each for a different purpose. They can be classified by their in-app action and whether they have a Notification Message in the device's notification center. [block:parameters] { "data": { "h-0": "Type", "h-1": "Notification Message", "h-2": "InApp Action", "h-3": "Limits", "0-0": "Message", "0-1": "Yes", "0-2": "None", "0-3": "OS Notification character limit.", "1-0": "Image", "1-1": "Yes", "1-2": "An Image", "1-3": "OS Notification character limit.", "2-0": "URL", "2-1": "Yes", "2-2": "A URL to a website", "2-3": "OS Notification character limit.", "3-0": "HTML", "3-1": "Yes", "3-2": "InApp rendered HTML", "3-3": "OS Notification character limit.\n\nmax. 50KB of HTML code", "4-0": "Card", "4-1": "Yes", "4-2": "Barcode, perfect for event tickets.", "4-3": "OS Notification character limit.", "5-0": "Video", "5-1": "Yes", "5-2": "InApp video playback.", "5-3": "OS Notification character limit.", "6-0": "Sound", "6-1": "No", "6-2": "InApp sound playback", "6-3": "None", "7-0": "Tag (available only in Standard and Pro)", "7-1": "No", "7-2": "It's a virtual counter", "7-3": "None", "8-0": "Custom (available only in Standard and Pro)", "8-1": "No", "8-2": "Runs a callback function in your App's code", "8-3": "None" }, "cols": 4, "rows": 9 } [/block] After choosing the type of Experience you want to deliver, we need to decide on what triggers the experience. There are three different types of triggers: [block:parameters] { "data": { "h-0": "Type", "h-1": "Definition", "0-0": "Place", "0-1": "A place is a Geofence and it can be created in the \"Places\" option in the Moca console.", "1-0": "Zone", "1-1": "A zone is a group of beacons associated to a Place. You can add zones to any of your places.", "2-0": "Beacon", "2-1": "A beacon is, as its name implies, an actual beacon. These can be added independently or assigned to a zone." }, "cols": 2, "rows": 3 } [/block] Since by default, each account comes with a Place pre-installed. Let's select place as the trigger. However, for this to work, remember to specify the location of your Place in the Place option. [block:image] { "images": [ { "image": [ "https://files.readme.io/Djo4gLrcTtGaMQTXMhJR_Captura%20de%20pantalla%202015-09-23%20a%20las%2018.11.41.png", "Captura de pantalla 2015-09-23 a las 18.11.41.png", "1226", "1112", "#987166", "" ], "caption": "Selecting Place as trigger" } ] } [/block] As you can see in the image above, after selecting "Place" as a trigger, we select "On enter" as the event of the trigger. This means that when a user enters the selected location the Experience should appear on his/her phone. Finally, after selecting the "Place" we want as a trigger, there are a few more settings for activating and setting a frequency for the Experience. We'll leave it as it is: [block:image] { "images": [ { "image": [ "https://files.readme.io/7sEBqDlRbmTzmukRXcLm_Captura%20de%20pantalla%202015-09-23%20a%20las%2018.15.12.png", "Captura de pantalla 2015-09-23 a las 18.15.12.png", "722", "219", "#9a6c5f", "" ], "caption": "Experience extra settings" } ] } [/block] This means that, besides having the experience activated, if the user decides to stay near the trigger's area, the experience won't repeat itself for at least another 5min. And that's all. Once you're happy with the experience's settings, click the "Save experience" button and that'll take you back to the Experiences list, where you'll see your new and shiny experience ready for action! [block:image] { "images": [ { "image": [ "https://files.readme.io/Te5pyvUlRK2U5Qaegndh_Captura%20de%20pantalla%202015-09-23%20a%20las%2018.19.02.png", "Captura de pantalla 2015-09-23 a las 18.19.02.png", "1026", "556", "#688eb8", "" ], "caption": "Experience List" } ] } [/block]
{"_id":"55a8d4c8cf45e1390093f1bf","body":"The MOCA SDKs lets you turn your mobile app into a powerful marketing tool. You can effortlessly add Bluetooth Beacons and geolocation driven proximity experiences to your iOS and Android apps, observe your audience with MOCA analytics and engage your users with proximity campaigns. The SDK enables you to quickly connect to MOCA backend platform, deploy beacon campaigns from the cloud, and enrich user experience with location and proximity context.  \n\nThe MOCA SDK for iOS and Android are drop-in, native libraries that provide a simple way to integrate MOCA platform services into your iOS and Android apps. Each SDK is provided as a ZIP archive and contains pre-compiled binaries for each architecture. MOCA iOS SDK supports iOS 7 and 8+ while Android SDK version is compatible with Android 4.0+.","excerpt":"","isReference":false,"parentDoc":null,"project":"559a61d2dbcfd20d00710b39","api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":"","auth":"required","params":[]},"title":"What is MOCA SDK?","updates":[],"version":"559a61d2dbcfd20d00710b3c","createdAt":"2015-07-17T10:11:20.731Z","githubsync":"","hidden":false,"link_url":"","sync_unique":"","user":"559a618bdbcfd20d00710b38","category":"559a61d3dbcfd20d00710b3d","link_external":false,"order":1,"slug":"what-is-moca-sdk","type":"basic","__v":4,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

What is MOCA SDK?


The MOCA SDKs lets you turn your mobile app into a powerful marketing tool. You can effortlessly add Bluetooth Beacons and geolocation driven proximity experiences to your iOS and Android apps, observe your audience with MOCA analytics and engage your users with proximity campaigns. The SDK enables you to quickly connect to MOCA backend platform, deploy beacon campaigns from the cloud, and enrich user experience with location and proximity context. The MOCA SDK for iOS and Android are drop-in, native libraries that provide a simple way to integrate MOCA platform services into your iOS and Android apps. Each SDK is provided as a ZIP archive and contains pre-compiled binaries for each architecture. MOCA iOS SDK supports iOS 7 and 8+ while Android SDK version is compatible with Android 4.0+.
The MOCA SDKs lets you turn your mobile app into a powerful marketing tool. You can effortlessly add Bluetooth Beacons and geolocation driven proximity experiences to your iOS and Android apps, observe your audience with MOCA analytics and engage your users with proximity campaigns. The SDK enables you to quickly connect to MOCA backend platform, deploy beacon campaigns from the cloud, and enrich user experience with location and proximity context. The MOCA SDK for iOS and Android are drop-in, native libraries that provide a simple way to integrate MOCA platform services into your iOS and Android apps. Each SDK is provided as a ZIP archive and contains pre-compiled binaries for each architecture. MOCA iOS SDK supports iOS 7 and 8+ while Android SDK version is compatible with Android 4.0+.
{"_id":"55a8d4fd27a17d2100525155","category":"559a61d3dbcfd20d00710b3d","user":"559a618bdbcfd20d00710b38","api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","auth":"required","params":[],"url":""},"body":"The MOCA SDK is targeted to mobile app developers willing to add iBeacon-awareness, geofence-tracking and analytics to their apps and deploy proximity-triggered experiences to mobile users. It is also targeted to developers that need to learn behavioral data from their apps in order to better profile their mobile audience.","createdAt":"2015-07-17T10:12:13.612Z","excerpt":"","githubsync":"","isReference":false,"link_external":false,"project":"559a61d2dbcfd20d00710b39","slug":"who-is-moca-sdk-for","sync_unique":"","title":"Who is MOCA SDK for?","__v":0,"hidden":false,"order":2,"link_url":"","parentDoc":null,"type":"basic","updates":[],"version":"559a61d2dbcfd20d00710b3c","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Who is MOCA SDK for?


The MOCA SDK is targeted to mobile app developers willing to add iBeacon-awareness, geofence-tracking and analytics to their apps and deploy proximity-triggered experiences to mobile users. It is also targeted to developers that need to learn behavioral data from their apps in order to better profile their mobile audience.
The MOCA SDK is targeted to mobile app developers willing to add iBeacon-awareness, geofence-tracking and analytics to their apps and deploy proximity-triggered experiences to mobile users. It is also targeted to developers that need to learn behavioral data from their apps in order to better profile their mobile audience.
{"_id":"55a8d51cc8bd450d000dd09e","user":"559a618bdbcfd20d00710b38","__v":1,"body":"The MOCA SDK brings the following key features to your app:\n\n**Context-awareness (Beacons & Geofences)**\n\n- Automatically detect beacon sensors configured in your beacon registry in MOCA cloud\n- Automatically fetch and deploy proximity campaigns from the cloud \n- Enrich user experience by delivering actions when geofence, proximity and other complex trigger conditions are met\n- Supported triggers include:\n     - *Enter place (geofence or beacon)*\n     - *Exit place (geofence or beacon)* \n     - *Enter zone* \n     - *Exit zone*\n     - *Enter beacon range with specific proximity (Immediate, Near, Far)*\n     - *Exit beacon range* \n     - *Custom trigger (via app provided delegate callback)*\n- Supported action types include:\n  - *Display local push notification message (both in Foreground and Background)*\n  - *Show full screen HTML5 creativity offline*\n  - *Play video from URL*\n  - *Show image from URL*\n  - *Show HTML content from URL*\n  - *Show PassBook card*\n  - *Play sound*\n  - *Custom action (via app provided delegate callback)*\n- Action delivery is handled in foreground and background modes. All content types are delivered as local push notification messages when in background. \n- Offline proximity campaigns (beacon interactions are active even if Internet connectivity is not available)\n\n**Analytics**\n- Automatically track the device properties, app usage, frequent locations, and iBeacon and location related events\n- Track and store any custom, in-app events from your app\n- Store all tracked events locally, and transmit them to the cloud when Internet connectivity (Edge, 3G, 4G, Wifi) is available. \n- Send all data to the Big Data platform for further processing and analysis.\n- App can fully customize tracking policy \n- MOCA does not collect sensitive user data and enforces privacy protection and legal data protection policies \n\n**Push Notifications**\n- The MOCA SDK lets you easily subscribe and use Apple Push Notification Service (APNS) and Google Cloud Messaging (GCM) in your app. Enable the automatic push service setup, and the SDK will register push tokens in the cloud allowing you to communicate with your mobile app users.\n- Deliver push notifications only when specific conditions are met (real-time, context-aware segmentation)\n- Track push notifications and analyze their effectiveness in the cloud.","parentDoc":null,"project":"559a61d2dbcfd20d00710b39","version":"559a61d2dbcfd20d00710b3c","githubsync":"","link_external":false,"link_url":"","slug":"key-features","type":"basic","api":{"results":{"codes":[{"name":"","status":200,"language":"json","code":"{}"},{"language":"json","code":"{}","name":"","status":400}]},"settings":"","auth":"required","params":[],"url":""},"category":"559a61d3dbcfd20d00710b3d","order":3,"sync_unique":"","isReference":false,"title":"Key Features","updates":["55b0a3ace7abe62300f9a86f"],"createdAt":"2015-07-17T10:12:44.249Z","excerpt":"","hidden":false,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Key Features


The MOCA SDK brings the following key features to your app: **Context-awareness (Beacons & Geofences)** - Automatically detect beacon sensors configured in your beacon registry in MOCA cloud - Automatically fetch and deploy proximity campaigns from the cloud - Enrich user experience by delivering actions when geofence, proximity and other complex trigger conditions are met - Supported triggers include: - *Enter place (geofence or beacon)* - *Exit place (geofence or beacon)* - *Enter zone* - *Exit zone* - *Enter beacon range with specific proximity (Immediate, Near, Far)* - *Exit beacon range* - *Custom trigger (via app provided delegate callback)* - Supported action types include: - *Display local push notification message (both in Foreground and Background)* - *Show full screen HTML5 creativity offline* - *Play video from URL* - *Show image from URL* - *Show HTML content from URL* - *Show PassBook card* - *Play sound* - *Custom action (via app provided delegate callback)* - Action delivery is handled in foreground and background modes. All content types are delivered as local push notification messages when in background. - Offline proximity campaigns (beacon interactions are active even if Internet connectivity is not available) **Analytics** - Automatically track the device properties, app usage, frequent locations, and iBeacon and location related events - Track and store any custom, in-app events from your app - Store all tracked events locally, and transmit them to the cloud when Internet connectivity (Edge, 3G, 4G, Wifi) is available. - Send all data to the Big Data platform for further processing and analysis. - App can fully customize tracking policy - MOCA does not collect sensitive user data and enforces privacy protection and legal data protection policies **Push Notifications** - The MOCA SDK lets you easily subscribe and use Apple Push Notification Service (APNS) and Google Cloud Messaging (GCM) in your app. Enable the automatic push service setup, and the SDK will register push tokens in the cloud allowing you to communicate with your mobile app users. - Deliver push notifications only when specific conditions are met (real-time, context-aware segmentation) - Track push notifications and analyze their effectiveness in the cloud.
The MOCA SDK brings the following key features to your app: **Context-awareness (Beacons & Geofences)** - Automatically detect beacon sensors configured in your beacon registry in MOCA cloud - Automatically fetch and deploy proximity campaigns from the cloud - Enrich user experience by delivering actions when geofence, proximity and other complex trigger conditions are met - Supported triggers include: - *Enter place (geofence or beacon)* - *Exit place (geofence or beacon)* - *Enter zone* - *Exit zone* - *Enter beacon range with specific proximity (Immediate, Near, Far)* - *Exit beacon range* - *Custom trigger (via app provided delegate callback)* - Supported action types include: - *Display local push notification message (both in Foreground and Background)* - *Show full screen HTML5 creativity offline* - *Play video from URL* - *Show image from URL* - *Show HTML content from URL* - *Show PassBook card* - *Play sound* - *Custom action (via app provided delegate callback)* - Action delivery is handled in foreground and background modes. All content types are delivered as local push notification messages when in background. - Offline proximity campaigns (beacon interactions are active even if Internet connectivity is not available) **Analytics** - Automatically track the device properties, app usage, frequent locations, and iBeacon and location related events - Track and store any custom, in-app events from your app - Store all tracked events locally, and transmit them to the cloud when Internet connectivity (Edge, 3G, 4G, Wifi) is available. - Send all data to the Big Data platform for further processing and analysis. - App can fully customize tracking policy - MOCA does not collect sensitive user data and enforces privacy protection and legal data protection policies **Push Notifications** - The MOCA SDK lets you easily subscribe and use Apple Push Notification Service (APNS) and Google Cloud Messaging (GCM) in your app. Enable the automatic push service setup, and the SDK will register push tokens in the cloud allowing you to communicate with your mobile app users. - Deliver push notifications only when specific conditions are met (real-time, context-aware segmentation) - Track push notifications and analyze their effectiveness in the cloud.
{"_id":"55a5a5cb80c8a30d00b32448","api":{"url":"","auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":""},"category":"559a61d3dbcfd20d00710b3d","githubsync":"","isReference":false,"order":4,"updates":[],"body":"[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/3OvC5cj7Rna5HgfMDnyz_Arch.png\",\n        \"Arch.png\",\n        \"925\",\n        \"638\",\n        \"#399ed8\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]","title":"SDK Architecture","version":"559a61d2dbcfd20d00710b3c","hidden":false,"link_external":false,"parentDoc":null,"project":"559a61d2dbcfd20d00710b39","sync_unique":"","type":"basic","__v":9,"createdAt":"2015-07-15T00:14:03.104Z","excerpt":"","link_url":"","slug":"moca-ios-sdk-overview","user":"55a575ebaaf9cf1900114d73","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

SDK Architecture


[block:image] { "images": [ { "image": [ "https://files.readme.io/3OvC5cj7Rna5HgfMDnyz_Arch.png", "Arch.png", "925", "638", "#399ed8", "" ] } ] } [/block]
[block:image] { "images": [ { "image": [ "https://files.readme.io/3OvC5cj7Rna5HgfMDnyz_Arch.png", "Arch.png", "925", "638", "#399ed8", "" ] } ] } [/block]
{"_id":"55a9118c27a17d210052523b","version":"559a61d2dbcfd20d00710b3c","body":"[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/OBeZ40yMSfmQpOsfw5nu_geo-location.png\",\n        \"geo-location.png\",\n        \"1177\",\n        \"731\",\n        \"#8464a3\",\n        \"\"\n      ],\n      \"caption\": \"Geo-location\"\n    }\n  ]\n}\n[/block]","excerpt":"","hidden":false,"order":5,"project":"559a61d2dbcfd20d00710b39","updates":[],"api":{"url":"","results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","auth":"required","params":[]},"createdAt":"2015-07-17T14:30:36.614Z","link_external":false,"__v":0,"link_url":"","parentDoc":null,"slug":"how-geo-location-tracking-works","type":"basic","category":"559a61d3dbcfd20d00710b3d","githubsync":"","isReference":false,"sync_unique":"","title":"How geo-location tracking works?","user":"559a618bdbcfd20d00710b38","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

How geo-location tracking works?


[block:image] { "images": [ { "image": [ "https://files.readme.io/OBeZ40yMSfmQpOsfw5nu_geo-location.png", "geo-location.png", "1177", "731", "#8464a3", "" ], "caption": "Geo-location" } ] } [/block]
[block:image] { "images": [ { "image": [ "https://files.readme.io/OBeZ40yMSfmQpOsfw5nu_geo-location.png", "geo-location.png", "1177", "731", "#8464a3", "" ], "caption": "Geo-location" } ] } [/block]
{"_id":"565dbeaa94f30d0d00d1f37c","category":"559a61d3dbcfd20d00710b3d","slug":"beacon-distances","version":"559a61d2dbcfd20d00710b3c","project":"559a61d2dbcfd20d00710b39","updates":["565dc4ad65242f0d00d93294"],"api":{"auth":"required","params":[],"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"createdAt":"2015-12-01T15:37:14.118Z","githubsync":"","isReference":false,"link_url":"","order":6,"user":"55a61860249a40190051d941","link_external":false,"parentDoc":null,"sync_unique":"","title":"Beacon Distances","type":"basic","__v":2,"body":"These are approximations of the distances MOCA's sdk detects between a phone and a beacon. The distances may vary depending on the obstacles near the beacon which absorb part of the signal. \n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Event\",\n    \"h-1\": \"Distance\",\n    \"0-0\": \"On Immediate\",\n    \"0-1\": \"Between 0m and 0.5m\",\n    \"1-0\": \"On Near\",\n    \"1-1\": \"Between 0.5 and 10m\",\n    \"2-0\": \"On Far\",\n    \"2-1\": \"More than 10m\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"RSSI vs Distance\",\n  \"body\": \"MOCA's SDK converts the beacon's signal intensity or RSSI into distances, but these are purely approximate and may vary greatly from device, beacon and environment.\"\n}\n[/block]","excerpt":"","hidden":false,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Beacon Distances


These are approximations of the distances MOCA's sdk detects between a phone and a beacon. The distances may vary depending on the obstacles near the beacon which absorb part of the signal. [block:parameters] { "data": { "h-0": "Event", "h-1": "Distance", "0-0": "On Immediate", "0-1": "Between 0m and 0.5m", "1-0": "On Near", "1-1": "Between 0.5 and 10m", "2-0": "On Far", "2-1": "More than 10m" }, "cols": 2, "rows": 3 } [/block] [block:callout] { "type": "info", "title": "RSSI vs Distance", "body": "MOCA's SDK converts the beacon's signal intensity or RSSI into distances, but these are purely approximate and may vary greatly from device, beacon and environment." } [/block]
These are approximations of the distances MOCA's sdk detects between a phone and a beacon. The distances may vary depending on the obstacles near the beacon which absorb part of the signal. [block:parameters] { "data": { "h-0": "Event", "h-1": "Distance", "0-0": "On Immediate", "0-1": "Between 0m and 0.5m", "1-0": "On Near", "1-1": "Between 0.5 and 10m", "2-0": "On Far", "2-1": "More than 10m" }, "cols": 2, "rows": 3 } [/block] [block:callout] { "type": "info", "title": "RSSI vs Distance", "body": "MOCA's SDK converts the beacon's signal intensity or RSSI into distances, but these are purely approximate and may vary greatly from device, beacon and environment." } [/block]
{"_id":"569e599efbee990d0072d912","type":"basic","updates":[],"version":"559a61d2dbcfd20d00710b3c","hidden":false,"link_url":"","project":"559a61d2dbcfd20d00710b39","sync_unique":"","__v":0,"api":{"params":[],"url":"","results":{"codes":[{"name":"","status":200,"language":"json","code":"{}"},{"language":"json","code":"{}","name":"","status":400}]},"settings":"","auth":"required"},"excerpt":"","isReference":false,"slug":"proximity-guidelines-how-to-maximize-detections","title":"Proximity guidelines: How to maximize detections","user":"559a618bdbcfd20d00710b38","body":"##Geofences\n\nMobile phones use a combination of sensors to estimate current position, depending on its availability. Specifically:\n\n- GPS\n- Wi-Fi\n- Cellular networks\n- Bluetooth\n\n###GPS \n\nMOCA SDK does not use GPS directly, as this is a high battery consuming resource and it does not work indoors.\n\n###Wi-Fi \n\nThis is is the main source of data that mobile devices use to calculate its position. Error margin is about 20 - 50 meters (65 -165 feet), is very fast and it is battery friendly. \nThis technique does not require the device to be connected to a Wi-Fi network, by having the Wi-Fi chip enabled, mobile phone is able to fetch nearby Wi-Fi networks and estimate its position.\n\n###Cellular networks\n\nIn locations where there are no Wi-Fi networks (e.g. rural areas), mobile devices rely on information relative to the nearby cell towers to determine its position. This is a battery friendly method, but does its precision is low. For example in Android:\n\n>When Wi-Fi location is not available (for example, when you are driving in rural areas) the location accuracy degrades. The accuracy range can be as large as several hundred meters to several kilometers. In cases like this, you should create geofences using a larger radius.\n\n- In order to maximize detections, create geofences with a minimum radius of 100m\n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/k7f2w6MGSHKGBfwfZhJY_Captura%20de%20pantalla%202016-01-19%20a%20las%2016.38.41.png\",\n        \"Captura de pantalla 2016-01-19 a las 16.38.41.png\",\n        \"1142\",\n        \"1015\",\n        \"#b33d3a\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]","category":"559a61d3dbcfd20d00710b3d","link_external":false,"parentDoc":null,"createdAt":"2016-01-19T15:43:26.383Z","githubsync":"","order":7,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Proximity guidelines: How to maximize detections


##Geofences Mobile phones use a combination of sensors to estimate current position, depending on its availability. Specifically: - GPS - Wi-Fi - Cellular networks - Bluetooth ###GPS MOCA SDK does not use GPS directly, as this is a high battery consuming resource and it does not work indoors. ###Wi-Fi This is is the main source of data that mobile devices use to calculate its position. Error margin is about 20 - 50 meters (65 -165 feet), is very fast and it is battery friendly. This technique does not require the device to be connected to a Wi-Fi network, by having the Wi-Fi chip enabled, mobile phone is able to fetch nearby Wi-Fi networks and estimate its position. ###Cellular networks In locations where there are no Wi-Fi networks (e.g. rural areas), mobile devices rely on information relative to the nearby cell towers to determine its position. This is a battery friendly method, but does its precision is low. For example in Android: >When Wi-Fi location is not available (for example, when you are driving in rural areas) the location accuracy degrades. The accuracy range can be as large as several hundred meters to several kilometers. In cases like this, you should create geofences using a larger radius. - In order to maximize detections, create geofences with a minimum radius of 100m [block:image] { "images": [ { "image": [ "https://files.readme.io/k7f2w6MGSHKGBfwfZhJY_Captura%20de%20pantalla%202016-01-19%20a%20las%2016.38.41.png", "Captura de pantalla 2016-01-19 a las 16.38.41.png", "1142", "1015", "#b33d3a", "" ] } ] } [/block]
##Geofences Mobile phones use a combination of sensors to estimate current position, depending on its availability. Specifically: - GPS - Wi-Fi - Cellular networks - Bluetooth ###GPS MOCA SDK does not use GPS directly, as this is a high battery consuming resource and it does not work indoors. ###Wi-Fi This is is the main source of data that mobile devices use to calculate its position. Error margin is about 20 - 50 meters (65 -165 feet), is very fast and it is battery friendly. This technique does not require the device to be connected to a Wi-Fi network, by having the Wi-Fi chip enabled, mobile phone is able to fetch nearby Wi-Fi networks and estimate its position. ###Cellular networks In locations where there are no Wi-Fi networks (e.g. rural areas), mobile devices rely on information relative to the nearby cell towers to determine its position. This is a battery friendly method, but does its precision is low. For example in Android: >When Wi-Fi location is not available (for example, when you are driving in rural areas) the location accuracy degrades. The accuracy range can be as large as several hundred meters to several kilometers. In cases like this, you should create geofences using a larger radius. - In order to maximize detections, create geofences with a minimum radius of 100m [block:image] { "images": [ { "image": [ "https://files.readme.io/k7f2w6MGSHKGBfwfZhJY_Captura%20de%20pantalla%202016-01-19%20a%20las%2016.38.41.png", "Captura de pantalla 2016-01-19 a las 16.38.41.png", "1142", "1015", "#b33d3a", "" ] } ] } [/block]
{"_id":"5703d2dda7472a0e00b6dd7f","createdAt":"2016-04-05T14:59:41.499Z","isReference":false,"link_url":"","order":8,"project":"559a61d2dbcfd20d00710b39","title":"Downloads","user":"559a618bdbcfd20d00710b38","__v":11,"excerpt":"","link_external":false,"version":"559a61d2dbcfd20d00710b3c","category":"559a61d3dbcfd20d00710b3d","parentDoc":null,"type":"basic","hidden":false,"api":{"results":{"codes":[{"language":"json","code":"{}","name":"","status":200},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":"","auth":"required","params":[]},"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"iOS\"\n}\n[/block]\n##iOS SDK\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/zyvbx4ZYSFmmooGPY6PZ_ios-sdk.png\",\n        \"ios-sdk.png\",\n        \"175\",\n        \"181\",\n        \"#e88a4a\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n##[Download latest version  (03/06/2016) **(v.1.9.6)**](http://files.mocaplatform.com/releases/moca-ios-sdk-latest.zip)\n[Installation Guide](../docs/moca-ios-sdk-setup)\n\n###Archive\n\n- [ **(v.1.9.5)**](http://files.mocaplatform.com/releases/moca-ios-sdk-1.9.5.zip)\n- [ **(v.1.9.4)**](http://files.mocaplatform.com/releases/moca-ios-sdk-1.9.4.zip)\n- [ **(v.1.7.0)**](http://files.mocaplatform.com/releases/moca-ios-sdk-1.7.0.zip)\n- [ **(v.1.6.8)**](http://files.mocaplatform.com/releases/moca-ios-sdk-1.6.8.zip)\n\n##iOS Sample App\n\n[Download](http://files.mocaplatform.com/releases/sample-apps/MOCA-iOS-Sample-1.9.6.zip)\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Android\"\n}\n[/block]\n##Android SDK\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/Ffak3n3QdSBh9h49XHA1_android-sdk.png\",\n        \"android-sdk.png\",\n        \"182\",\n        \"180\",\n        \"#e6884a\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n##[Download latest version (11/11/2016) **(v.1.9.6)**](http://files.mocaplatform.com/releases/moca-android-sdk-latest.zip)\n[Installation Guide](../docs/moca-android-sdk-installation)\n\n###Archive\n- [**(v.1.9.5)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.5.zip) \n- [**(v.1.9.4)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.4.zip) \n- [**(v.1.9.3)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.3.zip) \n- [**(v.1.9.2)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.2.zip) \n- [**(v.1.9.1)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.1.zip) \n- [**(v.1.9.0)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.0.zip) \n- [**(v.1.8.11)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.8.11.zip) \n\n\n##Android Sample App\n\n[Download](http://files.mocaplatform.com/releases/sample-apps/MOCA-Android-Sample-1.9.1.zip)\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Cordova Plugin\"\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/g4PuBoQTAeJBBWjGNLuQ_cordova-sdk-box.png\",\n        \"cordova-sdk-box.png\",\n        \"175\",\n        \"169\",\n        \"#ea8634\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n##Available on GitHub\n[Click here to read the installation instructions](../docs/moca-ios-sdk-setup)","githubsync":"","next":{"description":"","pages":[]},"slug":"downloads","sync_unique":"","updates":[],"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Downloads


[block:api-header] { "type": "basic", "title": "iOS" } [/block] ##iOS SDK [block:image] { "images": [ { "image": [ "https://files.readme.io/zyvbx4ZYSFmmooGPY6PZ_ios-sdk.png", "ios-sdk.png", "175", "181", "#e88a4a", "" ] } ] } [/block] ##[Download latest version (03/06/2016) **(v.1.9.6)**](http://files.mocaplatform.com/releases/moca-ios-sdk-latest.zip) [Installation Guide](../docs/moca-ios-sdk-setup) ###Archive - [ **(v.1.9.5)**](http://files.mocaplatform.com/releases/moca-ios-sdk-1.9.5.zip) - [ **(v.1.9.4)**](http://files.mocaplatform.com/releases/moca-ios-sdk-1.9.4.zip) - [ **(v.1.7.0)**](http://files.mocaplatform.com/releases/moca-ios-sdk-1.7.0.zip) - [ **(v.1.6.8)**](http://files.mocaplatform.com/releases/moca-ios-sdk-1.6.8.zip) ##iOS Sample App [Download](http://files.mocaplatform.com/releases/sample-apps/MOCA-iOS-Sample-1.9.6.zip) [block:api-header] { "type": "basic", "title": "Android" } [/block] ##Android SDK [block:image] { "images": [ { "image": [ "https://files.readme.io/Ffak3n3QdSBh9h49XHA1_android-sdk.png", "android-sdk.png", "182", "180", "#e6884a", "" ] } ] } [/block] ##[Download latest version (11/11/2016) **(v.1.9.6)**](http://files.mocaplatform.com/releases/moca-android-sdk-latest.zip) [Installation Guide](../docs/moca-android-sdk-installation) ###Archive - [**(v.1.9.5)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.5.zip) - [**(v.1.9.4)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.4.zip) - [**(v.1.9.3)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.3.zip) - [**(v.1.9.2)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.2.zip) - [**(v.1.9.1)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.1.zip) - [**(v.1.9.0)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.0.zip) - [**(v.1.8.11)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.8.11.zip) ##Android Sample App [Download](http://files.mocaplatform.com/releases/sample-apps/MOCA-Android-Sample-1.9.1.zip) [block:api-header] { "type": "basic", "title": "Cordova Plugin" } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/g4PuBoQTAeJBBWjGNLuQ_cordova-sdk-box.png", "cordova-sdk-box.png", "175", "169", "#ea8634", "" ] } ] } [/block] ##Available on GitHub [Click here to read the installation instructions](../docs/moca-ios-sdk-setup)
[block:api-header] { "type": "basic", "title": "iOS" } [/block] ##iOS SDK [block:image] { "images": [ { "image": [ "https://files.readme.io/zyvbx4ZYSFmmooGPY6PZ_ios-sdk.png", "ios-sdk.png", "175", "181", "#e88a4a", "" ] } ] } [/block] ##[Download latest version (03/06/2016) **(v.1.9.6)**](http://files.mocaplatform.com/releases/moca-ios-sdk-latest.zip) [Installation Guide](../docs/moca-ios-sdk-setup) ###Archive - [ **(v.1.9.5)**](http://files.mocaplatform.com/releases/moca-ios-sdk-1.9.5.zip) - [ **(v.1.9.4)**](http://files.mocaplatform.com/releases/moca-ios-sdk-1.9.4.zip) - [ **(v.1.7.0)**](http://files.mocaplatform.com/releases/moca-ios-sdk-1.7.0.zip) - [ **(v.1.6.8)**](http://files.mocaplatform.com/releases/moca-ios-sdk-1.6.8.zip) ##iOS Sample App [Download](http://files.mocaplatform.com/releases/sample-apps/MOCA-iOS-Sample-1.9.6.zip) [block:api-header] { "type": "basic", "title": "Android" } [/block] ##Android SDK [block:image] { "images": [ { "image": [ "https://files.readme.io/Ffak3n3QdSBh9h49XHA1_android-sdk.png", "android-sdk.png", "182", "180", "#e6884a", "" ] } ] } [/block] ##[Download latest version (11/11/2016) **(v.1.9.6)**](http://files.mocaplatform.com/releases/moca-android-sdk-latest.zip) [Installation Guide](../docs/moca-android-sdk-installation) ###Archive - [**(v.1.9.5)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.5.zip) - [**(v.1.9.4)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.4.zip) - [**(v.1.9.3)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.3.zip) - [**(v.1.9.2)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.2.zip) - [**(v.1.9.1)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.1.zip) - [**(v.1.9.0)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.9.0.zip) - [**(v.1.8.11)**](http://files.mocaplatform.com/releases/moca-android-sdk-1.8.11.zip) ##Android Sample App [Download](http://files.mocaplatform.com/releases/sample-apps/MOCA-Android-Sample-1.9.1.zip) [block:api-header] { "type": "basic", "title": "Cordova Plugin" } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/g4PuBoQTAeJBBWjGNLuQ_cordova-sdk-box.png", "cordova-sdk-box.png", "175", "169", "#ea8634", "" ] } ] } [/block] ##Available on GitHub [Click here to read the installation instructions](../docs/moca-ios-sdk-setup)
{"_id":"55a5917a0f354f0d00fd0345","sync_unique":"","api":{"auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"isReference":false,"createdAt":"2015-07-14T22:47:22.161Z","githubsync":"","hidden":false,"parentDoc":null,"type":"basic","__v":30,"category":"55a589ddaaf9cf1900114dd0","slug":"moca-ios-sdk-setup","title":"Installation","updates":["5732f597b26eb71900f89a3b"],"version":"559a61d2dbcfd20d00710b3c","link_url":"","project":"559a61d2dbcfd20d00710b39","excerpt":"This section describes how to add MOCA iOS SDK to your app.","link_external":false,"order":0,"user":"55a575ebaaf9cf1900114d73","body":"You may install the MOCA SDK using **CocoaPods** or **manually**.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Option A: Cocoapods\"\n}\n[/block]\nCocoaPods is a dependency manager for Objective-C projects. Learn more [here](http://cocoapods.org/).\n\n1. If you haven't already, install CocoaPods by executing the following: \n\n  ```\n$ sudo gem install cocoapods\n  ```\n \n3.  If you encounter any issues installing cocoapods, please refer to their [getting started guide](https://guides.cocoapods.org/using/getting-started.html)\n  \n2. Create a plain text file named Podfile (or use `touch Podfile` from the command line) in the Xcode project directory with the following content:\n\n  ```\n  pod 'MOCA',                       '1.9.6'\n  ```\n  \n3. Install MOCA SDK by executing the following in the Xcode project directory:\n\n  ```\n  pod install\n  ```\n  \n4. Open the project workspace (`<yourProject>.xcworkspace`) instead of the project file (`<yourProject>.xcodeproj`) to ensure that the MOCA SDK dependency is properly loaded. \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Option B: Manual installation\"\n}\n[/block]\n1. To install the MOCA SDK, download latest stable version of [MOCA SDK archive](http://files.mocaplatform.com/releases/moca-ios-sdk-latest.zip).\n2. Xcode with the iOS development kit is required to build an iOS app using MOCA SDK. For a better experience, we recommend XCode 7.\n3. The SDK requires `7.x`, `8.0`, `8.1`, `8.2`, `8.3`, `8.4` or later.\n4. Unzip the archive.\n\nOnce downloaded the SDK, you’ll need to add all necessary frameworks to your project.\n\n5. Open your project in Xcode.\n6. Add the `libMOCALib.a` static library provided in the SDK archive to your app project. The library is a universal FAT library compiled for the following architectures: `armv7/armv7s/arm64/x86_64/i386`. \n7. Make sure to Copy items into destination group's folder is selected.\n8. Press the Finish button.\n9. Ensure that you have added to your project the following dependent frameworks:\n   - `SystemConfiguration.framework`\n   - `CoreTelephony.framework`\n   - `MobileCoreServices.framework`\n   - `CoreBluetooth.framework`\n   - `CoreLocation.framework`\n   - `UIKit.framework`\n   - `AudioToolbox.framework`\n   - `libsqlite3.0.dynlib`\n   - `PassKit.framework` (optional, only add if you plan to deploy Passbook cards)\n\n   To do this, select your project file in the file explorer, select your target, and select the Build Phases sub-tab. Under Link Binary with Libraries, press the <i>+ button</i>, to select and add all required frameworks.\n\n10. In Xcode, go to the Build Settings of your project. Next go to the “linking” section and add the flag –ObjC in Other Linker Flags.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/aWxkZDdaS1l5cyU1AszE_xcode.png\",\n        \"xcode.png\",\n        \"846\",\n        \"403\",\n        \"#2d5695\",\n        \"\"\n      ],\n      \"caption\": \"Setting -ObjC linker flag.\"\n    }\n  ]\n}\n[/block]\n####Add the header files\n\n1. Copy the Headers folder from the decompressed file to your XCode project.\n    - Ensure you check the \"copy items if needed\" so headers will be inside your project. \n    - Select the needed target(s), so headers paths will be added automatically. (If you have only one target, select it).\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/j0FWxCVFRcxkuG1x2m2R_add-headers.png\",\n        \"add-headers.png\",\n        \"723\",\n        \"436\",\n        \"#3061a0\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n###Xcode does not find the header files!\n\nIf you cannot `#import <MOCA.h>` within your `AppDelegate`, make sure Xcode has added the Header's path correctly to the project's configuration.\n\nGo to `<<Your Project Name>>/<<Your Build Target>>/Build Settings/Search Paths -> Header Search Paths` and add the header's path. You can use the `$(PROJECT_DIR)` build setting to create relative paths:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/tlY6a3RmmCN6NAV0wMKg_(PROJECT_DIR).png\",\n        \"(PROJECT_DIR).png\",\n        \"802\",\n        \"361\",\n        \"#1a5cad\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Installation

This section describes how to add MOCA iOS SDK to your app.

You may install the MOCA SDK using **CocoaPods** or **manually**. [block:api-header] { "type": "basic", "title": "Option A: Cocoapods" } [/block] CocoaPods is a dependency manager for Objective-C projects. Learn more [here](http://cocoapods.org/). 1. If you haven't already, install CocoaPods by executing the following: ``` $ sudo gem install cocoapods ``` 3. If you encounter any issues installing cocoapods, please refer to their [getting started guide](https://guides.cocoapods.org/using/getting-started.html) 2. Create a plain text file named Podfile (or use `touch Podfile` from the command line) in the Xcode project directory with the following content: ``` pod 'MOCA', '1.9.6' ``` 3. Install MOCA SDK by executing the following in the Xcode project directory: ``` pod install ``` 4. Open the project workspace (`<yourProject>.xcworkspace`) instead of the project file (`<yourProject>.xcodeproj`) to ensure that the MOCA SDK dependency is properly loaded. [block:api-header] { "type": "basic", "title": "Option B: Manual installation" } [/block] 1. To install the MOCA SDK, download latest stable version of [MOCA SDK archive](http://files.mocaplatform.com/releases/moca-ios-sdk-latest.zip). 2. Xcode with the iOS development kit is required to build an iOS app using MOCA SDK. For a better experience, we recommend XCode 7. 3. The SDK requires `7.x`, `8.0`, `8.1`, `8.2`, `8.3`, `8.4` or later. 4. Unzip the archive. Once downloaded the SDK, you’ll need to add all necessary frameworks to your project. 5. Open your project in Xcode. 6. Add the `libMOCALib.a` static library provided in the SDK archive to your app project. The library is a universal FAT library compiled for the following architectures: `armv7/armv7s/arm64/x86_64/i386`. 7. Make sure to Copy items into destination group's folder is selected. 8. Press the Finish button. 9. Ensure that you have added to your project the following dependent frameworks: - `SystemConfiguration.framework` - `CoreTelephony.framework` - `MobileCoreServices.framework` - `CoreBluetooth.framework` - `CoreLocation.framework` - `UIKit.framework` - `AudioToolbox.framework` - `libsqlite3.0.dynlib` - `PassKit.framework` (optional, only add if you plan to deploy Passbook cards) To do this, select your project file in the file explorer, select your target, and select the Build Phases sub-tab. Under Link Binary with Libraries, press the <i>+ button</i>, to select and add all required frameworks. 10. In Xcode, go to the Build Settings of your project. Next go to the “linking” section and add the flag –ObjC in Other Linker Flags. [block:image] { "images": [ { "image": [ "https://files.readme.io/aWxkZDdaS1l5cyU1AszE_xcode.png", "xcode.png", "846", "403", "#2d5695", "" ], "caption": "Setting -ObjC linker flag." } ] } [/block] ####Add the header files 1. Copy the Headers folder from the decompressed file to your XCode project. - Ensure you check the "copy items if needed" so headers will be inside your project. - Select the needed target(s), so headers paths will be added automatically. (If you have only one target, select it). [block:image] { "images": [ { "image": [ "https://files.readme.io/j0FWxCVFRcxkuG1x2m2R_add-headers.png", "add-headers.png", "723", "436", "#3061a0", "" ] } ] } [/block] ###Xcode does not find the header files! If you cannot `#import <MOCA.h>` within your `AppDelegate`, make sure Xcode has added the Header's path correctly to the project's configuration. Go to `<<Your Project Name>>/<<Your Build Target>>/Build Settings/Search Paths -> Header Search Paths` and add the header's path. You can use the `$(PROJECT_DIR)` build setting to create relative paths: [block:image] { "images": [ { "image": [ "https://files.readme.io/tlY6a3RmmCN6NAV0wMKg_(PROJECT_DIR).png", "(PROJECT_DIR).png", "802", "361", "#1a5cad", "" ] } ] } [/block]
You may install the MOCA SDK using **CocoaPods** or **manually**. [block:api-header] { "type": "basic", "title": "Option A: Cocoapods" } [/block] CocoaPods is a dependency manager for Objective-C projects. Learn more [here](http://cocoapods.org/). 1. If you haven't already, install CocoaPods by executing the following: ``` $ sudo gem install cocoapods ``` 3. If you encounter any issues installing cocoapods, please refer to their [getting started guide](https://guides.cocoapods.org/using/getting-started.html) 2. Create a plain text file named Podfile (or use `touch Podfile` from the command line) in the Xcode project directory with the following content: ``` pod 'MOCA', '1.9.6' ``` 3. Install MOCA SDK by executing the following in the Xcode project directory: ``` pod install ``` 4. Open the project workspace (`<yourProject>.xcworkspace`) instead of the project file (`<yourProject>.xcodeproj`) to ensure that the MOCA SDK dependency is properly loaded. [block:api-header] { "type": "basic", "title": "Option B: Manual installation" } [/block] 1. To install the MOCA SDK, download latest stable version of [MOCA SDK archive](http://files.mocaplatform.com/releases/moca-ios-sdk-latest.zip). 2. Xcode with the iOS development kit is required to build an iOS app using MOCA SDK. For a better experience, we recommend XCode 7. 3. The SDK requires `7.x`, `8.0`, `8.1`, `8.2`, `8.3`, `8.4` or later. 4. Unzip the archive. Once downloaded the SDK, you’ll need to add all necessary frameworks to your project. 5. Open your project in Xcode. 6. Add the `libMOCALib.a` static library provided in the SDK archive to your app project. The library is a universal FAT library compiled for the following architectures: `armv7/armv7s/arm64/x86_64/i386`. 7. Make sure to Copy items into destination group's folder is selected. 8. Press the Finish button. 9. Ensure that you have added to your project the following dependent frameworks: - `SystemConfiguration.framework` - `CoreTelephony.framework` - `MobileCoreServices.framework` - `CoreBluetooth.framework` - `CoreLocation.framework` - `UIKit.framework` - `AudioToolbox.framework` - `libsqlite3.0.dynlib` - `PassKit.framework` (optional, only add if you plan to deploy Passbook cards) To do this, select your project file in the file explorer, select your target, and select the Build Phases sub-tab. Under Link Binary with Libraries, press the <i>+ button</i>, to select and add all required frameworks. 10. In Xcode, go to the Build Settings of your project. Next go to the “linking” section and add the flag –ObjC in Other Linker Flags. [block:image] { "images": [ { "image": [ "https://files.readme.io/aWxkZDdaS1l5cyU1AszE_xcode.png", "xcode.png", "846", "403", "#2d5695", "" ], "caption": "Setting -ObjC linker flag." } ] } [/block] ####Add the header files 1. Copy the Headers folder from the decompressed file to your XCode project. - Ensure you check the "copy items if needed" so headers will be inside your project. - Select the needed target(s), so headers paths will be added automatically. (If you have only one target, select it). [block:image] { "images": [ { "image": [ "https://files.readme.io/j0FWxCVFRcxkuG1x2m2R_add-headers.png", "add-headers.png", "723", "436", "#3061a0", "" ] } ] } [/block] ###Xcode does not find the header files! If you cannot `#import <MOCA.h>` within your `AppDelegate`, make sure Xcode has added the Header's path correctly to the project's configuration. Go to `<<Your Project Name>>/<<Your Build Target>>/Build Settings/Search Paths -> Header Search Paths` and add the header's path. You can use the `$(PROJECT_DIR)` build setting to create relative paths: [block:image] { "images": [ { "image": [ "https://files.readme.io/tlY6a3RmmCN6NAV0wMKg_(PROJECT_DIR).png", "(PROJECT_DIR).png", "802", "361", "#1a5cad", "" ] } ] } [/block]
{"_id":"55a5b03880c8a30d00b32458","type":"basic","version":"559a61d2dbcfd20d00710b3c","excerpt":"This section describes how to configure MOCA iOS SDK in your app.","link_url":"","next":{"description":"","pages":[]},"project":"559a61d2dbcfd20d00710b39","sync_unique":"","body":"To start using MOCA SDK in your app, you’ll need to configure it first.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Location Services\"\n}\n[/block]\nTo detect beacons, geofences and track significant changes in user location, the SDK uses *iOS Location Services*. For iOS 8, enable the app to always use location services by adding *NSLocationAlwaysUsageDescription* key to your `Info.plist file`. For example:\u000b \n\n| Key                              | Type   |                                                                                                                                 |\n|----------------------------------|--------|---------------------------------------------------------------------------------------------------------------------------------|\n| NSLocationAlwaysUsageDescription | String | This app will use your location information to identify ,nearby places and to notify you about available proximity experiences. |\n\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"body\": \"If this key is not present in your `info.plist`, iOS Location Services **won't start**, preventing the App to detect Bluetooth Beacons, Geofences and to receive Location updates.\",\n  \"title\": \"Important\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"This message will be prompted to the user when asked for location services permission. Please bear in mind that if this key is not present in your info.plist, location services** won’t work at all.**\",\n  \"sidebar\": true\n}\n[/block]\n###App Transport Security\n\niOS 9 blocks all non-HTTPS requests, as you probably may want to show content hosted in non-HTTPS servers, please add the following keys to your `info.plist`:\nBear in mind you can use the key description (see image) instead of the key (NS...).\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/W02ZcgadS36yvqYZi01v_ios%209%20app%20transport.png\",\n        \"ios 9 app transport.png\",\n        \"438\",\n        \"75\",\n        \"#114b9a\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nUsing key's descriptions.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/2Ch7Pe6vRneAKw4igre9_infoplist2.png\",\n        \"infoplist2.png\",\n        \"500\",\n        \"49\",\n        \"#764f40\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n###Bluetooth Usage Description\n\nStarting with **iOS 10**, Apple requires this mode to be added to all applications that use the `CoreBluetooth` framework.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/02648cb-BTUsage.png\",\n        \"BTUsage.png\",\n        706,\n        21,\n        \"#5e3d2b\"\n      ]\n    }\n  ]\n}\n[/block]\nEquivalent version using raw key / values:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/d05e962-BTUsageKeyValue.png\",\n        \"BTUsageKeyValue.png\",\n        700,\n        22,\n        \"#5b3728\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"App Capabilities\"\n}\n[/block]\nMOCA SDK requires the app to enable selected *Capabilities*. Open XCode with your app project, go to Target, and select *Capabilities* configuration page. \n\nFirst, within *Background Modes* section, ensure the following entitlements are enabled:\n   - Background Fetch\n   - Optionally, you may want to enable Remote notifications in your app.\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/mU6VBI2JSBW2sgCVaBak_background-capabilities.png\",\n        \"background-capabilities.png\",\n        \"817\",\n        \"282\",\n        \"\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"body\": \"**Do not** select *Location updates* (unless you need it for another App feature). MOCA SDK **does not require this mode**. If you enable it and do not use it for any purpose, **your App will be rejected** by Apple.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"App Keys\"\n}\n[/block]\nTo link you app to your MOCA account, you must register the app in the MOCA Console and add corresponding **AppKey** and **AppSecret**. \n\n* Goto [https://console.mocaplatform.com](https://console.mocaplatform.com) and sign in to your MOCA account.\n* If you don't have your account, you are invited to [Sign Up Free] (http://mocaplatform.com/signup). \n* Select Apps item at left sidebar, and then click <i>+ New App</i> in the content panel. Fill in the form and complete the app creation.\n* Select if your app is *In Development* or *In Production* mode.\n* Open newly created app and navigate to <i>Settings</i> item. Select <i>API keys</i> tab.\n* Get `App Key` and `App Secret`.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/FFeK1tqTwCqIjweq7aP9_moca-keys.png\",\n        \"moca-keys.png\",\n        \"704\",\n        \"458\",\n        \"#573033\",\n        \"\"\n      ],\n      \"caption\": \"App keys in MOCA Console\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"SDK Configuration File\"\n}\n[/block]\nNow, you’ll need to prepare SDK configuration file:\n\n* Go back to your Xcode project.\n* `CocoaPods` only: You will find the MOCAConfig.plist in the following path: `Pods/MOCA/Resources` there is no need to add it manually\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/6Q8t5NjZSICU3QYn0TeF_MOCAConfig-cocoapods.png\",\n        \"MOCAConfig-cocoapods.png\",\n        \"261\",\n        \"168\",\n        \"#97571e\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n* Add <i>New file / Property List</i> resource to your project. Save it as *MOCAConfig.plist* file. (optional,  [download sample MOCAConfig.plist file](https://s3-eu-west-1.amazonaws.com/files.mocaplatform.com/releases/MOCAConfig.plist))\n* Add configuration settings as shown below.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Key\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Default Value\",\n    \"h-3\": \"Description\",\n    \"h-4\": \"\",\n    \"0-0\": \"APP_KEY\",\n    \"0-1\": \"String\",\n    \"0-3\": \"App key from MOCA Console\",\n    \"1-0\": \"APP_SECRET\",\n    \"1-1\": \"String\",\n    \"1-3\": \"App secret from MOCA Console\",\n    \"2-0\": \"LOG_LEVEL\",\n    \"2-1\": \"String\",\n    \"2-3\": \"MOCA SDK logging level:\\n* trace\\n* debug\\n* info\\n* warn\\n* error\",\n    \"2-2\": \"\\\"info\\\"\",\n    \"3-0\": \"CACHE_DISK_SIZE_IN_MB\",\n    \"3-1\": \"Integer\",\n    \"3-3\": \"Maximum local disk space available for SDK cache.\",\n    \"3-2\": \"100\",\n    \"4-0\": \"AUTOMATIC_PUSH_SETUP_ENABLED\",\n    \"4-3\": \"If enabled, the SDK will automatically subscribe the app to APNS (Apple push notification service) and obtain push token.\",\n    \"4-1\": \"BOOL\",\n    \"4-2\": \"YES\",\n    \"5-0\": \"PROXIMITY_SERVICE_ENABLED\",\n    \"5-1\": \"BOOL\",\n    \"5-2\": \"YES\",\n    \"5-3\": \"Enables or disables Bluetooth Beacon monitoring and ranging & geofence detection using *iOS Location Services*\",\n    \"6-0\": \"GEOLOCATION_SERVICE_ENABLED\",\n    \"6-1\": \"BOOL\",\n    \"6-2\": \"YES\",\n    \"6-3\": \"Enables/disables tracking of significant changes in user location by GPS/Cellular Trilateration/Wifi.\\n\\nWhen enabled (YES), user location will be tracked when the app is in foreground. Additionally, background tracking is controlled by BACKGROUND_LOCATION_ENABLED flag. This is the default.\\n\\nWhen disabled (NO), user location will not be tracked at all (neither in foreground nor on background). However, Bluetooth beacons and geofences will still be detected if this flag is set to NO.\",\n    \"7-0\": \"BACKGROUND_LOCATION_ENABLED\",\n    \"7-1\": \"BOOL\",\n    \"7-2\": \"YES\",\n    \"7-3\": \"Enables/disables location tracking when the app is in background or suspended mode.\\n\\nThis flag has no effect if GEOLOCATION_SERVICE_ENABLED is set to NO.\\n\\nBy default background location tracking is enabled.\"\n  },\n  \"cols\": 4,\n  \"rows\": 8\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"MOCA performs location tracking using low battery usage modes to save battery life. For example, when the app is in background GPS-quality tracking is never used.\",\n  \"sidebar\": true\n}\n[/block]\n* Be sure to replace `APP_KEY` and `APP_SECRET` values with the real values for your app which you found in the MOCA console.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ncAD6MeQJy2CCfiVWjtm_moca-config-ios.png\",\n        \"moca-config-ios.png\",\n        \"949\",\n        \"369\",\n        \"#884c39\",\n        \"\"\n      ],\n      \"caption\": \"Sample MOCAConfig.plist file.\"\n    }\n  ]\n}\n[/block]","category":"55a589ddaaf9cf1900114dd0","githubsync":"","parentDoc":null,"updates":[],"__v":38,"link_external":false,"title":"Configuration","user":"55a575ebaaf9cf1900114d73","slug":"moca-ios-sdk-configuration","api":{"settings":"","url":"","auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]}},"createdAt":"2015-07-15T00:58:32.707Z","hidden":false,"isReference":false,"order":1,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Configuration

This section describes how to configure MOCA iOS SDK in your app.

To start using MOCA SDK in your app, you’ll need to configure it first. [block:api-header] { "type": "basic", "title": "Location Services" } [/block] To detect beacons, geofences and track significant changes in user location, the SDK uses *iOS Location Services*. For iOS 8, enable the app to always use location services by adding *NSLocationAlwaysUsageDescription* key to your `Info.plist file`. For example: | Key | Type | | |----------------------------------|--------|---------------------------------------------------------------------------------------------------------------------------------| | NSLocationAlwaysUsageDescription | String | This app will use your location information to identify ,nearby places and to notify you about available proximity experiences. | [block:callout] { "type": "danger", "body": "If this key is not present in your `info.plist`, iOS Location Services **won't start**, preventing the App to detect Bluetooth Beacons, Geofences and to receive Location updates.", "title": "Important" } [/block] [block:callout] { "type": "warning", "body": "This message will be prompted to the user when asked for location services permission. Please bear in mind that if this key is not present in your info.plist, location services** won’t work at all.**", "sidebar": true } [/block] ###App Transport Security iOS 9 blocks all non-HTTPS requests, as you probably may want to show content hosted in non-HTTPS servers, please add the following keys to your `info.plist`: Bear in mind you can use the key description (see image) instead of the key (NS...). [block:image] { "images": [ { "image": [ "https://files.readme.io/W02ZcgadS36yvqYZi01v_ios%209%20app%20transport.png", "ios 9 app transport.png", "438", "75", "#114b9a", "" ] } ] } [/block] Using key's descriptions. [block:image] { "images": [ { "image": [ "https://files.readme.io/2Ch7Pe6vRneAKw4igre9_infoplist2.png", "infoplist2.png", "500", "49", "#764f40", "" ] } ] } [/block] ###Bluetooth Usage Description Starting with **iOS 10**, Apple requires this mode to be added to all applications that use the `CoreBluetooth` framework. [block:image] { "images": [ { "image": [ "https://files.readme.io/02648cb-BTUsage.png", "BTUsage.png", 706, 21, "#5e3d2b" ] } ] } [/block] Equivalent version using raw key / values: [block:image] { "images": [ { "image": [ "https://files.readme.io/d05e962-BTUsageKeyValue.png", "BTUsageKeyValue.png", 700, 22, "#5b3728" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "App Capabilities" } [/block] MOCA SDK requires the app to enable selected *Capabilities*. Open XCode with your app project, go to Target, and select *Capabilities* configuration page. First, within *Background Modes* section, ensure the following entitlements are enabled: - Background Fetch - Optionally, you may want to enable Remote notifications in your app. [block:image] { "images": [ { "image": [ "https://files.readme.io/mU6VBI2JSBW2sgCVaBak_background-capabilities.png", "background-capabilities.png", "817", "282", "", "" ] } ] } [/block] [block:callout] { "type": "danger", "body": "**Do not** select *Location updates* (unless you need it for another App feature). MOCA SDK **does not require this mode**. If you enable it and do not use it for any purpose, **your App will be rejected** by Apple." } [/block] [block:api-header] { "type": "basic", "title": "App Keys" } [/block] To link you app to your MOCA account, you must register the app in the MOCA Console and add corresponding **AppKey** and **AppSecret**. * Goto [https://console.mocaplatform.com](https://console.mocaplatform.com) and sign in to your MOCA account. * If you don't have your account, you are invited to [Sign Up Free] (http://mocaplatform.com/signup). * Select Apps item at left sidebar, and then click <i>+ New App</i> in the content panel. Fill in the form and complete the app creation. * Select if your app is *In Development* or *In Production* mode. * Open newly created app and navigate to <i>Settings</i> item. Select <i>API keys</i> tab. * Get `App Key` and `App Secret`. [block:image] { "images": [ { "image": [ "https://files.readme.io/FFeK1tqTwCqIjweq7aP9_moca-keys.png", "moca-keys.png", "704", "458", "#573033", "" ], "caption": "App keys in MOCA Console" } ] } [/block] [block:api-header] { "type": "basic", "title": "SDK Configuration File" } [/block] Now, you’ll need to prepare SDK configuration file: * Go back to your Xcode project. * `CocoaPods` only: You will find the MOCAConfig.plist in the following path: `Pods/MOCA/Resources` there is no need to add it manually [block:image] { "images": [ { "image": [ "https://files.readme.io/6Q8t5NjZSICU3QYn0TeF_MOCAConfig-cocoapods.png", "MOCAConfig-cocoapods.png", "261", "168", "#97571e", "" ] } ] } [/block] * Add <i>New file / Property List</i> resource to your project. Save it as *MOCAConfig.plist* file. (optional, [download sample MOCAConfig.plist file](https://s3-eu-west-1.amazonaws.com/files.mocaplatform.com/releases/MOCAConfig.plist)) * Add configuration settings as shown below. [block:parameters] { "data": { "h-0": "Key", "h-1": "Type", "h-2": "Default Value", "h-3": "Description", "h-4": "", "0-0": "APP_KEY", "0-1": "String", "0-3": "App key from MOCA Console", "1-0": "APP_SECRET", "1-1": "String", "1-3": "App secret from MOCA Console", "2-0": "LOG_LEVEL", "2-1": "String", "2-3": "MOCA SDK logging level:\n* trace\n* debug\n* info\n* warn\n* error", "2-2": "\"info\"", "3-0": "CACHE_DISK_SIZE_IN_MB", "3-1": "Integer", "3-3": "Maximum local disk space available for SDK cache.", "3-2": "100", "4-0": "AUTOMATIC_PUSH_SETUP_ENABLED", "4-3": "If enabled, the SDK will automatically subscribe the app to APNS (Apple push notification service) and obtain push token.", "4-1": "BOOL", "4-2": "YES", "5-0": "PROXIMITY_SERVICE_ENABLED", "5-1": "BOOL", "5-2": "YES", "5-3": "Enables or disables Bluetooth Beacon monitoring and ranging & geofence detection using *iOS Location Services*", "6-0": "GEOLOCATION_SERVICE_ENABLED", "6-1": "BOOL", "6-2": "YES", "6-3": "Enables/disables tracking of significant changes in user location by GPS/Cellular Trilateration/Wifi.\n\nWhen enabled (YES), user location will be tracked when the app is in foreground. Additionally, background tracking is controlled by BACKGROUND_LOCATION_ENABLED flag. This is the default.\n\nWhen disabled (NO), user location will not be tracked at all (neither in foreground nor on background). However, Bluetooth beacons and geofences will still be detected if this flag is set to NO.", "7-0": "BACKGROUND_LOCATION_ENABLED", "7-1": "BOOL", "7-2": "YES", "7-3": "Enables/disables location tracking when the app is in background or suspended mode.\n\nThis flag has no effect if GEOLOCATION_SERVICE_ENABLED is set to NO.\n\nBy default background location tracking is enabled." }, "cols": 4, "rows": 8 } [/block] [block:callout] { "type": "info", "body": "MOCA performs location tracking using low battery usage modes to save battery life. For example, when the app is in background GPS-quality tracking is never used.", "sidebar": true } [/block] * Be sure to replace `APP_KEY` and `APP_SECRET` values with the real values for your app which you found in the MOCA console. [block:image] { "images": [ { "image": [ "https://files.readme.io/ncAD6MeQJy2CCfiVWjtm_moca-config-ios.png", "moca-config-ios.png", "949", "369", "#884c39", "" ], "caption": "Sample MOCAConfig.plist file." } ] } [/block]
To start using MOCA SDK in your app, you’ll need to configure it first. [block:api-header] { "type": "basic", "title": "Location Services" } [/block] To detect beacons, geofences and track significant changes in user location, the SDK uses *iOS Location Services*. For iOS 8, enable the app to always use location services by adding *NSLocationAlwaysUsageDescription* key to your `Info.plist file`. For example: | Key | Type | | |----------------------------------|--------|---------------------------------------------------------------------------------------------------------------------------------| | NSLocationAlwaysUsageDescription | String | This app will use your location information to identify ,nearby places and to notify you about available proximity experiences. | [block:callout] { "type": "danger", "body": "If this key is not present in your `info.plist`, iOS Location Services **won't start**, preventing the App to detect Bluetooth Beacons, Geofences and to receive Location updates.", "title": "Important" } [/block] [block:callout] { "type": "warning", "body": "This message will be prompted to the user when asked for location services permission. Please bear in mind that if this key is not present in your info.plist, location services** won’t work at all.**", "sidebar": true } [/block] ###App Transport Security iOS 9 blocks all non-HTTPS requests, as you probably may want to show content hosted in non-HTTPS servers, please add the following keys to your `info.plist`: Bear in mind you can use the key description (see image) instead of the key (NS...). [block:image] { "images": [ { "image": [ "https://files.readme.io/W02ZcgadS36yvqYZi01v_ios%209%20app%20transport.png", "ios 9 app transport.png", "438", "75", "#114b9a", "" ] } ] } [/block] Using key's descriptions. [block:image] { "images": [ { "image": [ "https://files.readme.io/2Ch7Pe6vRneAKw4igre9_infoplist2.png", "infoplist2.png", "500", "49", "#764f40", "" ] } ] } [/block] ###Bluetooth Usage Description Starting with **iOS 10**, Apple requires this mode to be added to all applications that use the `CoreBluetooth` framework. [block:image] { "images": [ { "image": [ "https://files.readme.io/02648cb-BTUsage.png", "BTUsage.png", 706, 21, "#5e3d2b" ] } ] } [/block] Equivalent version using raw key / values: [block:image] { "images": [ { "image": [ "https://files.readme.io/d05e962-BTUsageKeyValue.png", "BTUsageKeyValue.png", 700, 22, "#5b3728" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "App Capabilities" } [/block] MOCA SDK requires the app to enable selected *Capabilities*. Open XCode with your app project, go to Target, and select *Capabilities* configuration page. First, within *Background Modes* section, ensure the following entitlements are enabled: - Background Fetch - Optionally, you may want to enable Remote notifications in your app. [block:image] { "images": [ { "image": [ "https://files.readme.io/mU6VBI2JSBW2sgCVaBak_background-capabilities.png", "background-capabilities.png", "817", "282", "", "" ] } ] } [/block] [block:callout] { "type": "danger", "body": "**Do not** select *Location updates* (unless you need it for another App feature). MOCA SDK **does not require this mode**. If you enable it and do not use it for any purpose, **your App will be rejected** by Apple." } [/block] [block:api-header] { "type": "basic", "title": "App Keys" } [/block] To link you app to your MOCA account, you must register the app in the MOCA Console and add corresponding **AppKey** and **AppSecret**. * Goto [https://console.mocaplatform.com](https://console.mocaplatform.com) and sign in to your MOCA account. * If you don't have your account, you are invited to [Sign Up Free] (http://mocaplatform.com/signup). * Select Apps item at left sidebar, and then click <i>+ New App</i> in the content panel. Fill in the form and complete the app creation. * Select if your app is *In Development* or *In Production* mode. * Open newly created app and navigate to <i>Settings</i> item. Select <i>API keys</i> tab. * Get `App Key` and `App Secret`. [block:image] { "images": [ { "image": [ "https://files.readme.io/FFeK1tqTwCqIjweq7aP9_moca-keys.png", "moca-keys.png", "704", "458", "#573033", "" ], "caption": "App keys in MOCA Console" } ] } [/block] [block:api-header] { "type": "basic", "title": "SDK Configuration File" } [/block] Now, you’ll need to prepare SDK configuration file: * Go back to your Xcode project. * `CocoaPods` only: You will find the MOCAConfig.plist in the following path: `Pods/MOCA/Resources` there is no need to add it manually [block:image] { "images": [ { "image": [ "https://files.readme.io/6Q8t5NjZSICU3QYn0TeF_MOCAConfig-cocoapods.png", "MOCAConfig-cocoapods.png", "261", "168", "#97571e", "" ] } ] } [/block] * Add <i>New file / Property List</i> resource to your project. Save it as *MOCAConfig.plist* file. (optional, [download sample MOCAConfig.plist file](https://s3-eu-west-1.amazonaws.com/files.mocaplatform.com/releases/MOCAConfig.plist)) * Add configuration settings as shown below. [block:parameters] { "data": { "h-0": "Key", "h-1": "Type", "h-2": "Default Value", "h-3": "Description", "h-4": "", "0-0": "APP_KEY", "0-1": "String", "0-3": "App key from MOCA Console", "1-0": "APP_SECRET", "1-1": "String", "1-3": "App secret from MOCA Console", "2-0": "LOG_LEVEL", "2-1": "String", "2-3": "MOCA SDK logging level:\n* trace\n* debug\n* info\n* warn\n* error", "2-2": "\"info\"", "3-0": "CACHE_DISK_SIZE_IN_MB", "3-1": "Integer", "3-3": "Maximum local disk space available for SDK cache.", "3-2": "100", "4-0": "AUTOMATIC_PUSH_SETUP_ENABLED", "4-3": "If enabled, the SDK will automatically subscribe the app to APNS (Apple push notification service) and obtain push token.", "4-1": "BOOL", "4-2": "YES", "5-0": "PROXIMITY_SERVICE_ENABLED", "5-1": "BOOL", "5-2": "YES", "5-3": "Enables or disables Bluetooth Beacon monitoring and ranging & geofence detection using *iOS Location Services*", "6-0": "GEOLOCATION_SERVICE_ENABLED", "6-1": "BOOL", "6-2": "YES", "6-3": "Enables/disables tracking of significant changes in user location by GPS/Cellular Trilateration/Wifi.\n\nWhen enabled (YES), user location will be tracked when the app is in foreground. Additionally, background tracking is controlled by BACKGROUND_LOCATION_ENABLED flag. This is the default.\n\nWhen disabled (NO), user location will not be tracked at all (neither in foreground nor on background). However, Bluetooth beacons and geofences will still be detected if this flag is set to NO.", "7-0": "BACKGROUND_LOCATION_ENABLED", "7-1": "BOOL", "7-2": "YES", "7-3": "Enables/disables location tracking when the app is in background or suspended mode.\n\nThis flag has no effect if GEOLOCATION_SERVICE_ENABLED is set to NO.\n\nBy default background location tracking is enabled." }, "cols": 4, "rows": 8 } [/block] [block:callout] { "type": "info", "body": "MOCA performs location tracking using low battery usage modes to save battery life. For example, when the app is in background GPS-quality tracking is never used.", "sidebar": true } [/block] * Be sure to replace `APP_KEY` and `APP_SECRET` values with the real values for your app which you found in the MOCA console. [block:image] { "images": [ { "image": [ "https://files.readme.io/ncAD6MeQJy2CCfiVWjtm_moca-config-ios.png", "moca-config-ios.png", "949", "369", "#884c39", "" ], "caption": "Sample MOCAConfig.plist file." } ] } [/block]
{"_id":"55a611a0249a40190051d928","hidden":false,"link_external":false,"next":{"description":"","pages":[]},"user":"55a575ebaaf9cf1900114d73","body":"1 - Import `<MOCA/MOCA.h>` header file into your app’s delegate implementation file.\n\n2 - initialize MOCA SDK is in you app’s delegate `application:didFinishLaunchingWithOptions:` method.\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import <MOCA.h>\\n\\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\\n{\\n    // Initialize MOCA SDK.\\n    BOOL mocaReady = [MOCA initializeSDK];\\n    if (!mocaReady)\\n    {\\n        NSLog(@\\\"MOCA SDK initialization failed.\\\");\\n    }\\n    return YES;\\n}\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n- You must initialize the SDK before calling any other method.\n\n- On initialization, MOCA SDK will load configuration from MOCAConfig.plist file and perform all necessary framework setup.\n\n- The `[MOCA initializeSDK]` method call returns `YES` on success, and `NO` on error.\n\n3 - Handle local notifications in your AppDelegate:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification\\n{\\n    if (MOCA.initialized)\\n    {\\n        [MOCA handleLocalNotification:notification];\\n    }\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n4 - If you use MOCA remote push notifications, integrate the following code (recommended):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler: (void (^)(UIBackgroundFetchResult))completionHandler{\\n    \\n   if (MOCA.initialized)\\n    {\\n        [MOCA handleRemoteNotification:userInfo fetchCompletionHandler:handler];\\n    }\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken\\n{\\n    NSLog(@\\\"deviceToken: %@\\\", deviceToken);\\n    if(![MOCA initialized]) {\\n        return;\\n    }\\n    [MOCA registerDeviceToken:deviceToken];\\n}\",\n      \"language\": \"objectivec\",\n      \"name\": \"Push token\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Important considerations: Power Consumption\"\n}\n[/block]\n&nbsp;\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/r4ZqBpdYSWK7mLtjejr1_moca-low-battery.png\",\n        \"moca-low-battery.png\",\n        \"200\",\n        \"95\",\n        \"#fc4464\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n&nbsp;\nWhen backgrounded, your application will be woken up by iOS in order to respond to location events. That means that the `didFinishLaunchingWithOptions` **could be called several times** while the user is moving, or when the device is in the range of bluetooth beacons.\n**Be extra careful**: filter out these events so that MOCA SDK is initialized, but any other heavy tasks are not executed. If the `UIApplicationLaunchOptionsLocationKey` key is present in the `launchOptions`, you can tell that the App was launched to respond to a location event.\n\nExample:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import <MOCA.h>\\n\\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\\n{\\n    [MOCA initializeSDK];\\n    //Filter out the events\\n    if([launchOptions objectForKey:@\\\"UIApplicationLaunchOptionsLocationKey\\\"]) {\\n    \\t\\treturn YES;\\n    }\\n  \\t//do heavy stuff afterwards\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"success\",\n  \"body\": \"At this point, you already have a proximity-aware app! Go to the [MOCA Console](https://console.mocaplatform.com), create some campaigns and test your Proximity Experiences.\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Beacon detection cannot be tested in the simulator, you will need a real device (iPhone 4s or newer).\",\n  \"title\": \"Simulator\",\n  \"sidebar\": true\n}\n[/block]","createdAt":"2015-07-15T07:54:08.281Z","link_url":"","sync_unique":"","parentDoc":null,"type":"basic","api":{"auth":"required","params":[],"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"category":"55a589ddaaf9cf1900114dd0","excerpt":"This section describes how to integrate MOCA iOS SDK with your app code.","githubsync":"","isReference":false,"order":2,"updates":[],"__v":24,"project":"559a61d2dbcfd20d00710b39","slug":"moca-ios-sdk-integration","title":"Integration","version":"559a61d2dbcfd20d00710b3c","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Integration

This section describes how to integrate MOCA iOS SDK with your app code.

1 - Import `<MOCA/MOCA.h>` header file into your app’s delegate implementation file. 2 - initialize MOCA SDK is in you app’s delegate `application:didFinishLaunchingWithOptions:` method. [block:code] { "codes": [ { "code": "#import <MOCA.h>\n\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n // Initialize MOCA SDK.\n BOOL mocaReady = [MOCA initializeSDK];\n if (!mocaReady)\n {\n NSLog(@\"MOCA SDK initialization failed.\");\n }\n return YES;\n}\n", "language": "objectivec" } ] } [/block] - You must initialize the SDK before calling any other method. - On initialization, MOCA SDK will load configuration from MOCAConfig.plist file and perform all necessary framework setup. - The `[MOCA initializeSDK]` method call returns `YES` on success, and `NO` on error. 3 - Handle local notifications in your AppDelegate: [block:code] { "codes": [ { "code": "- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification\n{\n if (MOCA.initialized)\n {\n [MOCA handleLocalNotification:notification];\n }\n}", "language": "objectivec" } ] } [/block] 4 - If you use MOCA remote push notifications, integrate the following code (recommended): [block:code] { "codes": [ { "code": "-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler: (void (^)(UIBackgroundFetchResult))completionHandler{\n \n if (MOCA.initialized)\n {\n [MOCA handleRemoteNotification:userInfo fetchCompletionHandler:handler];\n }\n}", "language": "objectivec" } ] } [/block] [block:code] { "codes": [ { "code": "-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken\n{\n NSLog(@\"deviceToken: %@\", deviceToken);\n if(![MOCA initialized]) {\n return;\n }\n [MOCA registerDeviceToken:deviceToken];\n}", "language": "objectivec", "name": "Push token" } ] } [/block] [block:api-header] { "type": "basic", "title": "Important considerations: Power Consumption" } [/block] &nbsp; [block:image] { "images": [ { "image": [ "https://files.readme.io/r4ZqBpdYSWK7mLtjejr1_moca-low-battery.png", "moca-low-battery.png", "200", "95", "#fc4464", "" ] } ] } [/block] &nbsp; When backgrounded, your application will be woken up by iOS in order to respond to location events. That means that the `didFinishLaunchingWithOptions` **could be called several times** while the user is moving, or when the device is in the range of bluetooth beacons. **Be extra careful**: filter out these events so that MOCA SDK is initialized, but any other heavy tasks are not executed. If the `UIApplicationLaunchOptionsLocationKey` key is present in the `launchOptions`, you can tell that the App was launched to respond to a location event. Example: [block:code] { "codes": [ { "code": "#import <MOCA.h>\n\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n [MOCA initializeSDK];\n //Filter out the events\n if([launchOptions objectForKey:@\"UIApplicationLaunchOptionsLocationKey\"]) {\n \t\treturn YES;\n }\n \t//do heavy stuff afterwards\n}", "language": "objectivec" } ] } [/block] [block:callout] { "type": "success", "body": "At this point, you already have a proximity-aware app! Go to the [MOCA Console](https://console.mocaplatform.com), create some campaigns and test your Proximity Experiences." } [/block] [block:callout] { "type": "info", "body": "Beacon detection cannot be tested in the simulator, you will need a real device (iPhone 4s or newer).", "title": "Simulator", "sidebar": true } [/block]
1 - Import `<MOCA/MOCA.h>` header file into your app’s delegate implementation file. 2 - initialize MOCA SDK is in you app’s delegate `application:didFinishLaunchingWithOptions:` method. [block:code] { "codes": [ { "code": "#import <MOCA.h>\n\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n // Initialize MOCA SDK.\n BOOL mocaReady = [MOCA initializeSDK];\n if (!mocaReady)\n {\n NSLog(@\"MOCA SDK initialization failed.\");\n }\n return YES;\n}\n", "language": "objectivec" } ] } [/block] - You must initialize the SDK before calling any other method. - On initialization, MOCA SDK will load configuration from MOCAConfig.plist file and perform all necessary framework setup. - The `[MOCA initializeSDK]` method call returns `YES` on success, and `NO` on error. 3 - Handle local notifications in your AppDelegate: [block:code] { "codes": [ { "code": "- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification\n{\n if (MOCA.initialized)\n {\n [MOCA handleLocalNotification:notification];\n }\n}", "language": "objectivec" } ] } [/block] 4 - If you use MOCA remote push notifications, integrate the following code (recommended): [block:code] { "codes": [ { "code": "-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler: (void (^)(UIBackgroundFetchResult))completionHandler{\n \n if (MOCA.initialized)\n {\n [MOCA handleRemoteNotification:userInfo fetchCompletionHandler:handler];\n }\n}", "language": "objectivec" } ] } [/block] [block:code] { "codes": [ { "code": "-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken\n{\n NSLog(@\"deviceToken: %@\", deviceToken);\n if(![MOCA initialized]) {\n return;\n }\n [MOCA registerDeviceToken:deviceToken];\n}", "language": "objectivec", "name": "Push token" } ] } [/block] [block:api-header] { "type": "basic", "title": "Important considerations: Power Consumption" } [/block] &nbsp; [block:image] { "images": [ { "image": [ "https://files.readme.io/r4ZqBpdYSWK7mLtjejr1_moca-low-battery.png", "moca-low-battery.png", "200", "95", "#fc4464", "" ] } ] } [/block] &nbsp; When backgrounded, your application will be woken up by iOS in order to respond to location events. That means that the `didFinishLaunchingWithOptions` **could be called several times** while the user is moving, or when the device is in the range of bluetooth beacons. **Be extra careful**: filter out these events so that MOCA SDK is initialized, but any other heavy tasks are not executed. If the `UIApplicationLaunchOptionsLocationKey` key is present in the `launchOptions`, you can tell that the App was launched to respond to a location event. Example: [block:code] { "codes": [ { "code": "#import <MOCA.h>\n\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n [MOCA initializeSDK];\n //Filter out the events\n if([launchOptions objectForKey:@\"UIApplicationLaunchOptionsLocationKey\"]) {\n \t\treturn YES;\n }\n \t//do heavy stuff afterwards\n}", "language": "objectivec" } ] } [/block] [block:callout] { "type": "success", "body": "At this point, you already have a proximity-aware app! Go to the [MOCA Console](https://console.mocaplatform.com), create some campaigns and test your Proximity Experiences." } [/block] [block:callout] { "type": "info", "body": "Beacon detection cannot be tested in the simulator, you will need a real device (iPhone 4s or newer).", "title": "Simulator", "sidebar": true } [/block]
{"_id":"55a911aa27a17d210052523f","__v":1,"category":"55a589ddaaf9cf1900114dd0","parentDoc":null,"link_url":"","order":3,"sync_unique":"","type":"basic","updates":[],"version":"559a61d2dbcfd20d00710b3c","isReference":false,"slug":"known-issues","link_external":false,"project":"559a61d2dbcfd20d00710b39","api":{"auth":"required","params":[],"results":{"codes":[{"language":"json","code":"{}","name":"","status":200},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"body":"iOS iBeacon issues\n- CLProximity Toggling - iOS 7.0 and 7.1 has a known issue related to beacon unexpected proximity changes. It may happen that your have your app and a beacon is detected at a certain proximity distance, for example \"Near”. Both beacon and your device do not move. And suddenly the beacon ranging callback from iOS notifies you that beacon proximity changed to \"Immediate\", and then it switched back to \"Near\" again. This may happen several times. \n- The reason for this behavior resides both in BLE signal interference and in iOS logic for averaging the RSSI signal strength and determining CLProximity range. The effect is that you observe sudden rapid toggles between proximity regions.\n- We are working on a next version of SDK that will filter received signals, remove outliers and lower the sensitivity on region changes in order to provide a smoother user experience.","createdAt":"2015-07-17T14:31:06.333Z","excerpt":"","githubsync":"","hidden":false,"title":"Known issues","user":"559a618bdbcfd20d00710b38","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Known issues


iOS iBeacon issues - CLProximity Toggling - iOS 7.0 and 7.1 has a known issue related to beacon unexpected proximity changes. It may happen that your have your app and a beacon is detected at a certain proximity distance, for example "Near”. Both beacon and your device do not move. And suddenly the beacon ranging callback from iOS notifies you that beacon proximity changed to "Immediate", and then it switched back to "Near" again. This may happen several times. - The reason for this behavior resides both in BLE signal interference and in iOS logic for averaging the RSSI signal strength and determining CLProximity range. The effect is that you observe sudden rapid toggles between proximity regions. - We are working on a next version of SDK that will filter received signals, remove outliers and lower the sensitivity on region changes in order to provide a smoother user experience.
iOS iBeacon issues - CLProximity Toggling - iOS 7.0 and 7.1 has a known issue related to beacon unexpected proximity changes. It may happen that your have your app and a beacon is detected at a certain proximity distance, for example "Near”. Both beacon and your device do not move. And suddenly the beacon ranging callback from iOS notifies you that beacon proximity changed to "Immediate", and then it switched back to "Near" again. This may happen several times. - The reason for this behavior resides both in BLE signal interference and in iOS logic for averaging the RSSI signal strength and determining CLProximity range. The effect is that you observe sudden rapid toggles between proximity regions. - We are working on a next version of SDK that will filter received signals, remove outliers and lower the sensitivity on region changes in order to provide a smoother user experience.
{"_id":"55a612ae249a40190051d92d","order":4,"type":"basic","updates":[],"excerpt":"","hidden":false,"link_url":"","__v":11,"api":{"auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"language":"json","code":"{}","name":"","status":400}]},"settings":"","url":""},"title":"Integration Examples","link_external":false,"project":"559a61d2dbcfd20d00710b39","slug":"moca-ios-sdk-integration-examples","sync_unique":"","body":"The typical integration scenarios include handling of the following in-app events:\n* Launch app\n* User Login\n* User Logout\n* Receive Push Notification \n* Registered for Remote Push Notifications\n* Fetch Campaigns\n* Enter Screen\n* Custom Events\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Launch app\"\n}\n[/block]\nThis code sample shows how to initialize MOCA SDK on app startup and also handle situations when the app is started by opening a push notification. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\\n{\\n   // Init MOCA SDK\\n   [MOCA initializeSDK];\\n   if (launchOptions != nil) {\\n       // Launched from push notification\\n       NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];\\n       if (notification) {\\n           // Notify MOCA the app started from push\\n           [MOCA handleRemoteNotification:notification];\\n       }\\n   }\\n   // Optionally, set guest properties\\n   MOCAInstance * currentInstance = [MOCA currentInstance];\\n   if (currentInstance) {\\n        [currentInstance setValue:@\\\"property_1_value\\\" forProperty:@\\\"guest_property_1\\\"];\\n        [currentInstance setValue:@\\\"property_2_value\\\" forProperty:@\\\"guest_property_2\\\"];\\n        [currentInstance setValue:[NSNumber numberWithDouble:property3_value] forProperty:@\\\"guest_property_3\\\"];\\n     \\n        // Submit change to the cloud \\n        [currentInstance saveWithBlock:^(MOCAInstance *instance, NSError *error) {\\n            if (error) {\\n               NSLog(@\\\"Save instance failed: %@\\\", error);\\n            }\\n        }];\\n   }\\n}\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"User log-in\"\n}\n[/block]\nThis code sample shows how to inform MOCA that a user has logged into the app. This call should be executed each time the user performs the log in, even if the app persists user session on app close. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"   // Notify MOCA, the user logged in. Must be called after each app launch.\\n\\n   NSString * userId = ...\\n   MOCAUser *user = [[MOCA currentInstance] login:loginMgr.username];\\n   \\n   [user setValue:@”paidComplete\\\" forProperty:@\\\"paymentStatus\\\"];\\n   [user setValue:@\\\"...\\\" forProperty:@\\\"pictureStatus\\\"];\\n   [user setValue:@\\\"...\\\" forProperty:@\\\"merchantId\\\"];\\n   [user setValue:@\\\"...\\\" forProperty:@\\\"jobTitle\\\"];\\n   [user setValue:@\\\"...\\\" forProperty:@\\\"companyName\\\"];\\n   [user setValue:@\\\"...\\\" forProperty:@\\\"country\\\"];\\n   [user setValue:@\\\"...\\\" forProperty:@\\\"...\\\"];\\n        \\n   NSArray * arrValue = [NSArray arrayWithObjects: @\\\"Attr1\\\",@\\\"Attr2\\\",@\\\"Attr3\\\", nil];\\n   [user setValue:@\\\"...\\\" forProperty:@\\\"...\\\"];\\n    \\n   // Submit change to the cloud \\n   [user saveWithBlock:^(MOCAUser *user, NSError *error) {\\n      if (error) {\\n          NSLog(@\\\"Save user failed: %@\\\", error);\\n      }\\n   }];\\n}\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"User log-out.\"\n}\n[/block]\nThis code sample shows how to inform MOCA that a user has logged out from the app.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"   . . . \\n   // Notify MOCA, the user logged out\\n   MOCAUser * loggedInUser = [[MOCA currentInstance] currentUser];\\n   if (loggedInUser) {\\n        [loggedInUser logout];\\n        // Submit change to the cloud \\n        [loggedInUser saveWithBlock:^(MOCAUser *user, NSError *error) {\\n            if (error) {\\n                NSLog(@\\\"Save user failed: %@\\\", error);\\n            }\\n        }];\\n   }\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Receive push notification.\"\n}\n[/block]\nThis code sample shows how to handle MOCA-specific local push notifications and also track remote push notifications received by the app.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#pragma mark Notifications\\n\\n- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo\\n{\\n    if (MOCA.initialized)\\n    {\\n        [MOCA handleRemoteNotification:userInfo];\\n    }\\n}\\n\\n- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification\\n{\\n    if (MOCA.initialized)\\n    {\\n        [MOCA handleLocalNotification:notification];\\n    }\\n}\\n// Called when your app has been activated by the user selecting an action from a local notification.\\n// A nil action identifier indicates the default action.\\n// You should call the completion handler as soon as you've finished handling the action.\\n- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier\\n    forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler\\n{\\n    if (MOCA.initialized && [MOCA isMocaNotification:notification])\\n    {\\n        [MOCA handleActionWithIdentifier:identifier\\n                    forLocalNotification:notification];\\n    }\\n    if (completionHandler) completionHandler ();\\n}\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Register device token\"\n}\n[/block]\nThis code sample shows how to notify MOCA about an existing device token for push notification. This is used when the app is integrated with other third-party push SDKs such as Urban Airship SDK, Parse SDK or a SDK from any other push provider.\n\nIn such a scenario, MOCA is limited to handling its proper local push notifications and remains compatible with existing third-party SDKs.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#pragma mark Notifications\\n\\n-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken\\n{\\n    if ([MOCA initialized]) {\\n        [MOCA registerDeviceToken:deviceToken];\\n    }\\n}\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Fetch campaigns\"\n}\n[/block]\nThis code sample shows how to periodically fetch proximity campaigns from MOCA cloud backend. This example uses iOS Background Fetch mechanism to delegate handling of synchronization and content download to iOS.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#pragma mark Fetch Campaigns\\n\\n/// Applications with the \\\"fetch\\\" background mode may be given opportunities to fetch updated\\n// content in the background or when it is convenient for the system. This method will be called\\n// in these situations. You should call the fetchCompletionHandler\\n// as soon as you're finished performing that operation, so the system can accurately\\n// estimate its power and data cost.\\n- (void)application:(UIApplication *)application performFetchWithCompletionHandler:\\n(void (^)(UIBackgroundFetchResult result))completionHandler\\n{\\n    if (MOCA.initialized)\\n    {\\n        [MOCA performFetchWithCompletionHandler:completionHandler];\\n    }\\n}\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Force fetch campaigns\"\n}\n[/block]\nAdditionally, the app may force fetch the campaigns by calling performFetchWithCompletionHandler:completionHandler method in app-specific conditions. \n\nFor example, the app may force the synchronization on begin of each session.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"/// Asynchronously update campaigns (on request)\\n    if (MOCA.initialized)\\n    {\\n        [MOCA performFetchWithCompletionHandler:completionHandler];\\n    }\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Track in-app navigation.\"\n}\n[/block]\nThis sample code shows how to track custom events with the app, in particular, how to record a user opening a particular app window.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#Add to each View Controller to be tracked\\n\\n[MOCAEvent track:@\\\"view\\\" forItem:@\\\"screenName\\\" belongingTo:@\\\"screen\\\"];\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Track custom event.\"\n}\n[/block]\nThis sample code shows how to track a generic, custom event within the app.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"# Track custom events\\n\\n[MOCAEvent track:@”verb\\\" forItem:@”item\\\" belongingTo:@”category” . . . ];\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]","category":"55a589ddaaf9cf1900114dd0","createdAt":"2015-07-15T07:58:38.276Z","parentDoc":null,"user":"55a575ebaaf9cf1900114d73","version":"559a61d2dbcfd20d00710b3c","githubsync":"","isReference":false,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Integration Examples


The typical integration scenarios include handling of the following in-app events: * Launch app * User Login * User Logout * Receive Push Notification * Registered for Remote Push Notifications * Fetch Campaigns * Enter Screen * Custom Events [block:api-header] { "type": "basic", "title": "Launch app" } [/block] This code sample shows how to initialize MOCA SDK on app startup and also handle situations when the app is started by opening a push notification. [block:code] { "codes": [ { "code": "- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n // Init MOCA SDK\n [MOCA initializeSDK];\n if (launchOptions != nil) {\n // Launched from push notification\n NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];\n if (notification) {\n // Notify MOCA the app started from push\n [MOCA handleRemoteNotification:notification];\n }\n }\n // Optionally, set guest properties\n MOCAInstance * currentInstance = [MOCA currentInstance];\n if (currentInstance) {\n [currentInstance setValue:@\"property_1_value\" forProperty:@\"guest_property_1\"];\n [currentInstance setValue:@\"property_2_value\" forProperty:@\"guest_property_2\"];\n [currentInstance setValue:[NSNumber numberWithDouble:property3_value] forProperty:@\"guest_property_3\"];\n \n // Submit change to the cloud \n [currentInstance saveWithBlock:^(MOCAInstance *instance, NSError *error) {\n if (error) {\n NSLog(@\"Save instance failed: %@\", error);\n }\n }];\n }\n}\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "User log-in" } [/block] This code sample shows how to inform MOCA that a user has logged into the app. This call should be executed each time the user performs the log in, even if the app persists user session on app close. [block:code] { "codes": [ { "code": " // Notify MOCA, the user logged in. Must be called after each app launch.\n\n NSString * userId = ...\n MOCAUser *user = [[MOCA currentInstance] login:loginMgr.username];\n \n [user setValue:@”paidComplete\" forProperty:@\"paymentStatus\"];\n [user setValue:@\"...\" forProperty:@\"pictureStatus\"];\n [user setValue:@\"...\" forProperty:@\"merchantId\"];\n [user setValue:@\"...\" forProperty:@\"jobTitle\"];\n [user setValue:@\"...\" forProperty:@\"companyName\"];\n [user setValue:@\"...\" forProperty:@\"country\"];\n [user setValue:@\"...\" forProperty:@\"...\"];\n \n NSArray * arrValue = [NSArray arrayWithObjects: @\"Attr1\",@\"Attr2\",@\"Attr3\", nil];\n [user setValue:@\"...\" forProperty:@\"...\"];\n \n // Submit change to the cloud \n [user saveWithBlock:^(MOCAUser *user, NSError *error) {\n if (error) {\n NSLog(@\"Save user failed: %@\", error);\n }\n }];\n}\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "User log-out." } [/block] This code sample shows how to inform MOCA that a user has logged out from the app. [block:code] { "codes": [ { "code": " . . . \n // Notify MOCA, the user logged out\n MOCAUser * loggedInUser = [[MOCA currentInstance] currentUser];\n if (loggedInUser) {\n [loggedInUser logout];\n // Submit change to the cloud \n [loggedInUser saveWithBlock:^(MOCAUser *user, NSError *error) {\n if (error) {\n NSLog(@\"Save user failed: %@\", error);\n }\n }];\n }\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Receive push notification." } [/block] This code sample shows how to handle MOCA-specific local push notifications and also track remote push notifications received by the app. [block:code] { "codes": [ { "code": "#pragma mark Notifications\n\n- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo\n{\n if (MOCA.initialized)\n {\n [MOCA handleRemoteNotification:userInfo];\n }\n}\n\n- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification\n{\n if (MOCA.initialized)\n {\n [MOCA handleLocalNotification:notification];\n }\n}\n// Called when your app has been activated by the user selecting an action from a local notification.\n// A nil action identifier indicates the default action.\n// You should call the completion handler as soon as you've finished handling the action.\n- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier\n forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler\n{\n if (MOCA.initialized && [MOCA isMocaNotification:notification])\n {\n [MOCA handleActionWithIdentifier:identifier\n forLocalNotification:notification];\n }\n if (completionHandler) completionHandler ();\n}\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Register device token" } [/block] This code sample shows how to notify MOCA about an existing device token for push notification. This is used when the app is integrated with other third-party push SDKs such as Urban Airship SDK, Parse SDK or a SDK from any other push provider. In such a scenario, MOCA is limited to handling its proper local push notifications and remains compatible with existing third-party SDKs. [block:code] { "codes": [ { "code": "#pragma mark Notifications\n\n-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken\n{\n if ([MOCA initialized]) {\n [MOCA registerDeviceToken:deviceToken];\n }\n}\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Fetch campaigns" } [/block] This code sample shows how to periodically fetch proximity campaigns from MOCA cloud backend. This example uses iOS Background Fetch mechanism to delegate handling of synchronization and content download to iOS. [block:code] { "codes": [ { "code": "#pragma mark Fetch Campaigns\n\n/// Applications with the \"fetch\" background mode may be given opportunities to fetch updated\n// content in the background or when it is convenient for the system. This method will be called\n// in these situations. You should call the fetchCompletionHandler\n// as soon as you're finished performing that operation, so the system can accurately\n// estimate its power and data cost.\n- (void)application:(UIApplication *)application performFetchWithCompletionHandler:\n(void (^)(UIBackgroundFetchResult result))completionHandler\n{\n if (MOCA.initialized)\n {\n [MOCA performFetchWithCompletionHandler:completionHandler];\n }\n}\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Force fetch campaigns" } [/block] Additionally, the app may force fetch the campaigns by calling performFetchWithCompletionHandler:completionHandler method in app-specific conditions. For example, the app may force the synchronization on begin of each session. [block:code] { "codes": [ { "code": "/// Asynchronously update campaigns (on request)\n if (MOCA.initialized)\n {\n [MOCA performFetchWithCompletionHandler:completionHandler];\n }\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Track in-app navigation." } [/block] This sample code shows how to track custom events with the app, in particular, how to record a user opening a particular app window. [block:code] { "codes": [ { "code": "#Add to each View Controller to be tracked\n\n[MOCAEvent track:@\"view\" forItem:@\"screenName\" belongingTo:@\"screen\"];\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Track custom event." } [/block] This sample code shows how to track a generic, custom event within the app. [block:code] { "codes": [ { "code": "# Track custom events\n\n[MOCAEvent track:@”verb\" forItem:@”item\" belongingTo:@”category” . . . ];\n", "language": "objectivec" } ] } [/block]
The typical integration scenarios include handling of the following in-app events: * Launch app * User Login * User Logout * Receive Push Notification * Registered for Remote Push Notifications * Fetch Campaigns * Enter Screen * Custom Events [block:api-header] { "type": "basic", "title": "Launch app" } [/block] This code sample shows how to initialize MOCA SDK on app startup and also handle situations when the app is started by opening a push notification. [block:code] { "codes": [ { "code": "- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n // Init MOCA SDK\n [MOCA initializeSDK];\n if (launchOptions != nil) {\n // Launched from push notification\n NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];\n if (notification) {\n // Notify MOCA the app started from push\n [MOCA handleRemoteNotification:notification];\n }\n }\n // Optionally, set guest properties\n MOCAInstance * currentInstance = [MOCA currentInstance];\n if (currentInstance) {\n [currentInstance setValue:@\"property_1_value\" forProperty:@\"guest_property_1\"];\n [currentInstance setValue:@\"property_2_value\" forProperty:@\"guest_property_2\"];\n [currentInstance setValue:[NSNumber numberWithDouble:property3_value] forProperty:@\"guest_property_3\"];\n \n // Submit change to the cloud \n [currentInstance saveWithBlock:^(MOCAInstance *instance, NSError *error) {\n if (error) {\n NSLog(@\"Save instance failed: %@\", error);\n }\n }];\n }\n}\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "User log-in" } [/block] This code sample shows how to inform MOCA that a user has logged into the app. This call should be executed each time the user performs the log in, even if the app persists user session on app close. [block:code] { "codes": [ { "code": " // Notify MOCA, the user logged in. Must be called after each app launch.\n\n NSString * userId = ...\n MOCAUser *user = [[MOCA currentInstance] login:loginMgr.username];\n \n [user setValue:@”paidComplete\" forProperty:@\"paymentStatus\"];\n [user setValue:@\"...\" forProperty:@\"pictureStatus\"];\n [user setValue:@\"...\" forProperty:@\"merchantId\"];\n [user setValue:@\"...\" forProperty:@\"jobTitle\"];\n [user setValue:@\"...\" forProperty:@\"companyName\"];\n [user setValue:@\"...\" forProperty:@\"country\"];\n [user setValue:@\"...\" forProperty:@\"...\"];\n \n NSArray * arrValue = [NSArray arrayWithObjects: @\"Attr1\",@\"Attr2\",@\"Attr3\", nil];\n [user setValue:@\"...\" forProperty:@\"...\"];\n \n // Submit change to the cloud \n [user saveWithBlock:^(MOCAUser *user, NSError *error) {\n if (error) {\n NSLog(@\"Save user failed: %@\", error);\n }\n }];\n}\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "User log-out." } [/block] This code sample shows how to inform MOCA that a user has logged out from the app. [block:code] { "codes": [ { "code": " . . . \n // Notify MOCA, the user logged out\n MOCAUser * loggedInUser = [[MOCA currentInstance] currentUser];\n if (loggedInUser) {\n [loggedInUser logout];\n // Submit change to the cloud \n [loggedInUser saveWithBlock:^(MOCAUser *user, NSError *error) {\n if (error) {\n NSLog(@\"Save user failed: %@\", error);\n }\n }];\n }\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Receive push notification." } [/block] This code sample shows how to handle MOCA-specific local push notifications and also track remote push notifications received by the app. [block:code] { "codes": [ { "code": "#pragma mark Notifications\n\n- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo\n{\n if (MOCA.initialized)\n {\n [MOCA handleRemoteNotification:userInfo];\n }\n}\n\n- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification\n{\n if (MOCA.initialized)\n {\n [MOCA handleLocalNotification:notification];\n }\n}\n// Called when your app has been activated by the user selecting an action from a local notification.\n// A nil action identifier indicates the default action.\n// You should call the completion handler as soon as you've finished handling the action.\n- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier\n forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler\n{\n if (MOCA.initialized && [MOCA isMocaNotification:notification])\n {\n [MOCA handleActionWithIdentifier:identifier\n forLocalNotification:notification];\n }\n if (completionHandler) completionHandler ();\n}\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Register device token" } [/block] This code sample shows how to notify MOCA about an existing device token for push notification. This is used when the app is integrated with other third-party push SDKs such as Urban Airship SDK, Parse SDK or a SDK from any other push provider. In such a scenario, MOCA is limited to handling its proper local push notifications and remains compatible with existing third-party SDKs. [block:code] { "codes": [ { "code": "#pragma mark Notifications\n\n-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken\n{\n if ([MOCA initialized]) {\n [MOCA registerDeviceToken:deviceToken];\n }\n}\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Fetch campaigns" } [/block] This code sample shows how to periodically fetch proximity campaigns from MOCA cloud backend. This example uses iOS Background Fetch mechanism to delegate handling of synchronization and content download to iOS. [block:code] { "codes": [ { "code": "#pragma mark Fetch Campaigns\n\n/// Applications with the \"fetch\" background mode may be given opportunities to fetch updated\n// content in the background or when it is convenient for the system. This method will be called\n// in these situations. You should call the fetchCompletionHandler\n// as soon as you're finished performing that operation, so the system can accurately\n// estimate its power and data cost.\n- (void)application:(UIApplication *)application performFetchWithCompletionHandler:\n(void (^)(UIBackgroundFetchResult result))completionHandler\n{\n if (MOCA.initialized)\n {\n [MOCA performFetchWithCompletionHandler:completionHandler];\n }\n}\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Force fetch campaigns" } [/block] Additionally, the app may force fetch the campaigns by calling performFetchWithCompletionHandler:completionHandler method in app-specific conditions. For example, the app may force the synchronization on begin of each session. [block:code] { "codes": [ { "code": "/// Asynchronously update campaigns (on request)\n if (MOCA.initialized)\n {\n [MOCA performFetchWithCompletionHandler:completionHandler];\n }\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Track in-app navigation." } [/block] This sample code shows how to track custom events with the app, in particular, how to record a user opening a particular app window. [block:code] { "codes": [ { "code": "#Add to each View Controller to be tracked\n\n[MOCAEvent track:@\"view\" forItem:@\"screenName\" belongingTo:@\"screen\"];\n", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "Track custom event." } [/block] This sample code shows how to track a generic, custom event within the app. [block:code] { "codes": [ { "code": "# Track custom events\n\n[MOCAEvent track:@”verb\" forItem:@”item\" belongingTo:@”category” . . . ];\n", "language": "objectivec" } ] } [/block]
{"_id":"55a5921d80c8a30d00b32413","body":"Congratulations! After all the hard work you are finally ready to ship your app.\nLet's review the following checklist, just to be sure everything goes smoothly.\n\n- Ensure your `App Key` and `App Secret` are pointing to your production App.\n- Change the log level in the `MOCAConfig.plist` / `AndroidManifest.xml` of your app to `info`, instead of `debug`.\n- Ensure no *test* campaigns are active in the production App.\n\n##Uploading to iTunes Connect\n\n###App Review Information\n\nMOCA SDK uses certain iOS features that need to be explained one by one to the Apple AppStore review team. When submitting app, include the following link in the \"Notes\" section of the \"App Review Information\": \n\n[Notes for AppStore review team](../page/moca-sdk-notes-for-appstore-review-team)  \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"http://developer.mocaplatform.com/v1.0/page/moca-sdk-notes-for-appstore-review-team\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/de3WTBBeT4y9wXRj2sAx_notes.png\",\n        \"notes.png\",\n        \"967\",\n        \"281\",\n        \"#dddddd\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"Avoid App Rejections\",\n  \"body\": \"By including this information in your app description, you will lower the chance of being rejected by the AppStore review team.\"\n}\n[/block]\n###App Description \n\nDespite that MOCA SDK does not use navigation-grade location (only battery-friendly modes), sometimes the AppStore review team will ask you to include the following text in your app description.\n\n`NOTE: Continued use of GPS running in the background can dramatically decrease battery life.`\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Please note\",\n  \"body\": \"This text is only required when the `BACKGROUND_LOCATION_ENABLED` is set to `YES` in your MOCAConfig.plist\"\n}\n[/block]","category":"55a589ddaaf9cf1900114dd0","createdAt":"2015-07-14T22:50:05.314Z","link_url":"","slug":"moca-ios-sdk-submitting-your-app-to-the-store","title":"Submitting Your App to the Store","updates":[],"__v":24,"githubsync":"","sync_unique":"","version":"559a61d2dbcfd20d00710b3c","api":{"params":[],"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"name":"","status":400,"language":"json","code":"{}"}]},"settings":"","url":"","auth":"required"},"excerpt":"","isReference":false,"link_external":false,"user":"55a575ebaaf9cf1900114d73","hidden":false,"order":5,"parentDoc":null,"project":"559a61d2dbcfd20d00710b39","type":"basic","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Submitting Your App to the Store


Congratulations! After all the hard work you are finally ready to ship your app. Let's review the following checklist, just to be sure everything goes smoothly. - Ensure your `App Key` and `App Secret` are pointing to your production App. - Change the log level in the `MOCAConfig.plist` / `AndroidManifest.xml` of your app to `info`, instead of `debug`. - Ensure no *test* campaigns are active in the production App. ##Uploading to iTunes Connect ###App Review Information MOCA SDK uses certain iOS features that need to be explained one by one to the Apple AppStore review team. When submitting app, include the following link in the "Notes" section of the "App Review Information": [Notes for AppStore review team](../page/moca-sdk-notes-for-appstore-review-team) [block:code] { "codes": [ { "code": "http://developer.mocaplatform.com/v1.0/page/moca-sdk-notes-for-appstore-review-team", "language": "text" } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/de3WTBBeT4y9wXRj2sAx_notes.png", "notes.png", "967", "281", "#dddddd", "" ] } ] } [/block] [block:callout] { "type": "success", "title": "Avoid App Rejections", "body": "By including this information in your app description, you will lower the chance of being rejected by the AppStore review team." } [/block] ###App Description Despite that MOCA SDK does not use navigation-grade location (only battery-friendly modes), sometimes the AppStore review team will ask you to include the following text in your app description. `NOTE: Continued use of GPS running in the background can dramatically decrease battery life.` [block:callout] { "type": "info", "title": "Please note", "body": "This text is only required when the `BACKGROUND_LOCATION_ENABLED` is set to `YES` in your MOCAConfig.plist" } [/block]
Congratulations! After all the hard work you are finally ready to ship your app. Let's review the following checklist, just to be sure everything goes smoothly. - Ensure your `App Key` and `App Secret` are pointing to your production App. - Change the log level in the `MOCAConfig.plist` / `AndroidManifest.xml` of your app to `info`, instead of `debug`. - Ensure no *test* campaigns are active in the production App. ##Uploading to iTunes Connect ###App Review Information MOCA SDK uses certain iOS features that need to be explained one by one to the Apple AppStore review team. When submitting app, include the following link in the "Notes" section of the "App Review Information": [Notes for AppStore review team](../page/moca-sdk-notes-for-appstore-review-team) [block:code] { "codes": [ { "code": "http://developer.mocaplatform.com/v1.0/page/moca-sdk-notes-for-appstore-review-team", "language": "text" } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/de3WTBBeT4y9wXRj2sAx_notes.png", "notes.png", "967", "281", "#dddddd", "" ] } ] } [/block] [block:callout] { "type": "success", "title": "Avoid App Rejections", "body": "By including this information in your app description, you will lower the chance of being rejected by the AppStore review team." } [/block] ###App Description Despite that MOCA SDK does not use navigation-grade location (only battery-friendly modes), sometimes the AppStore review team will ask you to include the following text in your app description. `NOTE: Continued use of GPS running in the background can dramatically decrease battery life.` [block:callout] { "type": "info", "title": "Please note", "body": "This text is only required when the `BACKGROUND_LOCATION_ENABLED` is set to `YES` in your MOCAConfig.plist" } [/block]
{"_id":"57961400287f330e000fb524","slug":"remote-push-notifications-apns-setup","title":"APNS: Certificates for push notifications","user":"559a618bdbcfd20d00710b38","body":"MOCA Platform uses [Apple Push Notification Service](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html) (APNS) to deliver notifications to your iOS users. Please bear in mind this is only for remote push notifications, and **this is not mandatory for location based notifications** (Proximity Experiences).\n\n\n###Before starting\n\nIn order to get the certificates and upload them to MOCA, you will need:\n\n- A membership in the [Apple iOS developer program](https://developer.apple.com/programs/)\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Enable Remote Push Notifications on your App ID\"\n}\n[/block]\n- Sign in to your account in the [Apple developer center](https://developer.apple.com/account/\n), and then go to **Certificates, Identifiers & Profiles**\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/444df5c-CertsIdentiProfs.png\",\n        \"CertsIdentiProfs.png\",\n        707,\n        298,\n        \"#fbfbfb\"\n      ]\n    }\n  ]\n}\n[/block]\n- Each App should have an App ID, click the App ID that corresponds to your App (or create it if you have not already done so). In any case, ensure that the Push Notifications service is enabled.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/6a1106c-APNS_on.png\",\n        \"APNS_on.png\",\n        635,\n        696,\n        \"#3f4241\"\n      ]\n    }\n  ]\n}\n[/block]\n- Click on the `Development` or `Production` certificate button and follow the steps.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Exporting certificates\"\n}\n[/block]\n- Open the `KeyChain Access` App of your Mac, there you will find the certificates that you downloaded in the previous step.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"This application may have different names depending on your Mac language configuration:\",\n  \"body\": \"Català: “Accés a clauers”\\nEspañol: \\\"Acceso a llaveros\\\"\\nFrançais: \\\"Trousseau d'accès\\\"\\nPortuguês: \\\"Acesso às Chaves\\\"\"\n}\n[/block]\n- Right click on the certificate, and select \"Export ....\". Select the `p12` format and create a password for the file, do not lose this password as you will need it a next step.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/462ecb2-keychain_access.png\",\n        \"keychain_access.png\",\n        662,\n        364,\n        \"#eeeeed\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Production vs Development\",\n  \"body\": \"Ensure that the App in MOCA Console is pointing to the right servers. Production certificates won't work for Development apps and vice versa.\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Warning\",\n  \"body\": \"Do not submit Apps to Apple with Development certificates.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Uploading the certificates to MOCA Console\"\n}\n[/block]\n- Login in to your MOCA Account, and go to Apps **>** *app_to_be_configured* ** >** Settings **>** Services\n- Upload the file using the Add button in the \"APNS\" section, you will need the password you created in a previous step.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/791a0f6-APNS_upload.png\",\n        \"APNS_upload.png\",\n        778,\n        669,\n        \"#efefed\"\n      ]\n    }\n  ]\n}\n[/block]\n- All done. You can now start sending notifications to your users using MOCA Platform.","category":"55a589ddaaf9cf1900114dd0","hidden":false,"isReference":false,"link_external":false,"type":"basic","__v":0,"githubsync":"","link_url":"","updates":[],"version":"559a61d2dbcfd20d00710b3c","project":"559a61d2dbcfd20d00710b39","sync_unique":"","api":{"url":"","results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","auth":"required","params":[]},"createdAt":"2016-07-25T13:28:32.384Z","excerpt":"","order":6,"parentDoc":null,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

APNS: Certificates for push notifications


MOCA Platform uses [Apple Push Notification Service](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html) (APNS) to deliver notifications to your iOS users. Please bear in mind this is only for remote push notifications, and **this is not mandatory for location based notifications** (Proximity Experiences). ###Before starting In order to get the certificates and upload them to MOCA, you will need: - A membership in the [Apple iOS developer program](https://developer.apple.com/programs/) [block:api-header] { "type": "basic", "title": "Enable Remote Push Notifications on your App ID" } [/block] - Sign in to your account in the [Apple developer center](https://developer.apple.com/account/ ), and then go to **Certificates, Identifiers & Profiles** [block:image] { "images": [ { "image": [ "https://files.readme.io/444df5c-CertsIdentiProfs.png", "CertsIdentiProfs.png", 707, 298, "#fbfbfb" ] } ] } [/block] - Each App should have an App ID, click the App ID that corresponds to your App (or create it if you have not already done so). In any case, ensure that the Push Notifications service is enabled. [block:image] { "images": [ { "image": [ "https://files.readme.io/6a1106c-APNS_on.png", "APNS_on.png", 635, 696, "#3f4241" ] } ] } [/block] - Click on the `Development` or `Production` certificate button and follow the steps. [block:api-header] { "type": "basic", "title": "Exporting certificates" } [/block] - Open the `KeyChain Access` App of your Mac, there you will find the certificates that you downloaded in the previous step. [block:callout] { "type": "info", "title": "This application may have different names depending on your Mac language configuration:", "body": "Català: “Accés a clauers”\nEspañol: \"Acceso a llaveros\"\nFrançais: \"Trousseau d'accès\"\nPortuguês: \"Acesso às Chaves\"" } [/block] - Right click on the certificate, and select "Export ....". Select the `p12` format and create a password for the file, do not lose this password as you will need it a next step. [block:image] { "images": [ { "image": [ "https://files.readme.io/462ecb2-keychain_access.png", "keychain_access.png", 662, 364, "#eeeeed" ] } ] } [/block] [block:callout] { "type": "danger", "title": "Production vs Development", "body": "Ensure that the App in MOCA Console is pointing to the right servers. Production certificates won't work for Development apps and vice versa." } [/block] [block:callout] { "type": "warning", "title": "Warning", "body": "Do not submit Apps to Apple with Development certificates." } [/block] [block:api-header] { "type": "basic", "title": "Uploading the certificates to MOCA Console" } [/block] - Login in to your MOCA Account, and go to Apps **>** *app_to_be_configured* ** >** Settings **>** Services - Upload the file using the Add button in the "APNS" section, you will need the password you created in a previous step. [block:image] { "images": [ { "image": [ "https://files.readme.io/791a0f6-APNS_upload.png", "APNS_upload.png", 778, 669, "#efefed" ] } ] } [/block] - All done. You can now start sending notifications to your users using MOCA Platform.
MOCA Platform uses [Apple Push Notification Service](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html) (APNS) to deliver notifications to your iOS users. Please bear in mind this is only for remote push notifications, and **this is not mandatory for location based notifications** (Proximity Experiences). ###Before starting In order to get the certificates and upload them to MOCA, you will need: - A membership in the [Apple iOS developer program](https://developer.apple.com/programs/) [block:api-header] { "type": "basic", "title": "Enable Remote Push Notifications on your App ID" } [/block] - Sign in to your account in the [Apple developer center](https://developer.apple.com/account/ ), and then go to **Certificates, Identifiers & Profiles** [block:image] { "images": [ { "image": [ "https://files.readme.io/444df5c-CertsIdentiProfs.png", "CertsIdentiProfs.png", 707, 298, "#fbfbfb" ] } ] } [/block] - Each App should have an App ID, click the App ID that corresponds to your App (or create it if you have not already done so). In any case, ensure that the Push Notifications service is enabled. [block:image] { "images": [ { "image": [ "https://files.readme.io/6a1106c-APNS_on.png", "APNS_on.png", 635, 696, "#3f4241" ] } ] } [/block] - Click on the `Development` or `Production` certificate button and follow the steps. [block:api-header] { "type": "basic", "title": "Exporting certificates" } [/block] - Open the `KeyChain Access` App of your Mac, there you will find the certificates that you downloaded in the previous step. [block:callout] { "type": "info", "title": "This application may have different names depending on your Mac language configuration:", "body": "Català: “Accés a clauers”\nEspañol: \"Acceso a llaveros\"\nFrançais: \"Trousseau d'accès\"\nPortuguês: \"Acesso às Chaves\"" } [/block] - Right click on the certificate, and select "Export ....". Select the `p12` format and create a password for the file, do not lose this password as you will need it a next step. [block:image] { "images": [ { "image": [ "https://files.readme.io/462ecb2-keychain_access.png", "keychain_access.png", 662, 364, "#eeeeed" ] } ] } [/block] [block:callout] { "type": "danger", "title": "Production vs Development", "body": "Ensure that the App in MOCA Console is pointing to the right servers. Production certificates won't work for Development apps and vice versa." } [/block] [block:callout] { "type": "warning", "title": "Warning", "body": "Do not submit Apps to Apple with Development certificates." } [/block] [block:api-header] { "type": "basic", "title": "Uploading the certificates to MOCA Console" } [/block] - Login in to your MOCA Account, and go to Apps **>** *app_to_be_configured* ** >** Settings **>** Services - Upload the file using the Add button in the "APNS" section, you will need the password you created in a previous step. [block:image] { "images": [ { "image": [ "https://files.readme.io/791a0f6-APNS_upload.png", "APNS_upload.png", 778, 669, "#efefed" ] } ] } [/block] - All done. You can now start sending notifications to your users using MOCA Platform.
{"_id":"55a611ec80c8a30d00b32502","parentDoc":null,"type":"basic","updates":[],"api":{"auth":"required","params":[],"results":{"codes":[{"language":"json","code":"{}","name":"","status":200},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"createdAt":"2015-07-15T07:55:24.877Z","githubsync":"","slug":"moca-ios-sdk-api","sync_unique":"","__v":8,"hidden":false,"link_url":"","title":"MOCA API","version":"559a61d2dbcfd20d00710b3c","category":"55a8e7a227a17d21005251a2","excerpt":"","isReference":false,"link_external":false,"order":0,"project":"559a61d2dbcfd20d00710b39","user":"55a575ebaaf9cf1900114d73","body":"The **MOCA shared object** is a main entry point to MOCA APIs.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"@interface MOCA : NSObject\\n\\n// Gets the version of the MOCA library.\\n+ (NSString*) version;\\n\\n// Initializes the library with the configuration from MOCAConfig.plist resource file\\n+ (BOOL) initializeSDK:(MOCAConfig *)config;\\n\\n// Gets library configuration.\\n+ (MOCAConfig*) config;\\n\\n// Gets the application key once successfully initialized.\\n+ (NSString*) appKey;\\n\\n// Gets the application secret once successfully initialized.\\n+ (NSString*) appSecret;\\n\\n// Returns `YES` if the MOCA library has been initialized and is ready for use.\\n+ (BOOL) initialized;\\n\\n// Gets the current MOCA app instance object.\\n+ (MOCAInstance*) currentInstance;\\n\\n// Gets the current proximity service object. Available starting from iOS 7.\\n+ (MOCAProximityService*) proximityService;\\n\\n// Gets access to MOCA inbox.\\u000b+ (MOCAInbox*) inbox;\\n\\n// Gets the current log level of MOCA library.\\n+ (MOCALogLevel) logLevel;\\n\\n// Sets the log level.\\n+ (void) setLogLevel:(MOCALogLevel)logLevel;\\n\\n// Tells MOCA that it can begin a cloud fetch operation if it has data to download.\\n+(BOOL)performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler;\\n\\n// Updates the push device token and registers the token with MOCA cloud.\\n+(void)registerDeviceToken:(NSData*)deviceToken;\\n\\n// Tells MOCA that a remote push notification has been received by the application.\\n+(void)handleRemoteNotification:(NSDictionary *)userInfo;\\n\\n// Tells MOCA that a local push notification has been received by the application.\\n+(void)handleLocalNotification:(UILocalNotification*)notification;\\n\\n// Checks if this specific local notifaction contains MOCA content.\\n+(BOOL)isMOCANotification:(UILocalNotification*)notification;\\n\\u000b// Called when your app has been activated by the user selecting an action \\u000b// from a local notification.\\n+(BOOL)handleActionWithIdentifier:(NSString*)identifier \\u000b             forLocalNotification:(UILocalNotification*)notification;\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

MOCA API


The **MOCA shared object** is a main entry point to MOCA APIs. [block:code] { "codes": [ { "code": "@interface MOCA : NSObject\n\n// Gets the version of the MOCA library.\n+ (NSString*) version;\n\n// Initializes the library with the configuration from MOCAConfig.plist resource file\n+ (BOOL) initializeSDK:(MOCAConfig *)config;\n\n// Gets library configuration.\n+ (MOCAConfig*) config;\n\n// Gets the application key once successfully initialized.\n+ (NSString*) appKey;\n\n// Gets the application secret once successfully initialized.\n+ (NSString*) appSecret;\n\n// Returns `YES` if the MOCA library has been initialized and is ready for use.\n+ (BOOL) initialized;\n\n// Gets the current MOCA app instance object.\n+ (MOCAInstance*) currentInstance;\n\n// Gets the current proximity service object. Available starting from iOS 7.\n+ (MOCAProximityService*) proximityService;\n\n// Gets access to MOCA inbox.\u000b+ (MOCAInbox*) inbox;\n\n// Gets the current log level of MOCA library.\n+ (MOCALogLevel) logLevel;\n\n// Sets the log level.\n+ (void) setLogLevel:(MOCALogLevel)logLevel;\n\n// Tells MOCA that it can begin a cloud fetch operation if it has data to download.\n+(BOOL)performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler;\n\n// Updates the push device token and registers the token with MOCA cloud.\n+(void)registerDeviceToken:(NSData*)deviceToken;\n\n// Tells MOCA that a remote push notification has been received by the application.\n+(void)handleRemoteNotification:(NSDictionary *)userInfo;\n\n// Tells MOCA that a local push notification has been received by the application.\n+(void)handleLocalNotification:(UILocalNotification*)notification;\n\n// Checks if this specific local notifaction contains MOCA content.\n+(BOOL)isMOCANotification:(UILocalNotification*)notification;\n\u000b// Called when your app has been activated by the user selecting an action \u000b// from a local notification.\n+(BOOL)handleActionWithIdentifier:(NSString*)identifier \u000b forLocalNotification:(UILocalNotification*)notification;\n", "language": "objectivec" } ] } [/block]
The **MOCA shared object** is a main entry point to MOCA APIs. [block:code] { "codes": [ { "code": "@interface MOCA : NSObject\n\n// Gets the version of the MOCA library.\n+ (NSString*) version;\n\n// Initializes the library with the configuration from MOCAConfig.plist resource file\n+ (BOOL) initializeSDK:(MOCAConfig *)config;\n\n// Gets library configuration.\n+ (MOCAConfig*) config;\n\n// Gets the application key once successfully initialized.\n+ (NSString*) appKey;\n\n// Gets the application secret once successfully initialized.\n+ (NSString*) appSecret;\n\n// Returns `YES` if the MOCA library has been initialized and is ready for use.\n+ (BOOL) initialized;\n\n// Gets the current MOCA app instance object.\n+ (MOCAInstance*) currentInstance;\n\n// Gets the current proximity service object. Available starting from iOS 7.\n+ (MOCAProximityService*) proximityService;\n\n// Gets access to MOCA inbox.\u000b+ (MOCAInbox*) inbox;\n\n// Gets the current log level of MOCA library.\n+ (MOCALogLevel) logLevel;\n\n// Sets the log level.\n+ (void) setLogLevel:(MOCALogLevel)logLevel;\n\n// Tells MOCA that it can begin a cloud fetch operation if it has data to download.\n+(BOOL)performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler;\n\n// Updates the push device token and registers the token with MOCA cloud.\n+(void)registerDeviceToken:(NSData*)deviceToken;\n\n// Tells MOCA that a remote push notification has been received by the application.\n+(void)handleRemoteNotification:(NSDictionary *)userInfo;\n\n// Tells MOCA that a local push notification has been received by the application.\n+(void)handleLocalNotification:(UILocalNotification*)notification;\n\n// Checks if this specific local notifaction contains MOCA content.\n+(BOOL)isMOCANotification:(UILocalNotification*)notification;\n\u000b// Called when your app has been activated by the user selecting an action \u000b// from a local notification.\n+(BOOL)handleActionWithIdentifier:(NSString*)identifier \u000b forLocalNotification:(UILocalNotification*)notification;\n", "language": "objectivec" } ] } [/block]
{"_id":"55a8feb327a17d2100525201","order":1,"project":"559a61d2dbcfd20d00710b39","title":"Instance API","updates":[],"user":"559a618bdbcfd20d00710b38","githubsync":"","isReference":false,"slug":"instance-api","sync_unique":"","type":"basic","version":"559a61d2dbcfd20d00710b3c","createdAt":"2015-07-17T13:10:11.115Z","excerpt":"","hidden":false,"parentDoc":null,"__v":8,"body":"- The app `Instance object` is a local representation of an app instance downloaded and installed in a user device. \n- The instance object is **automatically managed** by MOCA. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"MOCAInstance * theInstance = [MOCA currentInstance];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n- The instance object holds a **collection of properties**. Property-value pairs can be set and retrieved and are persisted between app sessions.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"/**\\n * Sets the value for the given property name.\\n * \\n * @param value Value to be set. It must belong to one of the accepted classes.\\n * @param prop Property name.\\n */\\n- (void) setValue:(id)value forProperty:(NSString*)prop;\\n\\n/**\\n * Gets the value for the given property.\\n *\\n * @param prop Property name.\\n * @return Value associated with the property or <code>nil</code> if none.\\n */\\n- (id) valueForProperty:(NSString*)prop;\\n\\n/**\\n * Returns a new array containing all existing property names.\\n *\\n * @return A new array containing all existing property names.\\n */\\n- (NSArray*) allProperties;\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"info\",\n  \"body\": \"MOCA properties are internally stored in a local SQLite database\"\n}\n[/block]\nThe instance object holds predefined properties collected automatically:\n- `Device-oriented`, including:\n - `device_model` – the device model (i.e. iPhone 4S, iPhone 5C, iPhone 5S)\n - `device_type` – the type of device (i.e. iPhone, iPad, Simulator)\n - `local_timezone` – the local time zone's abbreviated name (i.e. EDT, GMT, PST)\n - `country` – the country code as defined by the user in `Settings\\General\\International\\Regional Format (NSLocaleCountryCode)`.\n - `lang` – the user preferred language code as defined in `Settings\\General\\International\\Language (NSLocaleLanguageCode)`.\n - `os_name` – the OS name (i.e. “iOS”)\n - `os_version` – the OS version (i.e. “7.0”)\n - `carrier_name` – the name of the user’s home cellular service provider (CTCarrier carrierName)\n - `carrier_country` – the ISO country code for the user’s cellular service provider.\n- App-oriented, including:\n - `app_name` – the app name\n - `app_version` – the app version number\n - `vendor_id` – the unique identifier for app vendor (i.e. UUID string)\n - `moca_version` – the version of MOCA SDK\n - `apns_token` – the push notification device token (optional)\n - `session` – session counter (how many times a user launched the app).\n\n- The object may also store any custom property-value pairs. \n- Each instance object is persisted both locally and in the cloud. The instance is automatically uploaded to the cloud each time the app starts.\n- The instance can be saved manually to the cloud. All saves are asynchronous.\n- It is recommended to perform as many sets as desired and then just invoke a single save operation.\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import <AdSupport/ASIdentifierManager.h>\\u000b\\n\\nMOCAInstance * theInstance = [MOCA currentInstance];    \\nif (theInstance)\\n{\\n    // Only track Advertising Identifier, if you app uses explicit Ad banners. \\n    NSString * adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; \\n    [theInstance setValue:adId forProperty:@”_ad_id\\\"];\\n    [theInstance setValue:@\\\"red\\\" forProperty:@\\\"favorite-color\\\"];\\n    [theInstance setValue:@\\\"women-cloth\\\" forKey:@\\\"last-search\\\"];\\u000b    // Asynchronously save the instance to the cloud.\\n    [theInstance saveWithBlock:^(MOCAInstance *instance, NSError *error)\\n        {\\n          if (error) NSLog(@\\\"Save instance failed: %@\\\", error);\\n        }\\n    ];\\n}\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]","category":"55a8e7a227a17d21005251a2","link_external":false,"link_url":"","api":{"auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Instance API


- The app `Instance object` is a local representation of an app instance downloaded and installed in a user device. - The instance object is **automatically managed** by MOCA. [block:code] { "codes": [ { "code": "MOCAInstance * theInstance = [MOCA currentInstance];", "language": "objectivec" } ] } [/block] - The instance object holds a **collection of properties**. Property-value pairs can be set and retrieved and are persisted between app sessions. [block:code] { "codes": [ { "code": "/**\n * Sets the value for the given property name.\n * \n * @param value Value to be set. It must belong to one of the accepted classes.\n * @param prop Property name.\n */\n- (void) setValue:(id)value forProperty:(NSString*)prop;\n\n/**\n * Gets the value for the given property.\n *\n * @param prop Property name.\n * @return Value associated with the property or <code>nil</code> if none.\n */\n- (id) valueForProperty:(NSString*)prop;\n\n/**\n * Returns a new array containing all existing property names.\n *\n * @return A new array containing all existing property names.\n */\n- (NSArray*) allProperties;", "language": "java" } ] } [/block] [block:callout] { "type": "info", "title": "info", "body": "MOCA properties are internally stored in a local SQLite database" } [/block] The instance object holds predefined properties collected automatically: - `Device-oriented`, including: - `device_model` – the device model (i.e. iPhone 4S, iPhone 5C, iPhone 5S) - `device_type` – the type of device (i.e. iPhone, iPad, Simulator) - `local_timezone` – the local time zone's abbreviated name (i.e. EDT, GMT, PST) - `country` – the country code as defined by the user in `Settings\General\International\Regional Format (NSLocaleCountryCode)`. - `lang` – the user preferred language code as defined in `Settings\General\International\Language (NSLocaleLanguageCode)`. - `os_name` – the OS name (i.e. “iOS”) - `os_version` – the OS version (i.e. “7.0”) - `carrier_name` – the name of the user’s home cellular service provider (CTCarrier carrierName) - `carrier_country` – the ISO country code for the user’s cellular service provider. - App-oriented, including: - `app_name` – the app name - `app_version` – the app version number - `vendor_id` – the unique identifier for app vendor (i.e. UUID string) - `moca_version` – the version of MOCA SDK - `apns_token` – the push notification device token (optional) - `session` – session counter (how many times a user launched the app). - The object may also store any custom property-value pairs. - Each instance object is persisted both locally and in the cloud. The instance is automatically uploaded to the cloud each time the app starts. - The instance can be saved manually to the cloud. All saves are asynchronous. - It is recommended to perform as many sets as desired and then just invoke a single save operation. [block:code] { "codes": [ { "code": "#import <AdSupport/ASIdentifierManager.h>\u000b\n\nMOCAInstance * theInstance = [MOCA currentInstance]; \nif (theInstance)\n{\n // Only track Advertising Identifier, if you app uses explicit Ad banners. \n NSString * adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; \n [theInstance setValue:adId forProperty:@”_ad_id\"];\n [theInstance setValue:@\"red\" forProperty:@\"favorite-color\"];\n [theInstance setValue:@\"women-cloth\" forKey:@\"last-search\"];\u000b // Asynchronously save the instance to the cloud.\n [theInstance saveWithBlock:^(MOCAInstance *instance, NSError *error)\n {\n if (error) NSLog(@\"Save instance failed: %@\", error);\n }\n ];\n}\n", "language": "objectivec" } ] } [/block]
- The app `Instance object` is a local representation of an app instance downloaded and installed in a user device. - The instance object is **automatically managed** by MOCA. [block:code] { "codes": [ { "code": "MOCAInstance * theInstance = [MOCA currentInstance];", "language": "objectivec" } ] } [/block] - The instance object holds a **collection of properties**. Property-value pairs can be set and retrieved and are persisted between app sessions. [block:code] { "codes": [ { "code": "/**\n * Sets the value for the given property name.\n * \n * @param value Value to be set. It must belong to one of the accepted classes.\n * @param prop Property name.\n */\n- (void) setValue:(id)value forProperty:(NSString*)prop;\n\n/**\n * Gets the value for the given property.\n *\n * @param prop Property name.\n * @return Value associated with the property or <code>nil</code> if none.\n */\n- (id) valueForProperty:(NSString*)prop;\n\n/**\n * Returns a new array containing all existing property names.\n *\n * @return A new array containing all existing property names.\n */\n- (NSArray*) allProperties;", "language": "java" } ] } [/block] [block:callout] { "type": "info", "title": "info", "body": "MOCA properties are internally stored in a local SQLite database" } [/block] The instance object holds predefined properties collected automatically: - `Device-oriented`, including: - `device_model` – the device model (i.e. iPhone 4S, iPhone 5C, iPhone 5S) - `device_type` – the type of device (i.e. iPhone, iPad, Simulator) - `local_timezone` – the local time zone's abbreviated name (i.e. EDT, GMT, PST) - `country` – the country code as defined by the user in `Settings\General\International\Regional Format (NSLocaleCountryCode)`. - `lang` – the user preferred language code as defined in `Settings\General\International\Language (NSLocaleLanguageCode)`. - `os_name` – the OS name (i.e. “iOS”) - `os_version` – the OS version (i.e. “7.0”) - `carrier_name` – the name of the user’s home cellular service provider (CTCarrier carrierName) - `carrier_country` – the ISO country code for the user’s cellular service provider. - App-oriented, including: - `app_name` – the app name - `app_version` – the app version number - `vendor_id` – the unique identifier for app vendor (i.e. UUID string) - `moca_version` – the version of MOCA SDK - `apns_token` – the push notification device token (optional) - `session` – session counter (how many times a user launched the app). - The object may also store any custom property-value pairs. - Each instance object is persisted both locally and in the cloud. The instance is automatically uploaded to the cloud each time the app starts. - The instance can be saved manually to the cloud. All saves are asynchronous. - It is recommended to perform as many sets as desired and then just invoke a single save operation. [block:code] { "codes": [ { "code": "#import <AdSupport/ASIdentifierManager.h>\u000b\n\nMOCAInstance * theInstance = [MOCA currentInstance]; \nif (theInstance)\n{\n // Only track Advertising Identifier, if you app uses explicit Ad banners. \n NSString * adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; \n [theInstance setValue:adId forProperty:@”_ad_id\"];\n [theInstance setValue:@\"red\" forProperty:@\"favorite-color\"];\n [theInstance setValue:@\"women-cloth\" forKey:@\"last-search\"];\u000b // Asynchronously save the instance to the cloud.\n [theInstance saveWithBlock:^(MOCAInstance *instance, NSError *error)\n {\n if (error) NSLog(@\"Save instance failed: %@\", error);\n }\n ];\n}\n", "language": "objectivec" } ] } [/block]
{"_id":"55a9021527a17d2100525208","body":"- The app **User object** manages information about current application user.\n- This object is **optional**, and it is used when the app needs to authenticate the user. \n- The authentication provides data about user’s identity: a unique user ID or similar. \n- The user login and logout calls are managed by the app. \u000b\n\n - To access existing User object, use currentUser property: \u000b\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Access authenticated user object\\nMOCAUser * theUser = [[MOCA currentInstance] currentUser];\\nif (theUser)\\n{\\n    // ...\\n}\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n- To authenticate a new user, use *login:id* call:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Authenticate a user by e-mail address    \\nMOCAUser * currentUser = [[MOCA currentInstance] login:@\\\"UNIQUE_USER_ID\\\"];\\nif (currentUser)\\n{\\n   // ...\\n}\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n- To logout a user, call:\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[theUser logout];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n- The user object holds a collection of properties. Property-value pairs can be set and retrieved.\n- Each user object is persisted both locally and in the cloud. \n- It is recommended to perform as many sets as desired and then \njust invoke a single save operation to persist them to the MOCA cloud.\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"MOCAUser * theUser = [[MOCA currentInstance] currentUser];    \\nif (theUser)\\n{\\n    [theUser setValue:@”male\\\" forProperty:@”gender\\\"];\\n    [theUser setValue:[NSNumber numberWithInt:1975] forProperty:@”birth_year\\\"];\\u000b    // Asynchronously save the user object to the cloud.\\n    [theUser saveWithBlock:^(MOCAUser *user, NSError *error)\\n        {\\n          if (error) NSLog(@\\\"Save user failed: %@\\\", error);\\n        }\\n    ];\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]","category":"55a8e7a227a17d21005251a2","link_external":false,"slug":"user-api","updates":[],"title":"User API","__v":2,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":"","auth":"required","params":[]},"hidden":false,"link_url":"","project":"559a61d2dbcfd20d00710b39","user":"559a618bdbcfd20d00710b38","excerpt":"","order":2,"sync_unique":"","type":"basic","createdAt":"2015-07-17T13:24:37.208Z","githubsync":"","isReference":false,"parentDoc":null,"version":"559a61d2dbcfd20d00710b3c","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

User API


- The app **User object** manages information about current application user. - This object is **optional**, and it is used when the app needs to authenticate the user. - The authentication provides data about user’s identity: a unique user ID or similar. - The user login and logout calls are managed by the app. - To access existing User object, use currentUser property: [block:code] { "codes": [ { "code": "// Access authenticated user object\nMOCAUser * theUser = [[MOCA currentInstance] currentUser];\nif (theUser)\n{\n // ...\n}\n", "language": "objectivec" } ] } [/block] - To authenticate a new user, use *login:id* call: [block:code] { "codes": [ { "code": "// Authenticate a user by e-mail address \nMOCAUser * currentUser = [[MOCA currentInstance] login:@\"UNIQUE_USER_ID\"];\nif (currentUser)\n{\n // ...\n}\n", "language": "objectivec" } ] } [/block] - To logout a user, call: [block:code] { "codes": [ { "code": "[theUser logout];", "language": "objectivec" } ] } [/block] - The user object holds a collection of properties. Property-value pairs can be set and retrieved. - Each user object is persisted both locally and in the cloud. - It is recommended to perform as many sets as desired and then just invoke a single save operation to persist them to the MOCA cloud. [block:code] { "codes": [ { "code": "MOCAUser * theUser = [[MOCA currentInstance] currentUser]; \nif (theUser)\n{\n [theUser setValue:@”male\" forProperty:@”gender\"];\n [theUser setValue:[NSNumber numberWithInt:1975] forProperty:@”birth_year\"];\u000b // Asynchronously save the user object to the cloud.\n [theUser saveWithBlock:^(MOCAUser *user, NSError *error)\n {\n if (error) NSLog(@\"Save user failed: %@\", error);\n }\n ];\n}", "language": "objectivec" } ] } [/block]
- The app **User object** manages information about current application user. - This object is **optional**, and it is used when the app needs to authenticate the user. - The authentication provides data about user’s identity: a unique user ID or similar. - The user login and logout calls are managed by the app. - To access existing User object, use currentUser property: [block:code] { "codes": [ { "code": "// Access authenticated user object\nMOCAUser * theUser = [[MOCA currentInstance] currentUser];\nif (theUser)\n{\n // ...\n}\n", "language": "objectivec" } ] } [/block] - To authenticate a new user, use *login:id* call: [block:code] { "codes": [ { "code": "// Authenticate a user by e-mail address \nMOCAUser * currentUser = [[MOCA currentInstance] login:@\"UNIQUE_USER_ID\"];\nif (currentUser)\n{\n // ...\n}\n", "language": "objectivec" } ] } [/block] - To logout a user, call: [block:code] { "codes": [ { "code": "[theUser logout];", "language": "objectivec" } ] } [/block] - The user object holds a collection of properties. Property-value pairs can be set and retrieved. - Each user object is persisted both locally and in the cloud. - It is recommended to perform as many sets as desired and then just invoke a single save operation to persist them to the MOCA cloud. [block:code] { "codes": [ { "code": "MOCAUser * theUser = [[MOCA currentInstance] currentUser]; \nif (theUser)\n{\n [theUser setValue:@”male\" forProperty:@”gender\"];\n [theUser setValue:[NSNumber numberWithInt:1975] forProperty:@”birth_year\"];\u000b // Asynchronously save the user object to the cloud.\n [theUser saveWithBlock:^(MOCAUser *user, NSError *error)\n {\n if (error) NSLog(@\"Save user failed: %@\", error);\n }\n ];\n}", "language": "objectivec" } ] } [/block]
{"_id":"55a9035927a17d210052520b","api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"name":"","status":400,"language":"json","code":"{}"}]},"settings":"","url":"","auth":"required","params":[]},"body":"- The MOCA SDK, once the user has opted in, passively develops \u000ba *User Profile* of mobile usage and other behaviors.\n- The profile ensures that the app can deliver much more personalized, relevant content based on: \n - Interests – sports, video games, books, cooking\n - Places of Interests (POIs) – top locations where the user spends time (e.g. home, work, restaurant, etc.)\n- User profile is elaborated automatically without user interaction\n- MOCA respects user’s privacy. Contact us for privacy policy recommendations.","parentDoc":null,"user":"559a618bdbcfd20d00710b38","version":"559a61d2dbcfd20d00710b3c","hidden":false,"isReference":false,"link_external":false,"type":"basic","sync_unique":"","title":"User Profile","order":3,"project":"559a61d2dbcfd20d00710b39","slug":"user-profile","githubsync":"","link_url":"","updates":[],"__v":1,"category":"55a8e7a227a17d21005251a2","createdAt":"2015-07-17T13:30:01.589Z","excerpt":"","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

User Profile


- The MOCA SDK, once the user has opted in, passively develops a *User Profile* of mobile usage and other behaviors. - The profile ensures that the app can deliver much more personalized, relevant content based on: - Interests – sports, video games, books, cooking - Places of Interests (POIs) – top locations where the user spends time (e.g. home, work, restaurant, etc.) - User profile is elaborated automatically without user interaction - MOCA respects user’s privacy. Contact us for privacy policy recommendations.
- The MOCA SDK, once the user has opted in, passively develops a *User Profile* of mobile usage and other behaviors. - The profile ensures that the app can deliver much more personalized, relevant content based on: - Interests – sports, video games, books, cooking - Places of Interests (POIs) – top locations where the user spends time (e.g. home, work, restaurant, etc.) - User profile is elaborated automatically without user interaction - MOCA respects user’s privacy. Contact us for privacy policy recommendations.
{"_id":"55a903cfcf45e1390093f29e","excerpt":"","hidden":false,"isReference":false,"order":4,"api":{"url":"","auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":""},"link_external":false,"project":"559a61d2dbcfd20d00710b39","sync_unique":"","title":"Tag API","updates":[],"__v":4,"parentDoc":null,"slug":"tags-1","category":"55a8e7a227a17d21005251a2","createdAt":"2015-07-17T13:31:59.715Z","githubsync":"","link_url":"","type":"basic","user":"559a618bdbcfd20d00710b38","version":"559a61d2dbcfd20d00710b3c","body":"# Introduction\n\n\n- To sense user interests, MOCA uses *Tags*.\n- Tags are small items of information with well defined semantics. \n- Each tag is associated with a ***counter***. The counter is used to track how many times the user was tagged or to sum points associated with the tag. \n- Tags are defined in MOCA Console or by the app.\n- For example: `Restaurant` `Video Store` `Woman` `Parking` `Gym`\n- Tags can be attached to specific locations by using beacons or programmatically by API.\n- Tag counters are used to rank the tags.\n\n\n- MOCA provides the following methods to manipulate Tags.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"@interface MOCAInstance\\n\\n#pragma mark Tags\\n\\n/**\\n * Add a tag to this instance and increment its value by 1.\\n */\\n-(void)addTag:(NSString*)tagName;\\n\\n/**\\n * Add a tag with a given value to this instance.\\n * @value - update expression with syntax [=|+|-] <double> value.\\n * For example \\\"+1\\\" increments the tag value by 1.\\n * For example \\\"-2\\\" decrements the tag value by 2. \\n * For example \\\"3\\\" or \\\"=3\\\" assign value of 3 to the tag's value.\\n */\\n-(void)addTag:(NSString*)tagName withValue:(NSString*)value;\\n\\n/**\\n * Checks if this instance contains a specific tag.\\n * @return <code>YES</code> if the instance contains a tag, or <code>NO</code> otherwise.\\n */\\n-(BOOL)containsTag:(NSString*)tagName;\\n\\n/**\\n * Retrieves a value of a specific tag associated with this instance.\\n * @return tag value or <code>nil</code> if the tag doest not exist.\\n */\\n-(NSNumber*)getTagValue:(NSString*)tagName;\\n\\n/**\\n * Retrieves top-k tags ranked by values.\\n */\\n-(NSArray*)getTopTags:(unsigned int)topK;\\n\\n/**\\n * Retrieves names of all tags associated with this instance.\\n */\\n-(NSArray*)allTags;\\n\\n#pragma mark\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Tag API


# Introduction - To sense user interests, MOCA uses *Tags*. - Tags are small items of information with well defined semantics. - Each tag is associated with a ***counter***. The counter is used to track how many times the user was tagged or to sum points associated with the tag. - Tags are defined in MOCA Console or by the app. - For example: `Restaurant` `Video Store` `Woman` `Parking` `Gym` - Tags can be attached to specific locations by using beacons or programmatically by API. - Tag counters are used to rank the tags. - MOCA provides the following methods to manipulate Tags. [block:code] { "codes": [ { "code": "@interface MOCAInstance\n\n#pragma mark Tags\n\n/**\n * Add a tag to this instance and increment its value by 1.\n */\n-(void)addTag:(NSString*)tagName;\n\n/**\n * Add a tag with a given value to this instance.\n * @value - update expression with syntax [=|+|-] <double> value.\n * For example \"+1\" increments the tag value by 1.\n * For example \"-2\" decrements the tag value by 2. \n * For example \"3\" or \"=3\" assign value of 3 to the tag's value.\n */\n-(void)addTag:(NSString*)tagName withValue:(NSString*)value;\n\n/**\n * Checks if this instance contains a specific tag.\n * @return <code>YES</code> if the instance contains a tag, or <code>NO</code> otherwise.\n */\n-(BOOL)containsTag:(NSString*)tagName;\n\n/**\n * Retrieves a value of a specific tag associated with this instance.\n * @return tag value or <code>nil</code> if the tag doest not exist.\n */\n-(NSNumber*)getTagValue:(NSString*)tagName;\n\n/**\n * Retrieves top-k tags ranked by values.\n */\n-(NSArray*)getTopTags:(unsigned int)topK;\n\n/**\n * Retrieves names of all tags associated with this instance.\n */\n-(NSArray*)allTags;\n\n#pragma mark\n", "language": "objectivec" } ] } [/block]
# Introduction - To sense user interests, MOCA uses *Tags*. - Tags are small items of information with well defined semantics. - Each tag is associated with a ***counter***. The counter is used to track how many times the user was tagged or to sum points associated with the tag. - Tags are defined in MOCA Console or by the app. - For example: `Restaurant` `Video Store` `Woman` `Parking` `Gym` - Tags can be attached to specific locations by using beacons or programmatically by API. - Tag counters are used to rank the tags. - MOCA provides the following methods to manipulate Tags. [block:code] { "codes": [ { "code": "@interface MOCAInstance\n\n#pragma mark Tags\n\n/**\n * Add a tag to this instance and increment its value by 1.\n */\n-(void)addTag:(NSString*)tagName;\n\n/**\n * Add a tag with a given value to this instance.\n * @value - update expression with syntax [=|+|-] <double> value.\n * For example \"+1\" increments the tag value by 1.\n * For example \"-2\" decrements the tag value by 2. \n * For example \"3\" or \"=3\" assign value of 3 to the tag's value.\n */\n-(void)addTag:(NSString*)tagName withValue:(NSString*)value;\n\n/**\n * Checks if this instance contains a specific tag.\n * @return <code>YES</code> if the instance contains a tag, or <code>NO</code> otherwise.\n */\n-(BOOL)containsTag:(NSString*)tagName;\n\n/**\n * Retrieves a value of a specific tag associated with this instance.\n * @return tag value or <code>nil</code> if the tag doest not exist.\n */\n-(NSNumber*)getTagValue:(NSString*)tagName;\n\n/**\n * Retrieves top-k tags ranked by values.\n */\n-(NSArray*)getTopTags:(unsigned int)topK;\n\n/**\n * Retrieves names of all tags associated with this instance.\n */\n-(NSArray*)allTags;\n\n#pragma mark\n", "language": "objectivec" } ] } [/block]
{"_id":"55a9049727a17d210052520f","__v":1,"body":"- To describe segments the user belongs to, MOCA uses `Segment objects`. Segments are *predefined* items of information with well defined semantics for the given data provider. \n\n- The segment objects allow data about the anonymous user (i.e. MOCA Instance) or logged-in user (MOCA User) to be passed to Ad services in order to improve *Ad targeting.*\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/Gf9PO6b5TKikNu229Hq6_Algorithm.png\",\n        \"Algorithm.png\",\n        \"875\",\n        \"547\",\n        \"#2c95d4\",\n        \"\"\n      ],\n      \"caption\": \"Profile Sensing\"\n    }\n  ]\n}\n[/block]","type":"basic","user":"559a618bdbcfd20d00710b38","hidden":false,"isReference":false,"slug":"segments-1","updates":[],"version":"559a61d2dbcfd20d00710b3c","createdAt":"2015-07-17T13:35:19.155Z","githubsync":"","link_external":false,"order":5,"parentDoc":null,"title":"Segments","api":{"auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"category":"55a8e7a227a17d21005251a2","excerpt":"","link_url":"","project":"559a61d2dbcfd20d00710b39","sync_unique":"","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Segments


- To describe segments the user belongs to, MOCA uses `Segment objects`. Segments are *predefined* items of information with well defined semantics for the given data provider. - The segment objects allow data about the anonymous user (i.e. MOCA Instance) or logged-in user (MOCA User) to be passed to Ad services in order to improve *Ad targeting.* [block:image] { "images": [ { "image": [ "https://files.readme.io/Gf9PO6b5TKikNu229Hq6_Algorithm.png", "Algorithm.png", "875", "547", "#2c95d4", "" ], "caption": "Profile Sensing" } ] } [/block]
- To describe segments the user belongs to, MOCA uses `Segment objects`. Segments are *predefined* items of information with well defined semantics for the given data provider. - The segment objects allow data about the anonymous user (i.e. MOCA Instance) or logged-in user (MOCA User) to be passed to Ad services in order to improve *Ad targeting.* [block:image] { "images": [ { "image": [ "https://files.readme.io/Gf9PO6b5TKikNu229Hq6_Algorithm.png", "Algorithm.png", "875", "547", "#2c95d4", "" ], "caption": "Profile Sensing" } ] } [/block]
{"_id":"55a9059a27a17d2100525217","__v":2,"title":"Event tracking","updates":[],"version":"559a61d2dbcfd20d00710b3c","api":{"results":{"codes":[{"language":"json","code":"{}","name":"","status":200},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":"","auth":"required","params":[]},"excerpt":"","link_url":"","parentDoc":null,"slug":"event-tracking","sync_unique":"","user":"559a618bdbcfd20d00710b38","githubsync":"","hidden":false,"isReference":false,"order":6,"body":"- The `Event object` enables you to feed data to MOCA Analytics. \n- The Event API *captures and transmits* to the cloud the *flow of arbitrary* events associated with the app.\n- A single event object represents the *record* that indicates that *something has happened*.\n - Such as App started, Push notification received, Beacon detected, etc.\n- There are two types of events: \n - Predefined – tracked automatically by the SDK\n - Custom – tracked by the app","category":"55a8e7a227a17d21005251a2","createdAt":"2015-07-17T13:39:38.644Z","link_external":false,"project":"559a61d2dbcfd20d00710b39","type":"basic","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Event tracking


- The `Event object` enables you to feed data to MOCA Analytics. - The Event API *captures and transmits* to the cloud the *flow of arbitrary* events associated with the app. - A single event object represents the *record* that indicates that *something has happened*. - Such as App started, Push notification received, Beacon detected, etc. - There are two types of events: - Predefined – tracked automatically by the SDK - Custom – tracked by the app
- The `Event object` enables you to feed data to MOCA Analytics. - The Event API *captures and transmits* to the cloud the *flow of arbitrary* events associated with the app. - A single event object represents the *record* that indicates that *something has happened*. - Such as App started, Push notification received, Beacon detected, etc. - There are two types of events: - Predefined – tracked automatically by the SDK - Custom – tracked by the app
{"_id":"55a9066527a17d210052521e","__v":6,"excerpt":"","isReference":false,"link_url":"","parentDoc":null,"user":"559a618bdbcfd20d00710b38","category":"55a8e7a227a17d21005251a2","createdAt":"2015-07-17T13:43:01.255Z","project":"559a61d2dbcfd20d00710b39","type":"basic","api":{"settings":"","url":"","auth":"required","params":[],"results":{"codes":[{"name":"","status":200,"language":"json","code":"{}"},{"status":400,"language":"json","code":"{}","name":""}]}},"body":"A single `event object` record contains:\n\n- Event data:\n - Identifier – unique event ID (UUID)\n - Timestamp – GMT timestamp when the event occurred\n - Local timestamp – timestamp with local timezone\n - Event type – type of event\n - Action verb – string that describes performed action (i.e. Buy, View, Search, Enter, etc.)\n - Item – item associated with the event (i.e. Product ID)\n - Item Category – category the item belongs to (Product Category)\n - Value – value associated with the event (E.g. purchase amount)\n\n- Context data:\n - Instance ID – the instance object ID that generated the event\n - User ID – the logged-in user that generated the event (optional)\n - Device model/type\n - OS name/version\n - Country\n - Language\n - And other attributes\n\nBy default, the SDK automatically tracks predefined events:\n - _start_session – when the new app session was started\n - _session – when the user’s session ends\n - _geo – track last coordinates of the current location *\n - _visit – when a user visits a frequent place *\n - _push – when push notification has been received while the app was running\n - _launching_push – when app was started by a push notification\n - _action – when proximity action has been triggered\n - _beacon_proximity – when the device entered/exited a beacon region *\n - _zone_proximity – when the device entered/exited a proximity zone *\n - _place_proximity – when the device entered/exited a proximity place *\n - _tick – indicates if the app is active\n - _user_login – when user logged in\n - _user_logout – when user logged out\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"* Used when available and allowed by user privacy settings.\"\n}\n[/block]\nTo track custom events in your app, use the following API:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"/**\\n * Tracks an event represented by an action verb \\n *\\n * @param verb Action verb. (E.g. Buy, View, Search, etc.).\\n *\\n * @return <code>YES</code> in case of success, <code>NO</code> in case of error.\\n */\\n+ (BOOL) track:(NSString*)verb;\\n\\n/**\\n * Track event helper methods. \\n */\\n+ (BOOL) track:(NSString*)verb withValue:(NSNumber*)value;\\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item;\\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item withValue:(NSNumber*)value;\\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item belongingTo:(NSString*)category;\\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item belongingTo:(NSString*)category withValue:(NSNumber*)value;\\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item belongingTo:(NSString*)category withIntValue:(int)value;\\n\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nCustom tracking example:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender\\n{\\n    if ([[segue identifier] isEqualToString:@”ViewProduct\\\"])\\n    {\\n      NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];\\n \\tProduct *product = self.products [indexPath];\\n\\t// Track view product event\\n        [MOCAEvent track:@”view” forItem:product.id];\\n    }\\n}\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]","order":7,"slug":"event-api","updates":[],"version":"559a61d2dbcfd20d00710b3c","githubsync":"","hidden":false,"link_external":false,"sync_unique":"","title":"Event API","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Event API


A single `event object` record contains: - Event data: - Identifier – unique event ID (UUID) - Timestamp – GMT timestamp when the event occurred - Local timestamp – timestamp with local timezone - Event type – type of event - Action verb – string that describes performed action (i.e. Buy, View, Search, Enter, etc.) - Item – item associated with the event (i.e. Product ID) - Item Category – category the item belongs to (Product Category) - Value – value associated with the event (E.g. purchase amount) - Context data: - Instance ID – the instance object ID that generated the event - User ID – the logged-in user that generated the event (optional) - Device model/type - OS name/version - Country - Language - And other attributes By default, the SDK automatically tracks predefined events: - _start_session – when the new app session was started - _session – when the user’s session ends - _geo – track last coordinates of the current location * - _visit – when a user visits a frequent place * - _push – when push notification has been received while the app was running - _launching_push – when app was started by a push notification - _action – when proximity action has been triggered - _beacon_proximity – when the device entered/exited a beacon region * - _zone_proximity – when the device entered/exited a proximity zone * - _place_proximity – when the device entered/exited a proximity place * - _tick – indicates if the app is active - _user_login – when user logged in - _user_logout – when user logged out [block:callout] { "type": "warning", "body": "* Used when available and allowed by user privacy settings." } [/block] To track custom events in your app, use the following API: [block:code] { "codes": [ { "code": "/**\n * Tracks an event represented by an action verb \n *\n * @param verb Action verb. (E.g. Buy, View, Search, etc.).\n *\n * @return <code>YES</code> in case of success, <code>NO</code> in case of error.\n */\n+ (BOOL) track:(NSString*)verb;\n\n/**\n * Track event helper methods. \n */\n+ (BOOL) track:(NSString*)verb withValue:(NSNumber*)value;\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item;\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item withValue:(NSNumber*)value;\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item belongingTo:(NSString*)category;\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item belongingTo:(NSString*)category withValue:(NSNumber*)value;\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item belongingTo:(NSString*)category withIntValue:(int)value;\n\n", "language": "objectivec" } ] } [/block] Custom tracking example: [block:code] { "codes": [ { "code": "(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender\n{\n if ([[segue identifier] isEqualToString:@”ViewProduct\"])\n {\n NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];\n \tProduct *product = self.products [indexPath];\n\t// Track view product event\n [MOCAEvent track:@”view” forItem:product.id];\n }\n}\n", "language": "objectivec" } ] } [/block]
A single `event object` record contains: - Event data: - Identifier – unique event ID (UUID) - Timestamp – GMT timestamp when the event occurred - Local timestamp – timestamp with local timezone - Event type – type of event - Action verb – string that describes performed action (i.e. Buy, View, Search, Enter, etc.) - Item – item associated with the event (i.e. Product ID) - Item Category – category the item belongs to (Product Category) - Value – value associated with the event (E.g. purchase amount) - Context data: - Instance ID – the instance object ID that generated the event - User ID – the logged-in user that generated the event (optional) - Device model/type - OS name/version - Country - Language - And other attributes By default, the SDK automatically tracks predefined events: - _start_session – when the new app session was started - _session – when the user’s session ends - _geo – track last coordinates of the current location * - _visit – when a user visits a frequent place * - _push – when push notification has been received while the app was running - _launching_push – when app was started by a push notification - _action – when proximity action has been triggered - _beacon_proximity – when the device entered/exited a beacon region * - _zone_proximity – when the device entered/exited a proximity zone * - _place_proximity – when the device entered/exited a proximity place * - _tick – indicates if the app is active - _user_login – when user logged in - _user_logout – when user logged out [block:callout] { "type": "warning", "body": "* Used when available and allowed by user privacy settings." } [/block] To track custom events in your app, use the following API: [block:code] { "codes": [ { "code": "/**\n * Tracks an event represented by an action verb \n *\n * @param verb Action verb. (E.g. Buy, View, Search, etc.).\n *\n * @return <code>YES</code> in case of success, <code>NO</code> in case of error.\n */\n+ (BOOL) track:(NSString*)verb;\n\n/**\n * Track event helper methods. \n */\n+ (BOOL) track:(NSString*)verb withValue:(NSNumber*)value;\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item;\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item withValue:(NSNumber*)value;\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item belongingTo:(NSString*)category;\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item belongingTo:(NSString*)category withValue:(NSNumber*)value;\n+ (BOOL) track:(NSString*)verb forItem:(NSString*)item belongingTo:(NSString*)category withIntValue:(int)value;\n\n", "language": "objectivec" } ] } [/block] Custom tracking example: [block:code] { "codes": [ { "code": "(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender\n{\n if ([[segue identifier] isEqualToString:@”ViewProduct\"])\n {\n NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];\n \tProduct *product = self.products [indexPath];\n\t// Track view product event\n [MOCAEvent track:@”view” forItem:product.id];\n }\n}\n", "language": "objectivec" } ] } [/block]
{"_id":"55a9075bcf45e1390093f2a9","api":{"url":"","auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"name":"","status":400,"language":"json","code":"{}"}]},"settings":""},"hidden":false,"sync_unique":"","type":"basic","updates":[],"version":"559a61d2dbcfd20d00710b3c","body":"##Features\n\n- Push notification registration\n - Automatic - configure MOCA SDK to register your app for remote push notifications.\n - Manual – handle remote push notification registration from your app and only register deviceToken in the  SDK \n- Push notification tracking\n - Tracked received push notifications with MOCA SDK. \n - The tracked data can be analyzed in MOCA Analytics (Pushes, PushOpened, and more).\n\n##Integration\n\nTo use automatic push notifications registration in MOCA, you’ll need to enable push service.\n\n1. Ensure automatic push setup is enabled in MOCAConfig.plist file.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/YSZRxxoGS6qEegXyCQg8_push.png\",\n        \"push.png\",\n        \"587\",\n        \"245\",\n        \"#3e5077\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n2 . The `[MOCA initializeSDK] `call will register for remote push notification for you:\n\n- For iOS7: `[[UIApplication sharedApplication] registerForRemoteNotificationTypes:] `\n- For iOS8+:` [[UIApplication sharedApplication] registerUserNotificationSettings:]` and  `[[UIApplication sharedApplication] registerForRemoteNotifications:] ` \n\n\n3. Next, implement `[didRegisterForRemoteNotificationsWithDeviceToken:]` app delegate callback:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken\\n{\\n    NSLog(@\\\"APNS token: %@\\\", deviceToken);\\n    // Register push token in MOCA\\n    [MOCA registerDeviceToken:deviceToken];\\n}\",\n      \"language\": \"objectivec\",\n      \"name\": \"Send received push token to MOCA Cloud\"\n    }\n  ]\n}\n[/block]\nAnd handle errors through the following callback.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error\\n{\\n   // Handle error\\n  NSLog(@\\\"Push notifications registration failed 😨\\\");\\n}\\n\",\n      \"language\": \"objectivec\",\n      \"name\": \"Handle registration errors\"\n    }\n  ]\n}\n[/block]\n4.  Complete, the process by implementing the app delegate callbacks:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"//Called after user taps a notification\\n- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification\\n{\\n    if (MOCA.initialized) {\\n        [MOCA handleLocalNotification:notification];\\n    }  \\n}\\n\\n//Called when the remote push notification is received from the server\\n-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{\\n    \\n    if (MOCA.initialized) {\\n        [MOCA handleRemoteNotification:userInfo fetchCompletionHandler:completionHandler];\\n    }\\n}\\n\",\n      \"language\": \"objectivec\",\n      \"name\": \"Handle remote notifications\"\n    }\n  ]\n}\n[/block]","category":"55a8e7a227a17d21005251a2","next":{"description":"","pages":[]},"parentDoc":null,"slug":"push-api","user":"559a618bdbcfd20d00710b38","__v":8,"createdAt":"2015-07-17T13:47:07.890Z","excerpt":"MOCA SDK easily integrates with iOS push notifications.","link_external":false,"order":8,"githubsync":"","isReference":false,"link_url":"","project":"559a61d2dbcfd20d00710b39","title":"Push API","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Push API

MOCA SDK easily integrates with iOS push notifications.

##Features - Push notification registration - Automatic - configure MOCA SDK to register your app for remote push notifications. - Manual – handle remote push notification registration from your app and only register deviceToken in the SDK - Push notification tracking - Tracked received push notifications with MOCA SDK. - The tracked data can be analyzed in MOCA Analytics (Pushes, PushOpened, and more). ##Integration To use automatic push notifications registration in MOCA, you’ll need to enable push service. 1. Ensure automatic push setup is enabled in MOCAConfig.plist file. [block:image] { "images": [ { "image": [ "https://files.readme.io/YSZRxxoGS6qEegXyCQg8_push.png", "push.png", "587", "245", "#3e5077", "" ] } ] } [/block] 2 . The `[MOCA initializeSDK] `call will register for remote push notification for you: - For iOS7: `[[UIApplication sharedApplication] registerForRemoteNotificationTypes:] ` - For iOS8+:` [[UIApplication sharedApplication] registerUserNotificationSettings:]` and `[[UIApplication sharedApplication] registerForRemoteNotifications:] ` 3. Next, implement `[didRegisterForRemoteNotificationsWithDeviceToken:]` app delegate callback: [block:code] { "codes": [ { "code": "- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken\n{\n NSLog(@\"APNS token: %@\", deviceToken);\n // Register push token in MOCA\n [MOCA registerDeviceToken:deviceToken];\n}", "language": "objectivec", "name": "Send received push token to MOCA Cloud" } ] } [/block] And handle errors through the following callback. [block:code] { "codes": [ { "code": "- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error\n{\n // Handle error\n NSLog(@\"Push notifications registration failed 😨\");\n}\n", "language": "objectivec", "name": "Handle registration errors" } ] } [/block] 4. Complete, the process by implementing the app delegate callbacks: [block:code] { "codes": [ { "code": "//Called after user taps a notification\n- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification\n{\n if (MOCA.initialized) {\n [MOCA handleLocalNotification:notification];\n } \n}\n\n//Called when the remote push notification is received from the server\n-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{\n \n if (MOCA.initialized) {\n [MOCA handleRemoteNotification:userInfo fetchCompletionHandler:completionHandler];\n }\n}\n", "language": "objectivec", "name": "Handle remote notifications" } ] } [/block]
##Features - Push notification registration - Automatic - configure MOCA SDK to register your app for remote push notifications. - Manual – handle remote push notification registration from your app and only register deviceToken in the SDK - Push notification tracking - Tracked received push notifications with MOCA SDK. - The tracked data can be analyzed in MOCA Analytics (Pushes, PushOpened, and more). ##Integration To use automatic push notifications registration in MOCA, you’ll need to enable push service. 1. Ensure automatic push setup is enabled in MOCAConfig.plist file. [block:image] { "images": [ { "image": [ "https://files.readme.io/YSZRxxoGS6qEegXyCQg8_push.png", "push.png", "587", "245", "#3e5077", "" ] } ] } [/block] 2 . The `[MOCA initializeSDK] `call will register for remote push notification for you: - For iOS7: `[[UIApplication sharedApplication] registerForRemoteNotificationTypes:] ` - For iOS8+:` [[UIApplication sharedApplication] registerUserNotificationSettings:]` and `[[UIApplication sharedApplication] registerForRemoteNotifications:] ` 3. Next, implement `[didRegisterForRemoteNotificationsWithDeviceToken:]` app delegate callback: [block:code] { "codes": [ { "code": "- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken\n{\n NSLog(@\"APNS token: %@\", deviceToken);\n // Register push token in MOCA\n [MOCA registerDeviceToken:deviceToken];\n}", "language": "objectivec", "name": "Send received push token to MOCA Cloud" } ] } [/block] And handle errors through the following callback. [block:code] { "codes": [ { "code": "- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error\n{\n // Handle error\n NSLog(@\"Push notifications registration failed 😨\");\n}\n", "language": "objectivec", "name": "Handle registration errors" } ] } [/block] 4. Complete, the process by implementing the app delegate callbacks: [block:code] { "codes": [ { "code": "//Called after user taps a notification\n- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification\n{\n if (MOCA.initialized) {\n [MOCA handleLocalNotification:notification];\n } \n}\n\n//Called when the remote push notification is received from the server\n-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{\n \n if (MOCA.initialized) {\n [MOCA handleRemoteNotification:userInfo fetchCompletionHandler:completionHandler];\n }\n}\n", "language": "objectivec", "name": "Handle remote notifications" } ] } [/block]
{"_id":"55a9090927a17d2100525228","hidden":false,"project":"559a61d2dbcfd20d00710b39","sync_unique":"","type":"basic","user":"559a618bdbcfd20d00710b38","api":{"auth":"required","params":[],"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"body":"##Introduction\n\n- The *MOCA SDK* lets you effortlessly add Bluetooth beacon based proximity experiences to your iOS app.\n- The SDK comes with a powerful proximity engine based on Complex Event Processing logic (see CEP).\n- MOCA defines some fundamental concepts:\n - Place, Zone, and Beacon\n - Trigger and Action\n - Visit\n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/4l1tE04pR5uVKvpaeDv6_Da-proximity-experience.png\",\n        \"Da-proximity-experience.png\",\n        \"911\",\n        \"457\",\n        \"#3ba0da\",\n        \"\"\n      ],\n      \"caption\": \"To map real-world context, MOCA introduces some fundamental concepts.\"\n    }\n  ]\n}\n[/block]\nTo start using Bluetooth beacon-based proximity experiences in your app, you’ll need to enable proximity service.\n\n1. Ensure proximity service is enabled in MOCAConfig.plist file.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/pxJrwqaqT5yKS1r1VbqO_proximity-service.png\",\n        \"proximity-service.png\",\n        \"587\",\n        \"245\",\n        \"#425479\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n2. The `[MOCA initializeSDK]` call will automatically start MOCA proximity engine and synchronize proximity campaigns defined in your MOCA cloud account.\n\n###Places\nRepresents a real-world locations, such as a store, venue, museum, building, office and so on.\n- A place can be localized by a geo-fence (GPS location and radius in meters) \n- A place contains a collection of zones, where each zone defines semantics for an indoor location, such as Kids Clothes, Women Clothes, Entrance, Exit, Books, Videogames, etc.\n\n###Zone\nRepresents a indoor area or micro-location within the place with user-defined semantics. \n- Examples include ds Clothes, Women Clothes, Entrance, Exit, Books, Videogames, etc.\n- A zone is defined by a range of one or more beacon sensors. \n\n###Beacon\nIt is a BLE, iBeacon-compatible proximity sensor.\n- Each beacon is identified by { Proximity UUID, Major and Minor } tuple.\n- MOCA SDK works with any iBeacon-compatible devices. \n - This includes MOCA Beacons \n - And beacons provided by other manufacturers such as Kontakt.io, Estimote, etc.\n- Beacons are assigned to Zones that define their micro-location semantics. \n- Each beacon must be registered in MOCA Management Console.\n\n###Campaigns \nCollections of proximity experiences that are delivered to a user within a specified time frame.\n\n###Experience \nDefines a proximity interaction with a user. \n- An experience is composed of a trigger condition and an action. \n- When proximity trigger conditions are met, the corresponding action is fired.\n\n###Trigger\nIt is a condition or a collection of conditions that must be met to fire an action associated with an experience. For example:\n- Enter place, \n- Exit place, \n- Enter zone, \n- Exit zone,\n- Enter beacon range with given proximity, \n- Exit beacon range\n- Custom trigger (implemented as app-provided delegate callback)\n\n###Action\nDescribes an activity to be performed when experience trigger conditions are met. The SDK supports the following actions:\n- Show local push notification with a specific message\n- Play sound with a specific file name (included in app bundle)\n- Play video from URL\n- Show image from URL\n- Show HTML content from URL\n- Open custom URL\n- Show PassBook card\n- Custom action (implemented as app-provided delegate callback)\n\n\nThe SDK provides delegates that enable full customization of all performed actions. \u000b\tSee `MOCAProximityActionsDelegate` in `MOCAProximityDelegate.h` file for details.","version":"559a61d2dbcfd20d00710b3c","title":"Proximity API","updates":[],"githubsync":"","link_url":"","order":9,"parentDoc":null,"slug":"proximity-api","__v":7,"category":"55a8e7a227a17d21005251a2","excerpt":"","createdAt":"2015-07-17T13:54:17.291Z","isReference":false,"link_external":false,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Proximity API


##Introduction - The *MOCA SDK* lets you effortlessly add Bluetooth beacon based proximity experiences to your iOS app. - The SDK comes with a powerful proximity engine based on Complex Event Processing logic (see CEP). - MOCA defines some fundamental concepts: - Place, Zone, and Beacon - Trigger and Action - Visit [block:image] { "images": [ { "image": [ "https://files.readme.io/4l1tE04pR5uVKvpaeDv6_Da-proximity-experience.png", "Da-proximity-experience.png", "911", "457", "#3ba0da", "" ], "caption": "To map real-world context, MOCA introduces some fundamental concepts." } ] } [/block] To start using Bluetooth beacon-based proximity experiences in your app, you’ll need to enable proximity service. 1. Ensure proximity service is enabled in MOCAConfig.plist file. [block:image] { "images": [ { "image": [ "https://files.readme.io/pxJrwqaqT5yKS1r1VbqO_proximity-service.png", "proximity-service.png", "587", "245", "#425479", "" ] } ] } [/block] 2. The `[MOCA initializeSDK]` call will automatically start MOCA proximity engine and synchronize proximity campaigns defined in your MOCA cloud account. ###Places Represents a real-world locations, such as a store, venue, museum, building, office and so on. - A place can be localized by a geo-fence (GPS location and radius in meters) - A place contains a collection of zones, where each zone defines semantics for an indoor location, such as Kids Clothes, Women Clothes, Entrance, Exit, Books, Videogames, etc. ###Zone Represents a indoor area or micro-location within the place with user-defined semantics. - Examples include ds Clothes, Women Clothes, Entrance, Exit, Books, Videogames, etc. - A zone is defined by a range of one or more beacon sensors. ###Beacon It is a BLE, iBeacon-compatible proximity sensor. - Each beacon is identified by { Proximity UUID, Major and Minor } tuple. - MOCA SDK works with any iBeacon-compatible devices. - This includes MOCA Beacons - And beacons provided by other manufacturers such as Kontakt.io, Estimote, etc. - Beacons are assigned to Zones that define their micro-location semantics. - Each beacon must be registered in MOCA Management Console. ###Campaigns Collections of proximity experiences that are delivered to a user within a specified time frame. ###Experience Defines a proximity interaction with a user. - An experience is composed of a trigger condition and an action. - When proximity trigger conditions are met, the corresponding action is fired. ###Trigger It is a condition or a collection of conditions that must be met to fire an action associated with an experience. For example: - Enter place, - Exit place, - Enter zone, - Exit zone, - Enter beacon range with given proximity, - Exit beacon range - Custom trigger (implemented as app-provided delegate callback) ###Action Describes an activity to be performed when experience trigger conditions are met. The SDK supports the following actions: - Show local push notification with a specific message - Play sound with a specific file name (included in app bundle) - Play video from URL - Show image from URL - Show HTML content from URL - Open custom URL - Show PassBook card - Custom action (implemented as app-provided delegate callback) The SDK provides delegates that enable full customization of all performed actions. See `MOCAProximityActionsDelegate` in `MOCAProximityDelegate.h` file for details.
##Introduction - The *MOCA SDK* lets you effortlessly add Bluetooth beacon based proximity experiences to your iOS app. - The SDK comes with a powerful proximity engine based on Complex Event Processing logic (see CEP). - MOCA defines some fundamental concepts: - Place, Zone, and Beacon - Trigger and Action - Visit [block:image] { "images": [ { "image": [ "https://files.readme.io/4l1tE04pR5uVKvpaeDv6_Da-proximity-experience.png", "Da-proximity-experience.png", "911", "457", "#3ba0da", "" ], "caption": "To map real-world context, MOCA introduces some fundamental concepts." } ] } [/block] To start using Bluetooth beacon-based proximity experiences in your app, you’ll need to enable proximity service. 1. Ensure proximity service is enabled in MOCAConfig.plist file. [block:image] { "images": [ { "image": [ "https://files.readme.io/pxJrwqaqT5yKS1r1VbqO_proximity-service.png", "proximity-service.png", "587", "245", "#425479", "" ] } ] } [/block] 2. The `[MOCA initializeSDK]` call will automatically start MOCA proximity engine and synchronize proximity campaigns defined in your MOCA cloud account. ###Places Represents a real-world locations, such as a store, venue, museum, building, office and so on. - A place can be localized by a geo-fence (GPS location and radius in meters) - A place contains a collection of zones, where each zone defines semantics for an indoor location, such as Kids Clothes, Women Clothes, Entrance, Exit, Books, Videogames, etc. ###Zone Represents a indoor area or micro-location within the place with user-defined semantics. - Examples include ds Clothes, Women Clothes, Entrance, Exit, Books, Videogames, etc. - A zone is defined by a range of one or more beacon sensors. ###Beacon It is a BLE, iBeacon-compatible proximity sensor. - Each beacon is identified by { Proximity UUID, Major and Minor } tuple. - MOCA SDK works with any iBeacon-compatible devices. - This includes MOCA Beacons - And beacons provided by other manufacturers such as Kontakt.io, Estimote, etc. - Beacons are assigned to Zones that define their micro-location semantics. - Each beacon must be registered in MOCA Management Console. ###Campaigns Collections of proximity experiences that are delivered to a user within a specified time frame. ###Experience Defines a proximity interaction with a user. - An experience is composed of a trigger condition and an action. - When proximity trigger conditions are met, the corresponding action is fired. ###Trigger It is a condition or a collection of conditions that must be met to fire an action associated with an experience. For example: - Enter place, - Exit place, - Enter zone, - Exit zone, - Enter beacon range with given proximity, - Exit beacon range - Custom trigger (implemented as app-provided delegate callback) ###Action Describes an activity to be performed when experience trigger conditions are met. The SDK supports the following actions: - Show local push notification with a specific message - Play sound with a specific file name (included in app bundle) - Play video from URL - Show image from URL - Show HTML content from URL - Open custom URL - Show PassBook card - Custom action (implemented as app-provided delegate callback) The SDK provides delegates that enable full customization of all performed actions. See `MOCAProximityActionsDelegate` in `MOCAProximityDelegate.h` file for details.
{"_id":"55a90b30c8bd450d000dd164","createdAt":"2015-07-17T14:03:28.610Z","excerpt":"","link_external":false,"title":"Proximity Events Delegate","type":"basic","version":"559a61d2dbcfd20d00710b3c","user":"559a618bdbcfd20d00710b38","api":{"url":"","auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":""},"githubsync":"","isReference":false,"link_url":"","parentDoc":null,"sync_unique":"","body":"Implement MOCAProximityEventsDelegate to handle proximity events:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"@interface AppDelegate : UIResponder <UIApplicationDelegate, MOCAProximityEventsDelegate>\\n\\n…\\n\\nMOCAProximityService * proxService = [MOCA proximityService];\\nif (proxService)\\n{\\n    // Notify me when beacon-related events are fired.\\n    [proxService eventsDelegate:self];\\n}\\n\\n/**\\n * Method invoked when a proximity service loaded or updated a registry of beacons\\n * from MOCA cloud.\\n *\\n * @param service proximity service\\n * @param beacons current collection of registered beacons\\n *\\n * @return YES if the custom trigger fired, or NO otherwise.\\n */\\n-(void)proximityService:(MOCAProximityService*)service\\n   didLoadedBeaconsData:(NSArray*)beacons\\n{\\n    NSLog(@\\\"Current beacon registry:\\\");\\n    for (MOCABeacon * beacon in beacons)\\n    {\\n        NSLog(@\\\"\\\\tBeacon name %@, UUID %@, Major %@, Minor %@\\\", \\u000b           beacon.name, [beacon.proximityUUID UUIDString], beacon.major, beacon.minor);\\n    }\\n}\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nThe MOCAProximityEventsDelegate exposes the following events:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"@protocol MOCAProximityEventsDelegate <NSObject>\\n\\[email protected]\\n\\n-(void)proximityService:(MOCAProximityService*)service didEnterRange:(MOCABeacon *)beacon withProximity:(CLProximity)proximity;\\n-(void)proximityService:(MOCAProximityService*)service didExitRange:(MOCABeacon *)beacon;\\n-(void)proximityService:(MOCAProximityService*)service didBeaconProximityChange:(MOCABeacon*)beacon\\n               fromProximity:(CLProximity)prevProximity toProximity:(CLProximity)curProximity;\\n\\n-(void)proximityService:(MOCAProximityService*)service didEnterPlace:(MOCAPlace *)place;\\n-(void)proximityService:(MOCAProximityService*)service didExitPlace:(MOCAPlace *)place;\\n\\n-(void)proximityService:(MOCAProximityService*)service didEnterZone:(MOCAZone *)zone;\\n-(void)proximityService:(MOCAProximityService*)service didExitZone:(MOCAZone *)zone;\\n\\n-(BOOL)proximityService:(MOCAProximityService*)service handleCustomTrigger:(NSString*)customAttribute;\\n\\n-(void)proximityService:(MOCAProximityService*)service didLoadedBeaconsData:(NSArray*)beacons;\\n\\[email protected]\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"These methods are completely optional. You don't need to implement them in order to get Proximity Experiences. \\nImplement these methods if you want to have a deeper integration with MOCA SDK. (e.g. custom information in your app views).\"\n}\n[/block]","hidden":false,"slug":"proximity-events-delegate","__v":2,"category":"55a8e7a227a17d21005251a2","next":{"description":"","pages":[]},"order":10,"project":"559a61d2dbcfd20d00710b39","updates":[],"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Proximity Events Delegate


Implement MOCAProximityEventsDelegate to handle proximity events: [block:code] { "codes": [ { "code": "@interface AppDelegate : UIResponder <UIApplicationDelegate, MOCAProximityEventsDelegate>\n\n…\n\nMOCAProximityService * proxService = [MOCA proximityService];\nif (proxService)\n{\n // Notify me when beacon-related events are fired.\n [proxService eventsDelegate:self];\n}\n\n/**\n * Method invoked when a proximity service loaded or updated a registry of beacons\n * from MOCA cloud.\n *\n * @param service proximity service\n * @param beacons current collection of registered beacons\n *\n * @return YES if the custom trigger fired, or NO otherwise.\n */\n-(void)proximityService:(MOCAProximityService*)service\n didLoadedBeaconsData:(NSArray*)beacons\n{\n NSLog(@\"Current beacon registry:\");\n for (MOCABeacon * beacon in beacons)\n {\n NSLog(@\"\\tBeacon name %@, UUID %@, Major %@, Minor %@\", \u000b beacon.name, [beacon.proximityUUID UUIDString], beacon.major, beacon.minor);\n }\n}\n", "language": "objectivec" } ] } [/block] The MOCAProximityEventsDelegate exposes the following events: [block:code] { "codes": [ { "code": "@protocol MOCAProximityEventsDelegate <NSObject>\n\[email protected]\n\n-(void)proximityService:(MOCAProximityService*)service didEnterRange:(MOCABeacon *)beacon withProximity:(CLProximity)proximity;\n-(void)proximityService:(MOCAProximityService*)service didExitRange:(MOCABeacon *)beacon;\n-(void)proximityService:(MOCAProximityService*)service didBeaconProximityChange:(MOCABeacon*)beacon\n fromProximity:(CLProximity)prevProximity toProximity:(CLProximity)curProximity;\n\n-(void)proximityService:(MOCAProximityService*)service didEnterPlace:(MOCAPlace *)place;\n-(void)proximityService:(MOCAProximityService*)service didExitPlace:(MOCAPlace *)place;\n\n-(void)proximityService:(MOCAProximityService*)service didEnterZone:(MOCAZone *)zone;\n-(void)proximityService:(MOCAProximityService*)service didExitZone:(MOCAZone *)zone;\n\n-(BOOL)proximityService:(MOCAProximityService*)service handleCustomTrigger:(NSString*)customAttribute;\n\n-(void)proximityService:(MOCAProximityService*)service didLoadedBeaconsData:(NSArray*)beacons;\n\[email protected]\n", "language": "objectivec" } ] } [/block] [block:callout] { "type": "warning", "body": "These methods are completely optional. You don't need to implement them in order to get Proximity Experiences. \nImplement these methods if you want to have a deeper integration with MOCA SDK. (e.g. custom information in your app views)." } [/block]
Implement MOCAProximityEventsDelegate to handle proximity events: [block:code] { "codes": [ { "code": "@interface AppDelegate : UIResponder <UIApplicationDelegate, MOCAProximityEventsDelegate>\n\n…\n\nMOCAProximityService * proxService = [MOCA proximityService];\nif (proxService)\n{\n // Notify me when beacon-related events are fired.\n [proxService eventsDelegate:self];\n}\n\n/**\n * Method invoked when a proximity service loaded or updated a registry of beacons\n * from MOCA cloud.\n *\n * @param service proximity service\n * @param beacons current collection of registered beacons\n *\n * @return YES if the custom trigger fired, or NO otherwise.\n */\n-(void)proximityService:(MOCAProximityService*)service\n didLoadedBeaconsData:(NSArray*)beacons\n{\n NSLog(@\"Current beacon registry:\");\n for (MOCABeacon * beacon in beacons)\n {\n NSLog(@\"\\tBeacon name %@, UUID %@, Major %@, Minor %@\", \u000b beacon.name, [beacon.proximityUUID UUIDString], beacon.major, beacon.minor);\n }\n}\n", "language": "objectivec" } ] } [/block] The MOCAProximityEventsDelegate exposes the following events: [block:code] { "codes": [ { "code": "@protocol MOCAProximityEventsDelegate <NSObject>\n\[email protected]\n\n-(void)proximityService:(MOCAProximityService*)service didEnterRange:(MOCABeacon *)beacon withProximity:(CLProximity)proximity;\n-(void)proximityService:(MOCAProximityService*)service didExitRange:(MOCABeacon *)beacon;\n-(void)proximityService:(MOCAProximityService*)service didBeaconProximityChange:(MOCABeacon*)beacon\n fromProximity:(CLProximity)prevProximity toProximity:(CLProximity)curProximity;\n\n-(void)proximityService:(MOCAProximityService*)service didEnterPlace:(MOCAPlace *)place;\n-(void)proximityService:(MOCAProximityService*)service didExitPlace:(MOCAPlace *)place;\n\n-(void)proximityService:(MOCAProximityService*)service didEnterZone:(MOCAZone *)zone;\n-(void)proximityService:(MOCAProximityService*)service didExitZone:(MOCAZone *)zone;\n\n-(BOOL)proximityService:(MOCAProximityService*)service handleCustomTrigger:(NSString*)customAttribute;\n\n-(void)proximityService:(MOCAProximityService*)service didLoadedBeaconsData:(NSArray*)beacons;\n\[email protected]\n", "language": "objectivec" } ] } [/block] [block:callout] { "type": "warning", "body": "These methods are completely optional. You don't need to implement them in order to get Proximity Experiences. \nImplement these methods if you want to have a deeper integration with MOCA SDK. (e.g. custom information in your app views)." } [/block]
{"_id":"55a90c56cf45e1390093f2bf","hidden":false,"isReference":false,"slug":"proximity-actions-delegate","version":"559a61d2dbcfd20d00710b3c","excerpt":"","order":11,"parentDoc":null,"type":"basic","updates":[],"category":"55a8e7a227a17d21005251a2","link_external":false,"createdAt":"2015-07-17T14:08:22.327Z","githubsync":"","link_url":"","project":"559a61d2dbcfd20d00710b39","__v":2,"body":"You may also customize actions using MOCAProximityActionsDelegate:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"@protocol MOCAProximityActionsDelegate <NSObject>\\n\\[email protected]\\n\\n/**\\n * Called to determine if a specific proximity action can be executed now.\\n * @param service - proximity service instance\\n *\\n * Discussion\\n *\\n * It is typically implemented by the hosting app that wants to control\\n * when the experiences should be displayed and when not.\\n * \\n * Example\\n *\\n * An app that displays a splash screen may want to enable proximity actions\\n * to be displayed only after displaying the home screen.\\n */\\n-(BOOL)actionCanDisplayNow:(MOCAAction*)sender withSituation:(MOCAFireSituation)situation;\\n\\n/**\\n * Called when action if fired and accepted by actionCanDisplayNow() method.\\n * This method is invoked for all action types and should be used to perform generic action logic.\\n * @return YES if action execution flow should proceed, or NO otherwise.\\n */\\n-(BOOL)action:(MOCAAction*)sender withSituation:(MOCAFireSituation)situation;\\n\\n/**\\n * Called when an alert notification should be displayed to a user.\\n * @param alertMessage a simple string to be displayed as an alert\\n * @return YES if the alert was shown to the user, NO otherwise.\\n */\\n-(BOOL)action:(MOCAAction*)sender displayNotificationAlert:(NSString *)alertMessage withSituation:(MOCAFireSituation)situation;\\n\\n/*\\n * Called when a URL content should be displayed to a user.\\n * @param url a content URL to be displayed\\n * @return YES if the alert was shown to the user, NO otherwise.\\n */\\n-(BOOL)action:(MOCAAction*)sender openUrl:(NSURL*)url withSituation:(MOCAFireSituation)situation;\\n\\n/*\\n * Called when a embedded HTML content should be displayed to a user.\\n * @param html a HTML content to be displayed\\n * @return YES if the alert was shown to the user, NO otherwise.\\n */\\n-(BOOL)action:(MOCAAction*)sender showHtmlWithString:(NSString*)html withSituation:(MOCAFireSituation)situation;\\n\\n/*\\n * Called when a video from URL should be played to a user.\\n * @param url - video content URL\\n * @return YES if the alert was shown to the user, NO otherwise.\\n */\\n-(BOOL)action:(MOCAAction*)sender playVideoFromUrl:(NSURL*)url withSituation:(MOCAFireSituation)situation;\\n\\n/*\\n * Called when an image from URL should be displayed to a user.\\n * @param url - image URL\\n * @return YES if the alert was shown to the user, NO otherwise.\\n */\\n-(BOOL)action:(MOCAAction*)sender displayImageFromUrl:(NSURL*)url withSituation:(MOCAFireSituation)situation;\\n\\n/*\\n * Called when a Passbook pass card from URL should be displayed to a user.\\n * @param url - pass URL\\n * @return YES if the alert was shown to the user, NO otherwise.\\n */\\n-(BOOL)action:(MOCAAction*)sender displayPassFromUrl:(NSURL*)url withSituation:(MOCAFireSituation)situation;\\n\\n/*\\n * Called when a user should be tagged.\\n * @param tagName name of the tag\\n * @param value value to be added\\n * @return YES if the tag should be added to user profile, NO otherwise.\\n */\\n-(BOOL)action:(MOCAAction*)sender addTag:(NSString*)tagName withValue:(NSString*)value;\\n\\n/*\\n * Called when a sound notification should be played.\\n * @param soundFilename The sound file to play or `default` for the standard notification sound.\\n * This file must be included in the application bundle or available in system bundle.\\n * @return YES if the alert was shown to the user, NO otherwise.\\n */\\n-(BOOL)action:(MOCAAction*)sender playNotificationSound:(NSString *)soundFilename withSituation:(MOCAFireSituation)situation;\\n\\n/*\\n * Called when the app should execute a custom action.\\n * @param customAttribute - user provided custom attribute\\n * @return YES if the alert was shown to the user, NO otherwise.\\n */\\n-(BOOL)action:(MOCAAction*)sender performCustomAction:(NSString*)customAttribute withSituation:(MOCAFireSituation)situation;\\n\\n/** \\n * Called to customize the app root view that should be used to display overlay popup window.\\n * @param view - default superview to add the overlay to as a child view.\\n * @return selected view to be used as superview.\\n */\\n-(UIView*)willShowOverlayInView:(UIView*) superview;\\n\\[email protected]\\n\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Use these methods to **override** MOCA SDK default behavior.\"\n}\n[/block]","title":"Proximity Actions Delegate","user":"559a618bdbcfd20d00710b38","api":{"url":"","auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":""},"sync_unique":"","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Proximity Actions Delegate


You may also customize actions using MOCAProximityActionsDelegate: [block:code] { "codes": [ { "code": "@protocol MOCAProximityActionsDelegate <NSObject>\n\[email protected]\n\n/**\n * Called to determine if a specific proximity action can be executed now.\n * @param service - proximity service instance\n *\n * Discussion\n *\n * It is typically implemented by the hosting app that wants to control\n * when the experiences should be displayed and when not.\n * \n * Example\n *\n * An app that displays a splash screen may want to enable proximity actions\n * to be displayed only after displaying the home screen.\n */\n-(BOOL)actionCanDisplayNow:(MOCAAction*)sender withSituation:(MOCAFireSituation)situation;\n\n/**\n * Called when action if fired and accepted by actionCanDisplayNow() method.\n * This method is invoked for all action types and should be used to perform generic action logic.\n * @return YES if action execution flow should proceed, or NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender withSituation:(MOCAFireSituation)situation;\n\n/**\n * Called when an alert notification should be displayed to a user.\n * @param alertMessage a simple string to be displayed as an alert\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender displayNotificationAlert:(NSString *)alertMessage withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when a URL content should be displayed to a user.\n * @param url a content URL to be displayed\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender openUrl:(NSURL*)url withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when a embedded HTML content should be displayed to a user.\n * @param html a HTML content to be displayed\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender showHtmlWithString:(NSString*)html withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when a video from URL should be played to a user.\n * @param url - video content URL\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender playVideoFromUrl:(NSURL*)url withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when an image from URL should be displayed to a user.\n * @param url - image URL\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender displayImageFromUrl:(NSURL*)url withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when a Passbook pass card from URL should be displayed to a user.\n * @param url - pass URL\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender displayPassFromUrl:(NSURL*)url withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when a user should be tagged.\n * @param tagName name of the tag\n * @param value value to be added\n * @return YES if the tag should be added to user profile, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender addTag:(NSString*)tagName withValue:(NSString*)value;\n\n/*\n * Called when a sound notification should be played.\n * @param soundFilename The sound file to play or `default` for the standard notification sound.\n * This file must be included in the application bundle or available in system bundle.\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender playNotificationSound:(NSString *)soundFilename withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when the app should execute a custom action.\n * @param customAttribute - user provided custom attribute\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender performCustomAction:(NSString*)customAttribute withSituation:(MOCAFireSituation)situation;\n\n/** \n * Called to customize the app root view that should be used to display overlay popup window.\n * @param view - default superview to add the overlay to as a child view.\n * @return selected view to be used as superview.\n */\n-(UIView*)willShowOverlayInView:(UIView*) superview;\n\[email protected]\n\n", "language": "objectivec" } ] } [/block] [block:callout] { "type": "warning", "body": "Use these methods to **override** MOCA SDK default behavior." } [/block]
You may also customize actions using MOCAProximityActionsDelegate: [block:code] { "codes": [ { "code": "@protocol MOCAProximityActionsDelegate <NSObject>\n\[email protected]\n\n/**\n * Called to determine if a specific proximity action can be executed now.\n * @param service - proximity service instance\n *\n * Discussion\n *\n * It is typically implemented by the hosting app that wants to control\n * when the experiences should be displayed and when not.\n * \n * Example\n *\n * An app that displays a splash screen may want to enable proximity actions\n * to be displayed only after displaying the home screen.\n */\n-(BOOL)actionCanDisplayNow:(MOCAAction*)sender withSituation:(MOCAFireSituation)situation;\n\n/**\n * Called when action if fired and accepted by actionCanDisplayNow() method.\n * This method is invoked for all action types and should be used to perform generic action logic.\n * @return YES if action execution flow should proceed, or NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender withSituation:(MOCAFireSituation)situation;\n\n/**\n * Called when an alert notification should be displayed to a user.\n * @param alertMessage a simple string to be displayed as an alert\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender displayNotificationAlert:(NSString *)alertMessage withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when a URL content should be displayed to a user.\n * @param url a content URL to be displayed\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender openUrl:(NSURL*)url withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when a embedded HTML content should be displayed to a user.\n * @param html a HTML content to be displayed\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender showHtmlWithString:(NSString*)html withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when a video from URL should be played to a user.\n * @param url - video content URL\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender playVideoFromUrl:(NSURL*)url withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when an image from URL should be displayed to a user.\n * @param url - image URL\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender displayImageFromUrl:(NSURL*)url withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when a Passbook pass card from URL should be displayed to a user.\n * @param url - pass URL\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender displayPassFromUrl:(NSURL*)url withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when a user should be tagged.\n * @param tagName name of the tag\n * @param value value to be added\n * @return YES if the tag should be added to user profile, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender addTag:(NSString*)tagName withValue:(NSString*)value;\n\n/*\n * Called when a sound notification should be played.\n * @param soundFilename The sound file to play or `default` for the standard notification sound.\n * This file must be included in the application bundle or available in system bundle.\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender playNotificationSound:(NSString *)soundFilename withSituation:(MOCAFireSituation)situation;\n\n/*\n * Called when the app should execute a custom action.\n * @param customAttribute - user provided custom attribute\n * @return YES if the alert was shown to the user, NO otherwise.\n */\n-(BOOL)action:(MOCAAction*)sender performCustomAction:(NSString*)customAttribute withSituation:(MOCAFireSituation)situation;\n\n/** \n * Called to customize the app root view that should be used to display overlay popup window.\n * @param view - default superview to add the overlay to as a child view.\n * @return selected view to be used as superview.\n */\n-(UIView*)willShowOverlayInView:(UIView*) superview;\n\[email protected]\n\n", "language": "objectivec" } ] } [/block] [block:callout] { "type": "warning", "body": "Use these methods to **override** MOCA SDK default behavior." } [/block]
{"_id":"55a9102bc8bd450d000dd170","category":"55a8e7a227a17d21005251a2","isReference":false,"type":"basic","hidden":false,"link_url":"","slug":"design-considerations","title":"Design considerations","updates":[],"createdAt":"2015-07-17T14:24:43.591Z","excerpt":"","githubsync":"","user":"559a618bdbcfd20d00710b38","order":12,"parentDoc":null,"project":"559a61d2dbcfd20d00710b39","__v":3,"body":"Location service authorization\n- By default, MOCA tracks user location and proximity interactions\n- The geo-location is tracked with 100-meter precision. \n- This is performed by means of iOS CLLocationManager\n- The user must allow the location tracking for the app (iOS 8 UseAlways mode).\n- The geo-location minimizes battery usage by employing SignificantLocationChange tracking\n- When the permission is not granted, MOCA does not track user location.\n\nHow event tracking works\n- MOCA SDK uses SQLite database stored in a local file on your phone to store all locally tracked events.\n- Periodically, when your device is connected to Internet (via Edge, 3G, LTE or WiFi), \u000bthe SDK incrementally transfers the packs of events to the cloud.\n- The local database is freed only when the transfer is successful (Store-And-Forward)\n- By default, the event transfer is performed every 15 minutes, but this may change depending on existing network conditions.\n\nBackground modes \n- MOCA SDK requires you to declare Background Modes for your app.\n- Open Capabilities tab in your App project build settings and configure the following options. The minimal configuration is as follows:\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ohipoRJRjK5UpOWpEMV8_background-modes.png\",\n        \"background-modes.png\",\n        \"1020\",\n        \"352\",\n        \"#395b8c\",\n        \"\"\n      ],\n      \"caption\": \"Background Modes\"\n    }\n  ]\n}\n[/block]\n- The `Background Fetch` option is required to periodically fetch the proximity campaign data from the cloud.\n- The `Uses Bluetooth LE accessories` is used by MOCA in order to be informed about Bluetooth status in the background.\n\nOffline behavior\n- MOCA SDK downloads proximity campaigns data from the cloud asynchronously using \u000b*background fetch* mechanism. \n- The frequency is controlled by iOS and depends on the app usage pattern.\n- The downloaded data is persisted locally and on servers as a cache.\n- If the connection to Internet is not available, the cached data is used to run the campaigns.\n- This enables you to offer proximity experiences even if the Internet connection is saturated or not available.","version":"559a61d2dbcfd20d00710b3c","api":{"auth":"required","params":[],"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"name":"","status":400,"language":"json","code":"{}"}]},"settings":"","url":""},"link_external":false,"sync_unique":"","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Design considerations


Location service authorization - By default, MOCA tracks user location and proximity interactions - The geo-location is tracked with 100-meter precision. - This is performed by means of iOS CLLocationManager - The user must allow the location tracking for the app (iOS 8 UseAlways mode). - The geo-location minimizes battery usage by employing SignificantLocationChange tracking - When the permission is not granted, MOCA does not track user location. How event tracking works - MOCA SDK uses SQLite database stored in a local file on your phone to store all locally tracked events. - Periodically, when your device is connected to Internet (via Edge, 3G, LTE or WiFi), the SDK incrementally transfers the packs of events to the cloud. - The local database is freed only when the transfer is successful (Store-And-Forward) - By default, the event transfer is performed every 15 minutes, but this may change depending on existing network conditions. Background modes - MOCA SDK requires you to declare Background Modes for your app. - Open Capabilities tab in your App project build settings and configure the following options. The minimal configuration is as follows: [block:image] { "images": [ { "image": [ "https://files.readme.io/ohipoRJRjK5UpOWpEMV8_background-modes.png", "background-modes.png", "1020", "352", "#395b8c", "" ], "caption": "Background Modes" } ] } [/block] - The `Background Fetch` option is required to periodically fetch the proximity campaign data from the cloud. - The `Uses Bluetooth LE accessories` is used by MOCA in order to be informed about Bluetooth status in the background. Offline behavior - MOCA SDK downloads proximity campaigns data from the cloud asynchronously using *background fetch* mechanism. - The frequency is controlled by iOS and depends on the app usage pattern. - The downloaded data is persisted locally and on servers as a cache. - If the connection to Internet is not available, the cached data is used to run the campaigns. - This enables you to offer proximity experiences even if the Internet connection is saturated or not available.
Location service authorization - By default, MOCA tracks user location and proximity interactions - The geo-location is tracked with 100-meter precision. - This is performed by means of iOS CLLocationManager - The user must allow the location tracking for the app (iOS 8 UseAlways mode). - The geo-location minimizes battery usage by employing SignificantLocationChange tracking - When the permission is not granted, MOCA does not track user location. How event tracking works - MOCA SDK uses SQLite database stored in a local file on your phone to store all locally tracked events. - Periodically, when your device is connected to Internet (via Edge, 3G, LTE or WiFi), the SDK incrementally transfers the packs of events to the cloud. - The local database is freed only when the transfer is successful (Store-And-Forward) - By default, the event transfer is performed every 15 minutes, but this may change depending on existing network conditions. Background modes - MOCA SDK requires you to declare Background Modes for your app. - Open Capabilities tab in your App project build settings and configure the following options. The minimal configuration is as follows: [block:image] { "images": [ { "image": [ "https://files.readme.io/ohipoRJRjK5UpOWpEMV8_background-modes.png", "background-modes.png", "1020", "352", "#395b8c", "" ], "caption": "Background Modes" } ] } [/block] - The `Background Fetch` option is required to periodically fetch the proximity campaign data from the cloud. - The `Uses Bluetooth LE accessories` is used by MOCA in order to be informed about Bluetooth status in the background. Offline behavior - MOCA SDK downloads proximity campaigns data from the cloud asynchronously using *background fetch* mechanism. - The frequency is controlled by iOS and depends on the app usage pattern. - The downloaded data is persisted locally and on servers as a cache. - If the connection to Internet is not available, the cached data is used to run the campaigns. - This enables you to offer proximity experiences even if the Internet connection is saturated or not available.
{"_id":"55a9172a27a17d210052524e","sync_unique":"","__v":22,"body":"<div class=\"tg-wrap\"><table style=\"border-collapse:collapse;border-spacing:0;margin:0px auto\"><tr><th style=\"font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top\">Android Version</th><th style=\"font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top\">Code name</th><th style=\"font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top\">API Level</th><th style=\"font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top\">Profile sensing</th><th style=\"font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top\">Analytics</th><th style=\"font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top\">Custom Events</th><th style=\"font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top\">Geofences</th><th style=\"font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top\">Location tracking</th><th style=\"font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top\">Bluetooth Beacons</th><th style=\"font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top\">Campaigns</th><th style=\"font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top\">Remote Push Notifications</th></tr><tr><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#5b1647;color:#efefef;text-align:center;vertical-align:top\">4.0</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#5b1647;color:#efefef;text-align:center;vertical-align:top\">Ice Cream Sandwich</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#5b1647;color:#efefef;text-align:center;vertical-align:top\">14-15</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">X</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td></tr><tr><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top\">4.1</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top\">Jelly Bean</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top\">16</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">X</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td></tr><tr><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top\">4.2</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top\">Jelly Bean</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top\">17</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">X</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td></tr><tr><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top\">4.3</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top\">Jelly Bean</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top\">18</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">X</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td></tr><tr><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#c90035;color:#efefef;text-align:center;vertical-align:top\">4.4</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#c90035;color:#efefef;text-align:center;vertical-align:top\">KitKat</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#c90035;color:#efefef;text-align:center;vertical-align:top\">19</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔\\*</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td></tr><tr><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ff5627;color:#efefef;text-align:center;vertical-align:top\">5.0</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ff5627;color:#efefef;text-align:center;vertical-align:top\">Lollipop</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ff5627;color:#efefef;text-align:center;vertical-align:top\">21</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔\\*\\*</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td></tr><tr><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ffc400;color:#656565;text-align:center;vertical-align:top\">6.0</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ffc400;color:#656565;text-align:center;vertical-align:top\">Marshmallow</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ffc400;color:#656565;text-align:center;vertical-align:top\">23</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔\\*\\*</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">✔</td></tr><tr><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#027175;color:#efefef;text-align:center;vertical-align:top\">Developer Preview 2</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#027175;color:#efefef;text-align:center;vertical-align:top\">N</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#027175;color:#efefef;text-align:center;vertical-align:top\"></td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">-</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">-</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">-</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">-</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">-</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">-</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">-</td><td style=\"font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top\">-</td></tr></table></div>\n\n\n\n*** Beacon sensors detection in not natively supported in this version of Android operating system.  The provided implementation uses lower level BLE  (Bluetooth Low Energy) scanning that might impact battery usage. \n\n** Android 5.0+ brings important improvements to BLE scanning software, providing battery-friendly background beacon detection.","createdAt":"2015-07-17T14:54:34.609Z","link_url":"","type":"basic","updates":[],"api":{"auth":"required","params":[],"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"category":"55a589e30f354f0d00fd0312","excerpt":"","hidden":false,"title":"Android compatibility chart","slug":"moca-android-sdk-compatibility-chart","githubsync":"","isReference":false,"link_external":false,"parentDoc":null,"project":"559a61d2dbcfd20d00710b39","order":0,"user":"559a618bdbcfd20d00710b38","version":"559a61d2dbcfd20d00710b3c","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Android compatibility chart


<div class="tg-wrap"><table style="border-collapse:collapse;border-spacing:0;margin:0px auto"><tr><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Android Version</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Code name</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">API Level</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Profile sensing</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Analytics</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Custom Events</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Geofences</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Location tracking</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Bluetooth Beacons</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Campaigns</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Remote Push Notifications</th></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#5b1647;color:#efefef;text-align:center;vertical-align:top">4.0</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#5b1647;color:#efefef;text-align:center;vertical-align:top">Ice Cream Sandwich</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#5b1647;color:#efefef;text-align:center;vertical-align:top">14-15</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">X</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">4.1</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">Jelly Bean</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">16</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">X</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">4.2</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">Jelly Bean</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">17</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">X</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">4.3</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">Jelly Bean</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">18</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">X</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#c90035;color:#efefef;text-align:center;vertical-align:top">4.4</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#c90035;color:#efefef;text-align:center;vertical-align:top">KitKat</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#c90035;color:#efefef;text-align:center;vertical-align:top">19</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔\*</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ff5627;color:#efefef;text-align:center;vertical-align:top">5.0</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ff5627;color:#efefef;text-align:center;vertical-align:top">Lollipop</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ff5627;color:#efefef;text-align:center;vertical-align:top">21</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔\*\*</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ffc400;color:#656565;text-align:center;vertical-align:top">6.0</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ffc400;color:#656565;text-align:center;vertical-align:top">Marshmallow</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ffc400;color:#656565;text-align:center;vertical-align:top">23</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔\*\*</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#027175;color:#efefef;text-align:center;vertical-align:top">Developer Preview 2</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#027175;color:#efefef;text-align:center;vertical-align:top">N</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#027175;color:#efefef;text-align:center;vertical-align:top"></td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td></tr></table></div> *** Beacon sensors detection in not natively supported in this version of Android operating system. The provided implementation uses lower level BLE (Bluetooth Low Energy) scanning that might impact battery usage. ** Android 5.0+ brings important improvements to BLE scanning software, providing battery-friendly background beacon detection.
<div class="tg-wrap"><table style="border-collapse:collapse;border-spacing:0;margin:0px auto"><tr><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Android Version</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Code name</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">API Level</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Profile sensing</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Analytics</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Custom Events</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Geofences</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Location tracking</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Bluetooth Beacons</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Campaigns</th><th style="font-family:Arial, sans-serif;font-size:11px;font-weight:bold;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#343434;color:#ffffff;text-align:center;vertical-align:top">Remote Push Notifications</th></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#5b1647;color:#efefef;text-align:center;vertical-align:top">4.0</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#5b1647;color:#efefef;text-align:center;vertical-align:top">Ice Cream Sandwich</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#5b1647;color:#efefef;text-align:center;vertical-align:top">14-15</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">X</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">4.1</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">Jelly Bean</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">16</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">X</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">4.2</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">Jelly Bean</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">17</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">X</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">4.3</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">Jelly Bean</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#93073e;color:#efefef;text-align:center;vertical-align:top">18</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">X</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#c90035;color:#efefef;text-align:center;vertical-align:top">4.4</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#c90035;color:#efefef;text-align:center;vertical-align:top">KitKat</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#c90035;color:#efefef;text-align:center;vertical-align:top">19</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔\*</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ff5627;color:#efefef;text-align:center;vertical-align:top">5.0</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ff5627;color:#efefef;text-align:center;vertical-align:top">Lollipop</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ff5627;color:#efefef;text-align:center;vertical-align:top">21</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔\*\*</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ffc400;color:#656565;text-align:center;vertical-align:top">6.0</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ffc400;color:#656565;text-align:center;vertical-align:top">Marshmallow</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#ffc400;color:#656565;text-align:center;vertical-align:top">23</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔\*\*</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">✔</td></tr><tr><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#027175;color:#efefef;text-align:center;vertical-align:top">Developer Preview 2</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#027175;color:#efefef;text-align:center;vertical-align:top">N</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;background-color:#027175;color:#efefef;text-align:center;vertical-align:top"></td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td><td style="font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;text-align:center;vertical-align:top">-</td></tr></table></div> *** Beacon sensors detection in not natively supported in this version of Android operating system. The provided implementation uses lower level BLE (Bluetooth Low Energy) scanning that might impact battery usage. ** Android 5.0+ brings important improvements to BLE scanning software, providing battery-friendly background beacon detection.
{"_id":"55a591c780c8a30d00b3240e","__v":13,"hidden":false,"user":"55a575ebaaf9cf1900114d73","githubsync":"","isReference":false,"order":1,"type":"basic","excerpt":"","parentDoc":null,"project":"559a61d2dbcfd20d00710b39","slug":"moca-android-sdk-installation","sync_unique":"","title":"Installation","updates":[],"api":{"auth":"required","params":[],"results":{"codes":[{"name":"","status":200,"language":"json","code":"{}"},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Requirements\"\n}\n[/block]\nYou'll need:\n\n- Android Studio IDE.\n- A real Android device is recommended. Otherwise you won't be able to discover bluetooth beacons.\n- Please check the Android OS [compatibility chart](doc:moca-android-sdk-compatibility-chart).\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Download & Install\"\n}\n[/block]\n1 - Download the latest version from the [downloads page](/docs/downloads).\n2 - Move the `AAR` file to the `app > libs` folder\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/4SExKfbJQLGXc3jyUggd_libs.png\",\n        \"libs.png\",\n        \"759\",\n        \"526\",\n        \"#5487c7\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nNext: [Configuration](doc:moca-android-sdk-configuration)","category":"55a589e30f354f0d00fd0312","createdAt":"2015-07-14T22:48:39.299Z","link_external":false,"link_url":"","version":"559a61d2dbcfd20d00710b3c","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Installation


[block:api-header] { "type": "basic", "title": "Requirements" } [/block] You'll need: - Android Studio IDE. - A real Android device is recommended. Otherwise you won't be able to discover bluetooth beacons. - Please check the Android OS [compatibility chart](doc:moca-android-sdk-compatibility-chart). [block:api-header] { "type": "basic", "title": "Download & Install" } [/block] 1 - Download the latest version from the [downloads page](/docs/downloads). 2 - Move the `AAR` file to the `app > libs` folder [block:image] { "images": [ { "image": [ "https://files.readme.io/4SExKfbJQLGXc3jyUggd_libs.png", "libs.png", "759", "526", "#5487c7", "" ] } ] } [/block] Next: [Configuration](doc:moca-android-sdk-configuration)
[block:api-header] { "type": "basic", "title": "Requirements" } [/block] You'll need: - Android Studio IDE. - A real Android device is recommended. Otherwise you won't be able to discover bluetooth beacons. - Please check the Android OS [compatibility chart](doc:moca-android-sdk-compatibility-chart). [block:api-header] { "type": "basic", "title": "Download & Install" } [/block] 1 - Download the latest version from the [downloads page](/docs/downloads). 2 - Move the `AAR` file to the `app > libs` folder [block:image] { "images": [ { "image": [ "https://files.readme.io/4SExKfbJQLGXc3jyUggd_libs.png", "libs.png", "759", "526", "#5487c7", "" ] } ] } [/block] Next: [Configuration](doc:moca-android-sdk-configuration)
{"_id":"55a9222dc8bd450d000dd1a8","body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Gradle\"\n}\n[/block]\nConfigure the library and its dependencies through `Gradle`\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Gradle path\",\n  \"body\": \"Make sure changes are made to the build.gradle file of your `Module:app`, not of your `Project:project name`.\\n\\nDon't forget to add the `repositories` configuration in your `build.gradle`, as shown below.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"repositories {\\n \\tflatDir {\\n        dirs 'libs'\\n    }\\n}\\n\\nandroid {\\n  ...\\n    ...\\n    ...\\n    \\n  dependencies {\\n    //AppCompat\\n    compile 'com.android.support:support-v4:23.4.0'\\n    compile 'com.android.support:appcompat-v7:23.4.0'\\n\\n    //MOCA SDK\\n    compile(name: 'moca-sdk-android-1.9.+', ext: 'aar')\\n\\n    compile 'org.msgpack:msgpack:0.6.11'\\n\\n    //Google Cloud Messaging\\n    compile 'com.google.android.gms:play-services-gcm:8.3.0'\\n\\n    //Google Location, Activity Recognition, and Places\\n    compile 'com.google.android.gms:play-services-location:8.3.0'\\n\\n    //Google Mobile Ads (Optional)\\n    compile 'com.google.android.gms:play-services-ads:8.3.0'\\t\\n  }\\n}\",\n      \"language\": \"groovy\",\n      \"name\": \"build.gradle\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Installing Google Play Services.\"\n}\n[/block]\nMOCA SDK requires Google Play Services 8.3.0+ as you've seen in the dependencies list above.\nIf your project is not using Google Play Services, please ensure the libraries are installed in your Android Studio before continuing.\nYou can see how to install Google Play Services by visiting this [Google guide](https://developer.android.com/studio/intro/update.html).\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Grab your AppKey and AppSecret\"\n}\n[/block]\n1 - Go to https://console.mocaplatform.com and sign into your MOCA account.  \n2 - Select Apps item at left sidebar, and then click + New App in the content panel. Fill in the form and complete the app creation.  \n3 - Open the newly created app and navigate to Settings item. Select API keys tab.\n4 - Get `App Key` and `App Secret`. \n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/jvi2iXdScWdM4W428eiX_consolekeys.png\",\n        \"consolekeys.png\",\n        \"704\",\n        \"458\",\n        \"#b02428\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nYou can configure the MOCA SDK from the `AndroidManifest.xml` file, or alternatively from a `MOCA.properties` file\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Option A: Configuration through MOCA.properties file\"\n}\n[/block]\nStarting from MOCA Android SDK 1.9.0, you can configure the SDK using a `MOCA.properties` file. \n\n1 - Create an `assets` folder, just inside your App's main folder.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/1k7sOod6QFGfMreUtwCl_assets-folder.png\",\n        \"assets-folder.png\",\n        \"700\",\n        \"598\",\n        \"#5a8fce\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nYou should be able to see a new folder in your project.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/9IgnTA5oSDqOMtqk5Xw0_assets.png\",\n        \"assets.png\",\n        \"272\",\n        \"272\",\n        \"#4d87d1\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n2 - Create a file called `MOCA.properties` by right clicking the `assets` folder and selecting New > File.\n\n3 - Configure the SDK with the necessary keys. Please bear in mind that ***the only mandatory keys are AppKey, and AppSecret***. \nThe ***gcmSender*** is mandatory only if you want to use MOCA Remote Push Notifications service.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Get your GCM Sender from Google\",\n  \"body\": \"Check [this guide](./gcm-fcm-cloud-messaging-setup) in order to get your Cloud Messaging Sender Id.\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"\",\n  \"body\": \"Don't forget to paste the AppKey and AppSecret with the ones corresponding to your App. Otherwise the SDK won't be able to connect to MOCA Cloud.\"\n}\n[/block]\nContents of the `MOCA.properties` file:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#MOCA App key and app secret. You can get this keys from the MOCA Console.\\nappKey = YOUR-MOCA-APP-KEY\\nappSecret = YOUR-MOCA-APP-SECRET\\n\\n#MOCA SDK Log level. Possible values [Off, Error,  Warning, Info, Debug, Verbose]\\nlogLevel = Debug\\n\\n# MOCA Remote Push Notifications\\n# disable it if you have your own/ other remote push implementation\\nremotePushNotificationsService = true\\n\\n# MOCA Proximity Service includes beacon and geofence detection\\nproximityService = true\\n\\n# MOCA GeoTracking Service generates geo points periodically for analytics\\ngeoTrackingService = true\\n\\n# MOCA Event Tracking Service. If enabled, activates event tracking (Sessions, custom events etc.)\\neventTrackingService = true\\n\\n# MOCA driver. This is required for Bluetooth Beacon detection. Set it to false if a custom\\n# beacon driver is being used\\nmocaDriver = true\\n\\n# Background location. Allows geoTracking in background\\nbackgroundLocation = true\\n\\n# GCM Sender ID. Only needed if you are using MOCA Remote Push Notifications.\\ngcmSender = YOUR-GCM-SENDER-ID\\n\\n# Beacon detection engine profile [LowLatency, Balanced, BatterySaver, Custom]\\n# LowLatency = Notifications will be delivered almost instantly in foreground and background.\\n# but will have an important impact on the user's device battery.\\n# Balanced = Notifications are delivered almost instantly in foreground. In background it can\\n# take up to one minute. In Android Lollipop, Marshmallow, and N there are operating system\\n# optimizations that reduce the notification delay (Default setting).\\n# BatterySaver = Detections in foreground can take up to one minute, and in background up to\\n#5 minutes. this is the recommended setting for analytics-only usages.\\n# \\nbeaconProfile = Balanced\\n\\n# If beaconProfile is \\\"Custom\\\", the following parameters are mandatory\\n# foregroundTimeBetweenScans: Time between each scan in milliseconds, close scans means faster response, but\\n#  more battery consumption.\\n# foregroundScanDuration: Time while device will be listening bluetooth signals in milliseconds.\\n#  We recommend at least 1100 ms, so if your beacon broadcasts a signal each 350 Hz,~3 packets\\n#  will be received.\\n# backgroundTimeBetweenScans: Same than foregroundTimeBetweenScans, but when device is in the background.\\n#  this is the most important setting in terms of battery consumption.\\n# backgroundScanDuration: Same than foregroundScanDuration but in background.\\n\\n# Uncomment these parameters in case you want to use a Custom profile\\n\\n# foregroundTimeBetweenScans = 3300\\n# foregroundScanDuration = 3300\\n# backgroundTimeBetweenScans = 60000\\n# backgroundScanDuration = 5001\\n\\n# MOCA Beacon detection settings (approximate distance in meters)\\n# distance detection is strongly dependent on hardware, and device calibration.\\n# Parameter indicates the threshold for the next zone, starting in 0\\n# Default config: 0-1m: immediate, 1m-5m: immediate, >5m far\\n# Uncomment the following lines if you want to override this settings.\\n\\n# proximityImmediate= 1\\n# proximityNear = 5\\n\\n#Other settings\\n\\n#Cache in MB\\ncacheSize = 100\\n\\n#Data fetch interval in milliseconds. Defaults to 1 hour\\ndataFetchInterval = 3600000\\n\\n#Event upload interval. Defaults to 15 minutes.\\neventUploadInterval = 900000\\n\\n# Custom settings\\n# Save custom settings by adding \\\"custom.\\\" prefix\\n# example custom.myCustomSetting = 1000\\ncustom.myCustomSetting = 1000\\n# Legacy notation\\nmoca.CUSTOM_PUSH_ICON = @drawable/ic_moca_logo\\n# moca.CUSTOM_NAOMICRO_APP_KEY = xxxxxx\\n# moca.CUSTOM_NAOMICRO_ENABLED = false\\n\",\n      \"language\": \"ruby\",\n      \"name\": \"MOCA.properties\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Option B: Configuration through `AndroidManifest.xml` file\"\n}\n[/block]\n- SDK Settings: you don't need to use this keys if you have used a `MOCA.properties` file.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Remember to paste the `moca.APP_KEY` and `moca.APP_SECRET` with the ones of your App. Otherwise the SDK won't be able to connect to MOCA Cloud.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<application\\n             ...>\\n      <!-- MOCA SDK configuration -->\\n    <meta-data android:name=\\\"moca.APP_KEY\\\"\\n               android:value=\\\"YOUR-MOCA-APP-KEY\\\"/>\\n    <meta-data android:name=\\\"moca.APP_SECRET\\\"\\n               android:value=\\\"YOUR-MOCA-APP-SECRET\\\"/>\\n    <meta-data android:name=\\\"moca.LOG_LEVEL\\\"\\n               android:value=\\\"debug\\\"/>\\n    <meta-data android:name=\\\"moca.AUTOMATIC_PUSH_SETUP_ENABLED\\\"\\n               android:value=\\\"true\\\"/>\\n    <meta-data android:name=\\\"moca.PROXIMITY_SERVICE_ENABLED\\\"\\n               android:value=\\\"true\\\" />\\n    <meta-data android:name=\\\"moca.GEOLOCATION_SERVICE_ENABLED\\\"\\n               android:value=\\\"true\\\" />\\n    <meta-data android:name=\\\"moca.BACKGROUND_LOCATION_ENABLED\\\"\\n               android:value=\\\"true\\\" />\\n    <meta-data android:name=\\\"moca.DATA_FETCH_INTERVAL_MS\\\"\\n               android:value=\\\"auto\\\" />\\n    <meta-data android:name=\\\"moca.EVENT_UPLOAD_INTERVAL_MS\\\"\\n               android:value=\\\"auto\\\" />\\n  \\t<meta-data android:name=\\\"moca.MOCA_DRIVER_ENABLED\\\"\\n               android:value=\\\"true\\\" />\\n    <!--Optional: Include it for remote push notifications-->\\n    <!--Be careful with the space before the number-->\\n    <meta-data android:name=\\\"moca.GCM_SENDER\\\"\\n               android:value=\\\"\\\\ YOUR_GCM_SENDER_ID\\\" />\\n</application>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n- Be sure to replace `moca.APP_KEY` and `moca.APP_SECRET` values with the real values for your app which you found in the MOCA console. \n\nChange any setting that you need for your app:\n\n- `moca.PROXIMITY_SERVICE_ENABLED`, will enable or disable Bluetooth Beacon detection & geofence detection.\n- `moca.GEOLOCATION_SERVICE_ENABLED` – enables/disabled tracking of significant changes in user location by GPS/Cellular Trilateration/Wifi.\n - YES – user location will be tracked when the app is in foreground. Additionally, background tracking is controlled by BACKGROUND_LOCATION_ENABLED flag. This is the default.\n - NO – user location will not be tracked at all (either foreground nor background). Bluetooth beacons and geofences will still be detected if this flag is set to NO. \n- `moca.BACKGROUND_LOCATION_ENABLED` – enables/disables location tracking when the app is in background or suspended mode.\n - This flag has no effect if GEOLOCATION_SERVICE_ENABLED is set to NO.\n - By default background location tracking is enabled.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Services & Receivers\"\n}\n[/block]\n- Please declare these services and receivers no matter what option did you use in the previous steps.\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"body\": \"You will need to override the **Application** class to initialize MOCA, so don't forget to add the tag **android:name=\\\"*pathToYourApplicationClass*\\\"** to **application**.\\n[Learn more about the Application class.](#initializing-moca-in-the-application-class)\",\n  \"title\": \"Please Note\"\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/F3KObXES3CnfPRbMGWbE_android-name-red.gif\",\n        \"android-name-red.gif\",\n        \"630\",\n        \"243\",\n        \"#0f344c\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<application \\n        ...     \\n        android:name=\\\"com.myCompany.MyApplication\\\">\\n\\n    <!-- User Google Play Services -->\\n    <meta-data android:name=\\\"com.google.android.gms.version\\\"\\n               android:value=\\\"@integer/google_play_services_version\\\" />\\n  \\n\\t\\t<!-- REQUIRED by MOCA to handle clicked notifications -->\\n\\t\\t<receiver android:name=\\\"com.innoquant.moca.push.MOCAPushReceiver\\\"\\n  \\t          android:exported=\\\"true\\\"\\n    \\t        android:permission=\\\"com.google.android.c2dm.permission.SEND\\\" >\\n\\t \\t\\t<intent-filter>\\n  \\t  \\t<action android:name=\\\"com.innoquant.moca.push.ACTION_PUSH_RECEIVE\\\" />\\n    \\t  <action android:name=\\\"com.innoquant.moca.push.ACTION_PUSH_DISMISSED\\\" />\\n\\t\\t\\t</intent-filter>\\n\\t\\t</receiver>\\n  \\n\\n    <!-- REQUIRED by MOCA to handle push notifications -->\\n    <receiver android:name=\\\"com.innoquant.moca.push.GcmPushReceiver\\\"\\n              android: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            <category android:name=\\\"YOUR-APP-PACKAGE-NAME\\\" />\\n        </intent-filter>\\n    </receiver>\\n  \\n\\t\\t<!-- MOCA GcmTokenListener listens to token registrations/updates -->\\n    <service android:name=\\\"com.innoquant.moca.push.GcmTokenListener\\\"\\n   \\t\\t\\t\\t\\tandroid:exported=\\\"false\\\">\\n\\t\\t\\t<intent-filter>\\n\\t\\t\\t\\t<action android:name=\\\"com.google.android.gms.iid.InstanceID\\\"/>\\n\\t\\t\\t</intent-filter>\\n\\t\\t</service>\\n  \\n</application>\",\n      \"language\": \"xml\",\n      \"name\": \"AndroidManifest.xml\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Setting app permissions\"\n}\n[/block]\nMOCA SDK archive (*.aar) file comes with proper AndroidManifest.xml file that gets merged with your app's Manifest. Internally, the SDK uses the following permissions:\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"There is no need to include these permissions in your AndroidManifest.xml\",\n  \"title\": \"Please note\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<!-- Required for MOCA SDK -->\\n<uses-permission android:name=\\\"android.permission.INTERNET\\\" />\\n<uses-permission android:name=\\\"android.permission.ACCESS_NETWORK_STATE\\\" />  <!– Required for BLE and Beacons -->\\n<uses-permission android:name=\\\"android.permission.BLUETOOTH\\\" /> \\n<!– Required to monitor reachability --> \\n<uses-permission android:name=\\\"android.permission.ACCESS_WIFI_STATE\\\" />     \\n<!-- Keeps the processor from sleeping when a message is received. -->     <uses-permission android:name=\\\"android.permission.WAKE_LOCK\\\" />\\n<!-- Required for Push --> \\n<uses-permission android:name=\\\"android.permission.VIBRATE\\\" /> \\n<!-- Used to collect location data -->\\n<uses-permission android:name=\\\"android.permission.ACCESS_FINE_LOCATION\\\" />  <!-- Used to collect battery stats -->\\n<uses-permission android:name=\\\"android.permission.BATTERY_STATS\\\" />     <!-- Used to collect carrier -->\\n<uses-permission android:name=\\\"android.permission.READ_PHONE_STATE\\\"/> \\n<!–- Push notifications -->\\n<uses-permission android:name=\\\"com.google.android.c2dm.permission.RECEIVE\\\"/>\\n\\n\\n\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Android Marshmallow (6.0) permissions\"\n}\n[/block]\nRequest the `ACCESS_FINE_LOCATION` permission at Run Time, an example of how to do it is [available here.](doc:android-60-permissions).\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"MOCA SDK included Services & Receivers\"\n}\n[/block]\nMOCA SDK archive (*.aar) file comes with proper AndroidManifest.xml file that gets merged with your app manifest. Internally, the SDK uses the following services & receivers:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<!– In App AndroidManifest.xml -->\\n<meta-data android:name=\\\"moca.CUSTOM_PUSH_ICON\\\" android:resource=\\\"@drawable/YOUR_PUSH_ICON\\\" />\\n\\n<!-- REQUIRED by MOCA to handle push notifications -->\\n<receiver android:name=\\\"com.innoquant.moca.push.MOCAPushReceiver\\\">\\n\\t<intent-filter>\\n\\t       <action android:name=\\\"com.innoquant.moca.push.ACTION_PUSH_RECEIVE\\\" />\\n            <category android:name=\\\"YOUR_APP_PACKAGE\\\" />\\n     </intent-filter>\\n</receiver>       \\n\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n####Remote Push Notifications\n\nIf your plan includes Remote Push Notifications, please ensure the SDK is properly configured.\nCheck the [Push Notifications](/docs/push-notifications) doc.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Initializing MOCA in the Application class\"\n}\n[/block]\nFinally, to start using SDK, you’ll need to initialize MOCA library. \n\n1 - If you don't have one, create a new class that inherits from Application. You will need to declare the name of this class in the `AndroidManifest.xml` file. As you can see in the AndroidManifest.xml section above.\n2 - Import `com.innoquant.moca.*` package into your main **Application** class.\n3 - Initialize MOCA SDK in the `onCreate` method of this class.\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Do not initialize MOCA within an Activity\",\n  \"body\": \"By doing so, MOCA won't be able to manage proximity events when the `Activity` is not running (App not in foreground, for instance).\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import com.innoquant.moca.MOCA;\\nimport com.innoquant.moca.MOCAInstance;\\n\\npublic class MocaApplication extends Application {\\n\\n    @Override\\n    public void onCreate() {\\n        super.onCreate();\\n\\n        // Init MOCA library\\n        MOCA.initializeSDK (this);\\n    }\\n}\\n\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n4 - You must initialize the SDK before calling any other method.\n5 - On initialization, MOCA SDK will load configuration from the `AndroidManifest.xml` file or the `MOCA.properties` file and perform all necessary library setup.","excerpt":"","link_external":false,"type":"basic","link_url":"","parentDoc":null,"slug":"moca-android-sdk-configuration","updates":["5716177840ef9c2000cac8d2","57602f88c811102000cef2fe"],"version":"559a61d2dbcfd20d00710b3c","api":{"settings":"","url":"","auth":"required","params":[],"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"name":"","status":400,"language":"json","code":"{}"}]}},"githubsync":"","isReference":false,"project":"559a61d2dbcfd20d00710b39","sync_unique":"","title":"Configuration","user":"559a618bdbcfd20d00710b38","__v":100,"category":"55a589e30f354f0d00fd0312","createdAt":"2015-07-17T15:41:33.472Z","hidden":false,"order":2,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Configuration


[block:api-header] { "type": "basic", "title": "Gradle" } [/block] Configure the library and its dependencies through `Gradle` [block:callout] { "type": "warning", "title": "Gradle path", "body": "Make sure changes are made to the build.gradle file of your `Module:app`, not of your `Project:project name`.\n\nDon't forget to add the `repositories` configuration in your `build.gradle`, as shown below." } [/block] [block:code] { "codes": [ { "code": "repositories {\n \tflatDir {\n dirs 'libs'\n }\n}\n\nandroid {\n ...\n ...\n ...\n \n dependencies {\n //AppCompat\n compile 'com.android.support:support-v4:23.4.0'\n compile 'com.android.support:appcompat-v7:23.4.0'\n\n //MOCA SDK\n compile(name: 'moca-sdk-android-1.9.+', ext: 'aar')\n\n compile 'org.msgpack:msgpack:0.6.11'\n\n //Google Cloud Messaging\n compile 'com.google.android.gms:play-services-gcm:8.3.0'\n\n //Google Location, Activity Recognition, and Places\n compile 'com.google.android.gms:play-services-location:8.3.0'\n\n //Google Mobile Ads (Optional)\n compile 'com.google.android.gms:play-services-ads:8.3.0'\t\n }\n}", "language": "groovy", "name": "build.gradle" } ] } [/block] [block:api-header] { "type": "basic", "title": "Installing Google Play Services." } [/block] MOCA SDK requires Google Play Services 8.3.0+ as you've seen in the dependencies list above. If your project is not using Google Play Services, please ensure the libraries are installed in your Android Studio before continuing. You can see how to install Google Play Services by visiting this [Google guide](https://developer.android.com/studio/intro/update.html). [block:api-header] { "type": "basic", "title": "Grab your AppKey and AppSecret" } [/block] 1 - Go to https://console.mocaplatform.com and sign into your MOCA account. 2 - Select Apps item at left sidebar, and then click + New App in the content panel. Fill in the form and complete the app creation. 3 - Open the newly created app and navigate to Settings item. Select API keys tab. 4 - Get `App Key` and `App Secret`. [block:image] { "images": [ { "image": [ "https://files.readme.io/jvi2iXdScWdM4W428eiX_consolekeys.png", "consolekeys.png", "704", "458", "#b02428", "" ] } ] } [/block] You can configure the MOCA SDK from the `AndroidManifest.xml` file, or alternatively from a `MOCA.properties` file [block:api-header] { "type": "basic", "title": "Option A: Configuration through MOCA.properties file" } [/block] Starting from MOCA Android SDK 1.9.0, you can configure the SDK using a `MOCA.properties` file. 1 - Create an `assets` folder, just inside your App's main folder. [block:image] { "images": [ { "image": [ "https://files.readme.io/1k7sOod6QFGfMreUtwCl_assets-folder.png", "assets-folder.png", "700", "598", "#5a8fce", "" ] } ] } [/block] You should be able to see a new folder in your project. [block:image] { "images": [ { "image": [ "https://files.readme.io/9IgnTA5oSDqOMtqk5Xw0_assets.png", "assets.png", "272", "272", "#4d87d1", "" ] } ] } [/block] 2 - Create a file called `MOCA.properties` by right clicking the `assets` folder and selecting New > File. 3 - Configure the SDK with the necessary keys. Please bear in mind that ***the only mandatory keys are AppKey, and AppSecret***. The ***gcmSender*** is mandatory only if you want to use MOCA Remote Push Notifications service. [block:callout] { "type": "info", "title": "Get your GCM Sender from Google", "body": "Check [this guide](./gcm-fcm-cloud-messaging-setup) in order to get your Cloud Messaging Sender Id." } [/block] [block:callout] { "type": "warning", "title": "", "body": "Don't forget to paste the AppKey and AppSecret with the ones corresponding to your App. Otherwise the SDK won't be able to connect to MOCA Cloud." } [/block] Contents of the `MOCA.properties` file: [block:code] { "codes": [ { "code": "#MOCA App key and app secret. You can get this keys from the MOCA Console.\nappKey = YOUR-MOCA-APP-KEY\nappSecret = YOUR-MOCA-APP-SECRET\n\n#MOCA SDK Log level. Possible values [Off, Error, Warning, Info, Debug, Verbose]\nlogLevel = Debug\n\n# MOCA Remote Push Notifications\n# disable it if you have your own/ other remote push implementation\nremotePushNotificationsService = true\n\n# MOCA Proximity Service includes beacon and geofence detection\nproximityService = true\n\n# MOCA GeoTracking Service generates geo points periodically for analytics\ngeoTrackingService = true\n\n# MOCA Event Tracking Service. If enabled, activates event tracking (Sessions, custom events etc.)\neventTrackingService = true\n\n# MOCA driver. This is required for Bluetooth Beacon detection. Set it to false if a custom\n# beacon driver is being used\nmocaDriver = true\n\n# Background location. Allows geoTracking in background\nbackgroundLocation = true\n\n# GCM Sender ID. Only needed if you are using MOCA Remote Push Notifications.\ngcmSender = YOUR-GCM-SENDER-ID\n\n# Beacon detection engine profile [LowLatency, Balanced, BatterySaver, Custom]\n# LowLatency = Notifications will be delivered almost instantly in foreground and background.\n# but will have an important impact on the user's device battery.\n# Balanced = Notifications are delivered almost instantly in foreground. In background it can\n# take up to one minute. In Android Lollipop, Marshmallow, and N there are operating system\n# optimizations that reduce the notification delay (Default setting).\n# BatterySaver = Detections in foreground can take up to one minute, and in background up to\n#5 minutes. this is the recommended setting for analytics-only usages.\n# \nbeaconProfile = Balanced\n\n# If beaconProfile is \"Custom\", the following parameters are mandatory\n# foregroundTimeBetweenScans: Time between each scan in milliseconds, close scans means faster response, but\n# more battery consumption.\n# foregroundScanDuration: Time while device will be listening bluetooth signals in milliseconds.\n# We recommend at least 1100 ms, so if your beacon broadcasts a signal each 350 Hz,~3 packets\n# will be received.\n# backgroundTimeBetweenScans: Same than foregroundTimeBetweenScans, but when device is in the background.\n# this is the most important setting in terms of battery consumption.\n# backgroundScanDuration: Same than foregroundScanDuration but in background.\n\n# Uncomment these parameters in case you want to use a Custom profile\n\n# foregroundTimeBetweenScans = 3300\n# foregroundScanDuration = 3300\n# backgroundTimeBetweenScans = 60000\n# backgroundScanDuration = 5001\n\n# MOCA Beacon detection settings (approximate distance in meters)\n# distance detection is strongly dependent on hardware, and device calibration.\n# Parameter indicates the threshold for the next zone, starting in 0\n# Default config: 0-1m: immediate, 1m-5m: immediate, >5m far\n# Uncomment the following lines if you want to override this settings.\n\n# proximityImmediate= 1\n# proximityNear = 5\n\n#Other settings\n\n#Cache in MB\ncacheSize = 100\n\n#Data fetch interval in milliseconds. Defaults to 1 hour\ndataFetchInterval = 3600000\n\n#Event upload interval. Defaults to 15 minutes.\neventUploadInterval = 900000\n\n# Custom settings\n# Save custom settings by adding \"custom.\" prefix\n# example custom.myCustomSetting = 1000\ncustom.myCustomSetting = 1000\n# Legacy notation\nmoca.CUSTOM_PUSH_ICON = @drawable/ic_moca_logo\n# moca.CUSTOM_NAOMICRO_APP_KEY = xxxxxx\n# moca.CUSTOM_NAOMICRO_ENABLED = false\n", "language": "ruby", "name": "MOCA.properties" } ] } [/block] [block:api-header] { "type": "basic", "title": "Option B: Configuration through `AndroidManifest.xml` file" } [/block] - SDK Settings: you don't need to use this keys if you have used a `MOCA.properties` file. [block:callout] { "type": "warning", "body": "Remember to paste the `moca.APP_KEY` and `moca.APP_SECRET` with the ones of your App. Otherwise the SDK won't be able to connect to MOCA Cloud." } [/block] [block:code] { "codes": [ { "code": "<application\n ...>\n <!-- MOCA SDK configuration -->\n <meta-data android:name=\"moca.APP_KEY\"\n android:value=\"YOUR-MOCA-APP-KEY\"/>\n <meta-data android:name=\"moca.APP_SECRET\"\n android:value=\"YOUR-MOCA-APP-SECRET\"/>\n <meta-data android:name=\"moca.LOG_LEVEL\"\n android:value=\"debug\"/>\n <meta-data android:name=\"moca.AUTOMATIC_PUSH_SETUP_ENABLED\"\n android:value=\"true\"/>\n <meta-data android:name=\"moca.PROXIMITY_SERVICE_ENABLED\"\n android:value=\"true\" />\n <meta-data android:name=\"moca.GEOLOCATION_SERVICE_ENABLED\"\n android:value=\"true\" />\n <meta-data android:name=\"moca.BACKGROUND_LOCATION_ENABLED\"\n android:value=\"true\" />\n <meta-data android:name=\"moca.DATA_FETCH_INTERVAL_MS\"\n android:value=\"auto\" />\n <meta-data android:name=\"moca.EVENT_UPLOAD_INTERVAL_MS\"\n android:value=\"auto\" />\n \t<meta-data android:name=\"moca.MOCA_DRIVER_ENABLED\"\n android:value=\"true\" />\n <!--Optional: Include it for remote push notifications-->\n <!--Be careful with the space before the number-->\n <meta-data android:name=\"moca.GCM_SENDER\"\n android:value=\"\\ YOUR_GCM_SENDER_ID\" />\n</application>", "language": "xml" } ] } [/block] - Be sure to replace `moca.APP_KEY` and `moca.APP_SECRET` values with the real values for your app which you found in the MOCA console. Change any setting that you need for your app: - `moca.PROXIMITY_SERVICE_ENABLED`, will enable or disable Bluetooth Beacon detection & geofence detection. - `moca.GEOLOCATION_SERVICE_ENABLED` – enables/disabled tracking of significant changes in user location by GPS/Cellular Trilateration/Wifi. - YES – user location will be tracked when the app is in foreground. Additionally, background tracking is controlled by BACKGROUND_LOCATION_ENABLED flag. This is the default. - NO – user location will not be tracked at all (either foreground nor background). Bluetooth beacons and geofences will still be detected if this flag is set to NO. - `moca.BACKGROUND_LOCATION_ENABLED` – enables/disables location tracking when the app is in background or suspended mode. - This flag has no effect if GEOLOCATION_SERVICE_ENABLED is set to NO. - By default background location tracking is enabled. [block:api-header] { "type": "basic", "title": "Services & Receivers" } [/block] - Please declare these services and receivers no matter what option did you use in the previous steps. [block:callout] { "type": "danger", "body": "You will need to override the **Application** class to initialize MOCA, so don't forget to add the tag **android:name=\"*pathToYourApplicationClass*\"** to **application**.\n[Learn more about the Application class.](#initializing-moca-in-the-application-class)", "title": "Please Note" } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/F3KObXES3CnfPRbMGWbE_android-name-red.gif", "android-name-red.gif", "630", "243", "#0f344c", "" ] } ] } [/block] [block:code] { "codes": [ { "code": "<application \n ... \n android:name=\"com.myCompany.MyApplication\">\n\n <!-- User Google Play Services -->\n <meta-data android:name=\"com.google.android.gms.version\"\n android:value=\"@integer/google_play_services_version\" />\n \n\t\t<!-- REQUIRED by MOCA to handle clicked notifications -->\n\t\t<receiver android:name=\"com.innoquant.moca.push.MOCAPushReceiver\"\n \t android:exported=\"true\"\n \t android:permission=\"com.google.android.c2dm.permission.SEND\" >\n\t \t\t<intent-filter>\n \t \t<action android:name=\"com.innoquant.moca.push.ACTION_PUSH_RECEIVE\" />\n \t <action android:name=\"com.innoquant.moca.push.ACTION_PUSH_DISMISSED\" />\n\t\t\t</intent-filter>\n\t\t</receiver>\n \n\n <!-- REQUIRED by MOCA to handle push notifications -->\n <receiver android:name=\"com.innoquant.moca.push.GcmPushReceiver\"\n android: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 <category android:name=\"YOUR-APP-PACKAGE-NAME\" />\n </intent-filter>\n </receiver>\n \n\t\t<!-- MOCA GcmTokenListener listens to token registrations/updates -->\n <service android:name=\"com.innoquant.moca.push.GcmTokenListener\"\n \t\t\t\t\tandroid:exported=\"false\">\n\t\t\t<intent-filter>\n\t\t\t\t<action android:name=\"com.google.android.gms.iid.InstanceID\"/>\n\t\t\t</intent-filter>\n\t\t</service>\n \n</application>", "language": "xml", "name": "AndroidManifest.xml" } ] } [/block] [block:api-header] { "type": "basic", "title": "Setting app permissions" } [/block] MOCA SDK archive (*.aar) file comes with proper AndroidManifest.xml file that gets merged with your app's Manifest. Internally, the SDK uses the following permissions: [block:callout] { "type": "info", "body": "There is no need to include these permissions in your AndroidManifest.xml", "title": "Please note" } [/block] [block:code] { "codes": [ { "code": "<!-- Required for MOCA SDK -->\n<uses-permission android:name=\"android.permission.INTERNET\" />\n<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" /> <!– Required for BLE and Beacons -->\n<uses-permission android:name=\"android.permission.BLUETOOTH\" /> \n<!– Required to monitor reachability --> \n<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\" /> \n<!-- Keeps the processor from sleeping when a message is received. --> <uses-permission android:name=\"android.permission.WAKE_LOCK\" />\n<!-- Required for Push --> \n<uses-permission android:name=\"android.permission.VIBRATE\" /> \n<!-- Used to collect location data -->\n<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" /> <!-- Used to collect battery stats -->\n<uses-permission android:name=\"android.permission.BATTERY_STATS\" /> <!-- Used to collect carrier -->\n<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/> \n<!–- Push notifications -->\n<uses-permission android:name=\"com.google.android.c2dm.permission.RECEIVE\"/>\n\n\n", "language": "xml" } ] } [/block] [block:api-header] { "type": "basic", "title": "Android Marshmallow (6.0) permissions" } [/block] Request the `ACCESS_FINE_LOCATION` permission at Run Time, an example of how to do it is [available here.](doc:android-60-permissions). [block:api-header] { "type": "basic", "title": "MOCA SDK included Services & Receivers" } [/block] MOCA SDK archive (*.aar) file comes with proper AndroidManifest.xml file that gets merged with your app manifest. Internally, the SDK uses the following services & receivers: [block:code] { "codes": [ { "code": "<!– In App AndroidManifest.xml -->\n<meta-data android:name=\"moca.CUSTOM_PUSH_ICON\" android:resource=\"@drawable/YOUR_PUSH_ICON\" />\n\n<!-- REQUIRED by MOCA to handle push notifications -->\n<receiver android:name=\"com.innoquant.moca.push.MOCAPushReceiver\">\n\t<intent-filter>\n\t <action android:name=\"com.innoquant.moca.push.ACTION_PUSH_RECEIVE\" />\n <category android:name=\"YOUR_APP_PACKAGE\" />\n </intent-filter>\n</receiver> \n", "language": "java" } ] } [/block] ####Remote Push Notifications If your plan includes Remote Push Notifications, please ensure the SDK is properly configured. Check the [Push Notifications](/docs/push-notifications) doc. [block:api-header] { "type": "basic", "title": "Initializing MOCA in the Application class" } [/block] Finally, to start using SDK, you’ll need to initialize MOCA library. 1 - If you don't have one, create a new class that inherits from Application. You will need to declare the name of this class in the `AndroidManifest.xml` file. As you can see in the AndroidManifest.xml section above. 2 - Import `com.innoquant.moca.*` package into your main **Application** class. 3 - Initialize MOCA SDK in the `onCreate` method of this class. [block:callout] { "type": "danger", "title": "Do not initialize MOCA within an Activity", "body": "By doing so, MOCA won't be able to manage proximity events when the `Activity` is not running (App not in foreground, for instance)." } [/block] [block:code] { "codes": [ { "code": "import com.innoquant.moca.MOCA;\nimport com.innoquant.moca.MOCAInstance;\n\npublic class MocaApplication extends Application {\n\n @Override\n public void onCreate() {\n super.onCreate();\n\n // Init MOCA library\n MOCA.initializeSDK (this);\n }\n}\n", "language": "java" } ] } [/block] 4 - You must initialize the SDK before calling any other method. 5 - On initialization, MOCA SDK will load configuration from the `AndroidManifest.xml` file or the `MOCA.properties` file and perform all necessary library setup.
[block:api-header] { "type": "basic", "title": "Gradle" } [/block] Configure the library and its dependencies through `Gradle` [block:callout] { "type": "warning", "title": "Gradle path", "body": "Make sure changes are made to the build.gradle file of your `Module:app`, not of your `Project:project name`.\n\nDon't forget to add the `repositories` configuration in your `build.gradle`, as shown below." } [/block] [block:code] { "codes": [ { "code": "repositories {\n \tflatDir {\n dirs 'libs'\n }\n}\n\nandroid {\n ...\n ...\n ...\n \n dependencies {\n //AppCompat\n compile 'com.android.support:support-v4:23.4.0'\n compile 'com.android.support:appcompat-v7:23.4.0'\n\n //MOCA SDK\n compile(name: 'moca-sdk-android-1.9.+', ext: 'aar')\n\n compile 'org.msgpack:msgpack:0.6.11'\n\n //Google Cloud Messaging\n compile 'com.google.android.gms:play-services-gcm:8.3.0'\n\n //Google Location, Activity Recognition, and Places\n compile 'com.google.android.gms:play-services-location:8.3.0'\n\n //Google Mobile Ads (Optional)\n compile 'com.google.android.gms:play-services-ads:8.3.0'\t\n }\n}", "language": "groovy", "name": "build.gradle" } ] } [/block] [block:api-header] { "type": "basic", "title": "Installing Google Play Services." } [/block] MOCA SDK requires Google Play Services 8.3.0+ as you've seen in the dependencies list above. If your project is not using Google Play Services, please ensure the libraries are installed in your Android Studio before continuing. You can see how to install Google Play Services by visiting this [Google guide](https://developer.android.com/studio/intro/update.html). [block:api-header] { "type": "basic", "title": "Grab your AppKey and AppSecret" } [/block] 1 - Go to https://console.mocaplatform.com and sign into your MOCA account. 2 - Select Apps item at left sidebar, and then click + New App in the content panel. Fill in the form and complete the app creation. 3 - Open the newly created app and navigate to Settings item. Select API keys tab. 4 - Get `App Key` and `App Secret`. [block:image] { "images": [ { "image": [ "https://files.readme.io/jvi2iXdScWdM4W428eiX_consolekeys.png", "consolekeys.png", "704", "458", "#b02428", "" ] } ] } [/block] You can configure the MOCA SDK from the `AndroidManifest.xml` file, or alternatively from a `MOCA.properties` file [block:api-header] { "type": "basic", "title": "Option A: Configuration through MOCA.properties file" } [/block] Starting from MOCA Android SDK 1.9.0, you can configure the SDK using a `MOCA.properties` file. 1 - Create an `assets` folder, just inside your App's main folder. [block:image] { "images": [ { "image": [ "https://files.readme.io/1k7sOod6QFGfMreUtwCl_assets-folder.png", "assets-folder.png", "700", "598", "#5a8fce", "" ] } ] } [/block] You should be able to see a new folder in your project. [block:image] { "images": [ { "image": [ "https://files.readme.io/9IgnTA5oSDqOMtqk5Xw0_assets.png", "assets.png", "272", "272", "#4d87d1", "" ] } ] } [/block] 2 - Create a file called `MOCA.properties` by right clicking the `assets` folder and selecting New > File. 3 - Configure the SDK with the necessary keys. Please bear in mind that ***the only mandatory keys are AppKey, and AppSecret***. The ***gcmSender*** is mandatory only if you want to use MOCA Remote Push Notifications service. [block:callout] { "type": "info", "title": "Get your GCM Sender from Google", "body": "Check [this guide](./gcm-fcm-cloud-messaging-setup) in order to get your Cloud Messaging Sender Id." } [/block] [block:callout] { "type": "warning", "title": "", "body": "Don't forget to paste the AppKey and AppSecret with the ones corresponding to your App. Otherwise the SDK won't be able to connect to MOCA Cloud." } [/block] Contents of the `MOCA.properties` file: [block:code] { "codes": [ { "code": "#MOCA App key and app secret. You can get this keys from the MOCA Console.\nappKey = YOUR-MOCA-APP-KEY\nappSecret = YOUR-MOCA-APP-SECRET\n\n#MOCA SDK Log level. Possible values [Off, Error, Warning, Info, Debug, Verbose]\nlogLevel = Debug\n\n# MOCA Remote Push Notifications\n# disable it if you have your own/ other remote push implementation\nremotePushNotificationsService = true\n\n# MOCA Proximity Service includes beacon and geofence detection\nproximityService = true\n\n# MOCA GeoTracking Service generates geo points periodically for analytics\ngeoTrackingService = true\n\n# MOCA Event Tracking Service. If enabled, activates event tracking (Sessions, custom events etc.)\neventTrackingService = true\n\n# MOCA driver. This is required for Bluetooth Beacon detection. Set it to false if a custom\n# beacon driver is being used\nmocaDriver = true\n\n# Background location. Allows geoTracking in background\nbackgroundLocation = true\n\n# GCM Sender ID. Only needed if you are using MOCA Remote Push Notifications.\ngcmSender = YOUR-GCM-SENDER-ID\n\n# Beacon detection engine profile [LowLatency, Balanced, BatterySaver, Custom]\n# LowLatency = Notifications will be delivered almost instantly in foreground and background.\n# but will have an important impact on the user's device battery.\n# Balanced = Notifications are delivered almost instantly in foreground. In background it can\n# take up to one minute. In Android Lollipop, Marshmallow, and N there are operating system\n# optimizations that reduce the notification delay (Default setting).\n# BatterySaver = Detections in foreground can take up to one minute, and in background up to\n#5 minutes. this is the recommended setting for analytics-only usages.\n# \nbeaconProfile = Balanced\n\n# If beaconProfile is \"Custom\", the following parameters are mandatory\n# foregroundTimeBetweenScans: Time between each scan in milliseconds, close scans means faster response, but\n# more battery consumption.\n# foregroundScanDuration: Time while device will be listening bluetooth signals in milliseconds.\n# We recommend at least 1100 ms, so if your beacon broadcasts a signal each 350 Hz,~3 packets\n# will be received.\n# backgroundTimeBetweenScans: Same than foregroundTimeBetweenScans, but when device is in the background.\n# this is the most important setting in terms of battery consumption.\n# backgroundScanDuration: Same than foregroundScanDuration but in background.\n\n# Uncomment these parameters in case you want to use a Custom profile\n\n# foregroundTimeBetweenScans = 3300\n# foregroundScanDuration = 3300\n# backgroundTimeBetweenScans = 60000\n# backgroundScanDuration = 5001\n\n# MOCA Beacon detection settings (approximate distance in meters)\n# distance detection is strongly dependent on hardware, and device calibration.\n# Parameter indicates the threshold for the next zone, starting in 0\n# Default config: 0-1m: immediate, 1m-5m: immediate, >5m far\n# Uncomment the following lines if you want to override this settings.\n\n# proximityImmediate= 1\n# proximityNear = 5\n\n#Other settings\n\n#Cache in MB\ncacheSize = 100\n\n#Data fetch interval in milliseconds. Defaults to 1 hour\ndataFetchInterval = 3600000\n\n#Event upload interval. Defaults to 15 minutes.\neventUploadInterval = 900000\n\n# Custom settings\n# Save custom settings by adding \"custom.\" prefix\n# example custom.myCustomSetting = 1000\ncustom.myCustomSetting = 1000\n# Legacy notation\nmoca.CUSTOM_PUSH_ICON = @drawable/ic_moca_logo\n# moca.CUSTOM_NAOMICRO_APP_KEY = xxxxxx\n# moca.CUSTOM_NAOMICRO_ENABLED = false\n", "language": "ruby", "name": "MOCA.properties" } ] } [/block] [block:api-header] { "type": "basic", "title": "Option B: Configuration through `AndroidManifest.xml` file" } [/block] - SDK Settings: you don't need to use this keys if you have used a `MOCA.properties` file. [block:callout] { "type": "warning", "body": "Remember to paste the `moca.APP_KEY` and `moca.APP_SECRET` with the ones of your App. Otherwise the SDK won't be able to connect to MOCA Cloud." } [/block] [block:code] { "codes": [ { "code": "<application\n ...>\n <!-- MOCA SDK configuration -->\n <meta-data android:name=\"moca.APP_KEY\"\n android:value=\"YOUR-MOCA-APP-KEY\"/>\n <meta-data android:name=\"moca.APP_SECRET\"\n android:value=\"YOUR-MOCA-APP-SECRET\"/>\n <meta-data android:name=\"moca.LOG_LEVEL\"\n android:value=\"debug\"/>\n <meta-data android:name=\"moca.AUTOMATIC_PUSH_SETUP_ENABLED\"\n android:value=\"true\"/>\n <meta-data android:name=\"moca.PROXIMITY_SERVICE_ENABLED\"\n android:value=\"true\" />\n <meta-data android:name=\"moca.GEOLOCATION_SERVICE_ENABLED\"\n android:value=\"true\" />\n <meta-data android:name=\"moca.BACKGROUND_LOCATION_ENABLED\"\n android:value=\"true\" />\n <meta-data android:name=\"moca.DATA_FETCH_INTERVAL_MS\"\n android:value=\"auto\" />\n <meta-data android:name=\"moca.EVENT_UPLOAD_INTERVAL_MS\"\n android:value=\"auto\" />\n \t<meta-data android:name=\"moca.MOCA_DRIVER_ENABLED\"\n android:value=\"true\" />\n <!--Optional: Include it for remote push notifications-->\n <!--Be careful with the space before the number-->\n <meta-data android:name=\"moca.GCM_SENDER\"\n android:value=\"\\ YOUR_GCM_SENDER_ID\" />\n</application>", "language": "xml" } ] } [/block] - Be sure to replace `moca.APP_KEY` and `moca.APP_SECRET` values with the real values for your app which you found in the MOCA console. Change any setting that you need for your app: - `moca.PROXIMITY_SERVICE_ENABLED`, will enable or disable Bluetooth Beacon detection & geofence detection. - `moca.GEOLOCATION_SERVICE_ENABLED` – enables/disabled tracking of significant changes in user location by GPS/Cellular Trilateration/Wifi. - YES – user location will be tracked when the app is in foreground. Additionally, background tracking is controlled by BACKGROUND_LOCATION_ENABLED flag. This is the default. - NO – user location will not be tracked at all (either foreground nor background). Bluetooth beacons and geofences will still be detected if this flag is set to NO. - `moca.BACKGROUND_LOCATION_ENABLED` – enables/disables location tracking when the app is in background or suspended mode. - This flag has no effect if GEOLOCATION_SERVICE_ENABLED is set to NO. - By default background location tracking is enabled. [block:api-header] { "type": "basic", "title": "Services & Receivers" } [/block] - Please declare these services and receivers no matter what option did you use in the previous steps. [block:callout] { "type": "danger", "body": "You will need to override the **Application** class to initialize MOCA, so don't forget to add the tag **android:name=\"*pathToYourApplicationClass*\"** to **application**.\n[Learn more about the Application class.](#initializing-moca-in-the-application-class)", "title": "Please Note" } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/F3KObXES3CnfPRbMGWbE_android-name-red.gif", "android-name-red.gif", "630", "243", "#0f344c", "" ] } ] } [/block] [block:code] { "codes": [ { "code": "<application \n ... \n android:name=\"com.myCompany.MyApplication\">\n\n <!-- User Google Play Services -->\n <meta-data android:name=\"com.google.android.gms.version\"\n android:value=\"@integer/google_play_services_version\" />\n \n\t\t<!-- REQUIRED by MOCA to handle clicked notifications -->\n\t\t<receiver android:name=\"com.innoquant.moca.push.MOCAPushReceiver\"\n \t android:exported=\"true\"\n \t android:permission=\"com.google.android.c2dm.permission.SEND\" >\n\t \t\t<intent-filter>\n \t \t<action android:name=\"com.innoquant.moca.push.ACTION_PUSH_RECEIVE\" />\n \t <action android:name=\"com.innoquant.moca.push.ACTION_PUSH_DISMISSED\" />\n\t\t\t</intent-filter>\n\t\t</receiver>\n \n\n <!-- REQUIRED by MOCA to handle push notifications -->\n <receiver android:name=\"com.innoquant.moca.push.GcmPushReceiver\"\n android: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 <category android:name=\"YOUR-APP-PACKAGE-NAME\" />\n </intent-filter>\n </receiver>\n \n\t\t<!-- MOCA GcmTokenListener listens to token registrations/updates -->\n <service android:name=\"com.innoquant.moca.push.GcmTokenListener\"\n \t\t\t\t\tandroid:exported=\"false\">\n\t\t\t<intent-filter>\n\t\t\t\t<action android:name=\"com.google.android.gms.iid.InstanceID\"/>\n\t\t\t</intent-filter>\n\t\t</service>\n \n</application>", "language": "xml", "name": "AndroidManifest.xml" } ] } [/block] [block:api-header] { "type": "basic", "title": "Setting app permissions" } [/block] MOCA SDK archive (*.aar) file comes with proper AndroidManifest.xml file that gets merged with your app's Manifest. Internally, the SDK uses the following permissions: [block:callout] { "type": "info", "body": "There is no need to include these permissions in your AndroidManifest.xml", "title": "Please note" } [/block] [block:code] { "codes": [ { "code": "<!-- Required for MOCA SDK -->\n<uses-permission android:name=\"android.permission.INTERNET\" />\n<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" /> <!– Required for BLE and Beacons -->\n<uses-permission android:name=\"android.permission.BLUETOOTH\" /> \n<!– Required to monitor reachability --> \n<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\" /> \n<!-- Keeps the processor from sleeping when a message is received. --> <uses-permission android:name=\"android.permission.WAKE_LOCK\" />\n<!-- Required for Push --> \n<uses-permission android:name=\"android.permission.VIBRATE\" /> \n<!-- Used to collect location data -->\n<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" /> <!-- Used to collect battery stats -->\n<uses-permission android:name=\"android.permission.BATTERY_STATS\" /> <!-- Used to collect carrier -->\n<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/> \n<!–- Push notifications -->\n<uses-permission android:name=\"com.google.android.c2dm.permission.RECEIVE\"/>\n\n\n", "language": "xml" } ] } [/block] [block:api-header] { "type": "basic", "title": "Android Marshmallow (6.0) permissions" } [/block] Request the `ACCESS_FINE_LOCATION` permission at Run Time, an example of how to do it is [available here.](doc:android-60-permissions). [block:api-header] { "type": "basic", "title": "MOCA SDK included Services & Receivers" } [/block] MOCA SDK archive (*.aar) file comes with proper AndroidManifest.xml file that gets merged with your app manifest. Internally, the SDK uses the following services & receivers: [block:code] { "codes": [ { "code": "<!– In App AndroidManifest.xml -->\n<meta-data android:name=\"moca.CUSTOM_PUSH_ICON\" android:resource=\"@drawable/YOUR_PUSH_ICON\" />\n\n<!-- REQUIRED by MOCA to handle push notifications -->\n<receiver android:name=\"com.innoquant.moca.push.MOCAPushReceiver\">\n\t<intent-filter>\n\t <action android:name=\"com.innoquant.moca.push.ACTION_PUSH_RECEIVE\" />\n <category android:name=\"YOUR_APP_PACKAGE\" />\n </intent-filter>\n</receiver> \n", "language": "java" } ] } [/block] ####Remote Push Notifications If your plan includes Remote Push Notifications, please ensure the SDK is properly configured. Check the [Push Notifications](/docs/push-notifications) doc. [block:api-header] { "type": "basic", "title": "Initializing MOCA in the Application class" } [/block] Finally, to start using SDK, you’ll need to initialize MOCA library. 1 - If you don't have one, create a new class that inherits from Application. You will need to declare the name of this class in the `AndroidManifest.xml` file. As you can see in the AndroidManifest.xml section above. 2 - Import `com.innoquant.moca.*` package into your main **Application** class. 3 - Initialize MOCA SDK in the `onCreate` method of this class. [block:callout] { "type": "danger", "title": "Do not initialize MOCA within an Activity", "body": "By doing so, MOCA won't be able to manage proximity events when the `Activity` is not running (App not in foreground, for instance)." } [/block] [block:code] { "codes": [ { "code": "import com.innoquant.moca.MOCA;\nimport com.innoquant.moca.MOCAInstance;\n\npublic class MocaApplication extends Application {\n\n @Override\n public void onCreate() {\n super.onCreate();\n\n // Init MOCA library\n MOCA.initializeSDK (this);\n }\n}\n", "language": "java" } ] } [/block] 4 - You must initialize the SDK before calling any other method. 5 - On initialization, MOCA SDK will load configuration from the `AndroidManifest.xml` file or the `MOCA.properties` file and perform all necessary library setup.
{"_id":"55a93c4002becf2d007aac43","excerpt":"","link_external":false,"user":"559a618bdbcfd20d00710b38","__v":16,"api":{"auth":"required","params":[],"results":{"codes":[{"name":"","status":200,"language":"json","code":"{}"},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"hidden":false,"order":3,"parentDoc":null,"type":"basic","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]","createdAt":"2015-07-17T17:32:48.053Z","isReference":false,"next":{"description":"","pages":[]},"project":"559a61d2dbcfd20d00710b39","version":"559a61d2dbcfd20d00710b3c","category":"55a589e30f354f0d00fd0312","githubsync":"","link_url":"","slug":"push-notifications","sync_unique":"","title":"Push Notifications","updates":[],"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

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]
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]
{"_id":"56d5d72da0b5600b000b1f7b","hidden":false,"link_url":"","type":"basic","link_external":false,"order":4,"__v":0,"category":"55a589e30f354f0d00fd0312","slug":"proguard-rules","sync_unique":"","title":"ProGuard rules","user":"559a618bdbcfd20d00710b38","version":"559a61d2dbcfd20d00710b3c","body":"If you use ProGuard, please include the following rules:\n\n```\n-keep class com.innoquant.** { *; }\n-keep class org.msgpack.** { *; }\n-keep class javassist.util.** { *; }\n-keep class javassist.tools.** { *; }\n-dontwarn org.msgpack.**\n-dontwarn javassist.util.**\n-dontwarn javassist.tools.**\n```","parentDoc":null,"project":"559a61d2dbcfd20d00710b39","githubsync":"","isReference":false,"updates":[],"api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","auth":"required","params":[],"url":""},"createdAt":"2016-03-01T17:53:49.824Z","excerpt":"","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

ProGuard rules


If you use ProGuard, please include the following rules: ``` -keep class com.innoquant.** { *; } -keep class org.msgpack.** { *; } -keep class javassist.util.** { *; } -keep class javassist.tools.** { *; } -dontwarn org.msgpack.** -dontwarn javassist.util.** -dontwarn javassist.tools.** ```
If you use ProGuard, please include the following rules: ``` -keep class com.innoquant.** { *; } -keep class org.msgpack.** { *; } -keep class javassist.util.** { *; } -keep class javassist.tools.** { *; } -dontwarn org.msgpack.** -dontwarn javassist.util.** -dontwarn javassist.tools.** ```
{"_id":"573d83d9cf7be63200c5b174","parentDoc":null,"project":"559a61d2dbcfd20d00710b39","slug":"android-60-permissions","title":"Android 6.0+ permissions","user":"559a618bdbcfd20d00710b38","category":"55a589e30f354f0d00fd0312","hidden":false,"type":"basic","order":5,"version":"559a61d2dbcfd20d00710b3c","__v":9,"api":{"auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"language":"json","code":"{}","name":"","status":400}]},"settings":"","url":""},"createdAt":"2016-05-19T09:14:01.099Z","excerpt":"","isReference":false,"sync_unique":"","updates":[],"body":"Starting from **Android 6.0**, there are some permissions that are considered *dangerous*. All the permissions that fall into this category **are no longer requested at install time, but at Run Time.**\n\n##Android Lollipop and lower\n\n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/utGBMUxUSWabJudw5kv6_lollipop-permissions.jpg\",\n        \"lollipop-permissions.jpg\",\n        \"630\",\n        \"1120\",\n        \"#6d944b\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n##Android Marshmallow and greater\n\n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/RZuk8nGtQj6YGS9uik0c_marshmallow-permissions.jpg\",\n        \"marshmallow-permissions.jpg\",\n        \"630\",\n        \"1120\",\n        \"#4aa096\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Requesting permissions at runtime.\"\n}\n[/block]\nMOCA SDK requires the `ACCESS_FINE_LOCATION` permission for **bluetooth** scanning, **location tracking** and **geofencing**. Request this permission in your Main Activity this way:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"final int REQUEST_PERMISSION_GEO = 101;        \\nfinal String permissionStr = android.Manifest.permission.ACCESS_FINE_LOCATION;\\n\\n\\[email protected](Build.VERSION_CODES.M)\\nprivate void requestMocaPermissions() {\\n  final int permStatus = ContextCompat.checkSelfPermission(this, FINE_LOCATION_PERMISSION);\\n  if (permStatus != PackageManager.PERMISSION_GRANTED) {\\n    if (shouldShowRequestPermissionRationale(FINE_LOCATION_PERMISSION)) {\\n\\n      AlertDialog.Builder builder = new AlertDialog.Builder(this);\\n\\n      builder.setMessage(R.string.LOCATION_PERMISSION_DESCRIPTION)\\n        .setTitle(R.string.APP_SHORT_NAME)\\n        .setNeutralButton(R.string.OK_TEXT, new DialogInterface.OnClickListener() {\\n\\n          public void onClick(DialogInterface dialog, int which) {\\n            requestPermissions(new String[]{FINE_LOCATION_PERMISSION},\\n                               REQUEST_PERMISSION_GEO);\\n          }\\n\\n        }).show();\\n\\n    } else {\\n      // No explanation needed, we can request the permission.\\n      requestPermissions(new String[]{FINE_LOCATION_PERMISSION},\\n                         REQUEST_PERMISSION_GEO);\\n    }\\n  }\\n}\",\n      \"language\": \"java\",\n      \"name\": \"Permission Request example\"\n    }\n  ]\n}\n[/block]\nOnce the user allows or denies the permission, Android will send you this information using the `onRequestPermissionsResult` callback. Below you will find an example of how to implement this method, and how to initialize the permission-affected MOCA Services:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"/**\\n     * Callback received when a permissions request has been completed.\\n     */\\n    @Override\\n    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,\\n                                           @NonNull int[] grantResults) {\\n\\n        if((requestCode == REQUEST_PERMISSION_GEO)\\n                && (permissions[0].equals(FINE_LOCATION_PERMISSION))\\n                && (grantResults[0] == PackageManager.PERMISSION_GRANTED)){\\n            if(MOCA.initialized()){\\n                MOCA.setProximityEnabled(true);\\n                MOCA.setGeoTrackingEnabled(true);\\n            }\\n        }\\n        else{\\n            Log.e(\\\"MOCA\\\", \\\"Location permission denied by the user.\\\");\\n        }\\n    }\",\n      \"language\": \"java\",\n      \"name\": \"Permission request callback\"\n    }\n  ]\n}\n[/block]\nLearn more about [requesting permissions at Run Time.](https://developer.android.com/training/permissions/requesting.html) (external link).","githubsync":"","link_external":false,"link_url":"","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Android 6.0+ permissions


Starting from **Android 6.0**, there are some permissions that are considered *dangerous*. All the permissions that fall into this category **are no longer requested at install time, but at Run Time.** ##Android Lollipop and lower [block:image] { "images": [ { "image": [ "https://files.readme.io/utGBMUxUSWabJudw5kv6_lollipop-permissions.jpg", "lollipop-permissions.jpg", "630", "1120", "#6d944b", "" ] } ] } [/block] ##Android Marshmallow and greater [block:image] { "images": [ { "image": [ "https://files.readme.io/RZuk8nGtQj6YGS9uik0c_marshmallow-permissions.jpg", "marshmallow-permissions.jpg", "630", "1120", "#4aa096", "" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "Requesting permissions at runtime." } [/block] MOCA SDK requires the `ACCESS_FINE_LOCATION` permission for **bluetooth** scanning, **location tracking** and **geofencing**. Request this permission in your Main Activity this way: [block:code] { "codes": [ { "code": "final int REQUEST_PERMISSION_GEO = 101; \nfinal String permissionStr = android.Manifest.permission.ACCESS_FINE_LOCATION;\n\n\[email protected](Build.VERSION_CODES.M)\nprivate void requestMocaPermissions() {\n final int permStatus = ContextCompat.checkSelfPermission(this, FINE_LOCATION_PERMISSION);\n if (permStatus != PackageManager.PERMISSION_GRANTED) {\n if (shouldShowRequestPermissionRationale(FINE_LOCATION_PERMISSION)) {\n\n AlertDialog.Builder builder = new AlertDialog.Builder(this);\n\n builder.setMessage(R.string.LOCATION_PERMISSION_DESCRIPTION)\n .setTitle(R.string.APP_SHORT_NAME)\n .setNeutralButton(R.string.OK_TEXT, new DialogInterface.OnClickListener() {\n\n public void onClick(DialogInterface dialog, int which) {\n requestPermissions(new String[]{FINE_LOCATION_PERMISSION},\n REQUEST_PERMISSION_GEO);\n }\n\n }).show();\n\n } else {\n // No explanation needed, we can request the permission.\n requestPermissions(new String[]{FINE_LOCATION_PERMISSION},\n REQUEST_PERMISSION_GEO);\n }\n }\n}", "language": "java", "name": "Permission Request example" } ] } [/block] Once the user allows or denies the permission, Android will send you this information using the `onRequestPermissionsResult` callback. Below you will find an example of how to implement this method, and how to initialize the permission-affected MOCA Services: [block:code] { "codes": [ { "code": "/**\n * Callback received when a permissions request has been completed.\n */\n @Override\n public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,\n @NonNull int[] grantResults) {\n\n if((requestCode == REQUEST_PERMISSION_GEO)\n && (permissions[0].equals(FINE_LOCATION_PERMISSION))\n && (grantResults[0] == PackageManager.PERMISSION_GRANTED)){\n if(MOCA.initialized()){\n MOCA.setProximityEnabled(true);\n MOCA.setGeoTrackingEnabled(true);\n }\n }\n else{\n Log.e(\"MOCA\", \"Location permission denied by the user.\");\n }\n }", "language": "java", "name": "Permission request callback" } ] } [/block] Learn more about [requesting permissions at Run Time.](https://developer.android.com/training/permissions/requesting.html) (external link).
Starting from **Android 6.0**, there are some permissions that are considered *dangerous*. All the permissions that fall into this category **are no longer requested at install time, but at Run Time.** ##Android Lollipop and lower [block:image] { "images": [ { "image": [ "https://files.readme.io/utGBMUxUSWabJudw5kv6_lollipop-permissions.jpg", "lollipop-permissions.jpg", "630", "1120", "#6d944b", "" ] } ] } [/block] ##Android Marshmallow and greater [block:image] { "images": [ { "image": [ "https://files.readme.io/RZuk8nGtQj6YGS9uik0c_marshmallow-permissions.jpg", "marshmallow-permissions.jpg", "630", "1120", "#4aa096", "" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "Requesting permissions at runtime." } [/block] MOCA SDK requires the `ACCESS_FINE_LOCATION` permission for **bluetooth** scanning, **location tracking** and **geofencing**. Request this permission in your Main Activity this way: [block:code] { "codes": [ { "code": "final int REQUEST_PERMISSION_GEO = 101; \nfinal String permissionStr = android.Manifest.permission.ACCESS_FINE_LOCATION;\n\n\[email protected](Build.VERSION_CODES.M)\nprivate void requestMocaPermissions() {\n final int permStatus = ContextCompat.checkSelfPermission(this, FINE_LOCATION_PERMISSION);\n if (permStatus != PackageManager.PERMISSION_GRANTED) {\n if (shouldShowRequestPermissionRationale(FINE_LOCATION_PERMISSION)) {\n\n AlertDialog.Builder builder = new AlertDialog.Builder(this);\n\n builder.setMessage(R.string.LOCATION_PERMISSION_DESCRIPTION)\n .setTitle(R.string.APP_SHORT_NAME)\n .setNeutralButton(R.string.OK_TEXT, new DialogInterface.OnClickListener() {\n\n public void onClick(DialogInterface dialog, int which) {\n requestPermissions(new String[]{FINE_LOCATION_PERMISSION},\n REQUEST_PERMISSION_GEO);\n }\n\n }).show();\n\n } else {\n // No explanation needed, we can request the permission.\n requestPermissions(new String[]{FINE_LOCATION_PERMISSION},\n REQUEST_PERMISSION_GEO);\n }\n }\n}", "language": "java", "name": "Permission Request example" } ] } [/block] Once the user allows or denies the permission, Android will send you this information using the `onRequestPermissionsResult` callback. Below you will find an example of how to implement this method, and how to initialize the permission-affected MOCA Services: [block:code] { "codes": [ { "code": "/**\n * Callback received when a permissions request has been completed.\n */\n @Override\n public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,\n @NonNull int[] grantResults) {\n\n if((requestCode == REQUEST_PERMISSION_GEO)\n && (permissions[0].equals(FINE_LOCATION_PERMISSION))\n && (grantResults[0] == PackageManager.PERMISSION_GRANTED)){\n if(MOCA.initialized()){\n MOCA.setProximityEnabled(true);\n MOCA.setGeoTrackingEnabled(true);\n }\n }\n else{\n Log.e(\"MOCA\", \"Location permission denied by the user.\");\n }\n }", "language": "java", "name": "Permission request callback" } ] } [/block] Learn more about [requesting permissions at Run Time.](https://developer.android.com/training/permissions/requesting.html) (external link).
{"_id":"57d82165b5d28c2900fb558d","category":"55a589e30f354f0d00fd0312","excerpt":"","hidden":false,"slug":"gcm-fcm-cloud-messaging-setup","__v":0,"link_external":false,"order":7,"title":"GCM / FCM: Cloud Messaging Setup.","updates":[],"user":"559a618bdbcfd20d00710b38","version":"559a61d2dbcfd20d00710b3c","link_url":"","project":"559a61d2dbcfd20d00710b39","type":"basic","api":{"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","auth":"required","params":[],"url":""},"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Firebase Messaging\",\n  \"body\": \"Google has integrated Google Cloud Messaging (GCM) into Firebase. API Keys generated through Google API Console are no longer valid.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Enabling Cloud Messaging and generating Server API Key\"\n}\n[/block]\n1 - Sign in into [Google Firebase](https://console.firebase.google.com/)\n2 - Select `CREATE A NEW PROJECT`. \n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"You can also import an existing GCM project using the option below the button.\"\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/e2361bc-Firebase-1.png\",\n        \"Firebase-1.png\",\n        717,\n        509,\n        \"#167cbd\"\n      ]\n    }\n  ]\n}\n[/block]\n3 - Type a name for your new project and select your country.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ceac511-country-name.png\",\n        \"country-name.png\",\n        688,\n        502,\n        \"#8a8a8a\"\n      ]\n    }\n  ]\n}\n[/block]\n4 - After the project has been created, click on the gear icon and select \"Project settings\"\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/f06c749-project_settings.png\",\n        \"project settings.png\",\n        715,\n        485,\n        \"#0e91cd\"\n      ]\n    }\n  ]\n}\n[/block]\n5 - Select `CLOUD MESSAGING`. Here you will see two keys:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/d484dbe-keys.png\",\n        \"keys.png\",\n        674,\n        397,\n        \"#0593dc\"\n      ]\n    }\n  ]\n}\n[/block]\n- The **Server Key** is needed to configure the service in the MOCA Console.\n- The **Sender ID** should be used for the [Android SDK configuration](./moca-android-sdk-configuration). (also known as GCM Sender Id).\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Using the Key in the MOCA Console.\"\n}\n[/block]\n1 - [Log in to your MOCA Account](https://console.mocaplatform.com/) and go to Apps **>** *app_to_be_configured* ** >** Settings **>** Services\n2 - Select `Add` in Google Cloud Messaging (GCM) and paste your server API Key there \n\n![](https://files.readme.io/da9ff5b-APi-server-key-moca.png)\n\n- All done. You can now start sending notifications to your users using MOCA Platform to your Android users.","createdAt":"2016-09-13T15:55:17.844Z","githubsync":"","isReference":false,"parentDoc":null,"sync_unique":"","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

GCM / FCM: Cloud Messaging Setup.


[block:callout] { "type": "info", "title": "Firebase Messaging", "body": "Google has integrated Google Cloud Messaging (GCM) into Firebase. API Keys generated through Google API Console are no longer valid." } [/block] [block:api-header] { "type": "basic", "title": "Enabling Cloud Messaging and generating Server API Key" } [/block] 1 - Sign in into [Google Firebase](https://console.firebase.google.com/) 2 - Select `CREATE A NEW PROJECT`. [block:callout] { "type": "warning", "body": "You can also import an existing GCM project using the option below the button." } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/e2361bc-Firebase-1.png", "Firebase-1.png", 717, 509, "#167cbd" ] } ] } [/block] 3 - Type a name for your new project and select your country. [block:image] { "images": [ { "image": [ "https://files.readme.io/ceac511-country-name.png", "country-name.png", 688, 502, "#8a8a8a" ] } ] } [/block] 4 - After the project has been created, click on the gear icon and select "Project settings" [block:image] { "images": [ { "image": [ "https://files.readme.io/f06c749-project_settings.png", "project settings.png", 715, 485, "#0e91cd" ] } ] } [/block] 5 - Select `CLOUD MESSAGING`. Here you will see two keys: [block:image] { "images": [ { "image": [ "https://files.readme.io/d484dbe-keys.png", "keys.png", 674, 397, "#0593dc" ] } ] } [/block] - The **Server Key** is needed to configure the service in the MOCA Console. - The **Sender ID** should be used for the [Android SDK configuration](./moca-android-sdk-configuration). (also known as GCM Sender Id). [block:api-header] { "type": "basic", "title": "Using the Key in the MOCA Console." } [/block] 1 - [Log in to your MOCA Account](https://console.mocaplatform.com/) and go to Apps **>** *app_to_be_configured* ** >** Settings **>** Services 2 - Select `Add` in Google Cloud Messaging (GCM) and paste your server API Key there ![](https://files.readme.io/da9ff5b-APi-server-key-moca.png) - All done. You can now start sending notifications to your users using MOCA Platform to your Android users.
[block:callout] { "type": "info", "title": "Firebase Messaging", "body": "Google has integrated Google Cloud Messaging (GCM) into Firebase. API Keys generated through Google API Console are no longer valid." } [/block] [block:api-header] { "type": "basic", "title": "Enabling Cloud Messaging and generating Server API Key" } [/block] 1 - Sign in into [Google Firebase](https://console.firebase.google.com/) 2 - Select `CREATE A NEW PROJECT`. [block:callout] { "type": "warning", "body": "You can also import an existing GCM project using the option below the button." } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/e2361bc-Firebase-1.png", "Firebase-1.png", 717, 509, "#167cbd" ] } ] } [/block] 3 - Type a name for your new project and select your country. [block:image] { "images": [ { "image": [ "https://files.readme.io/ceac511-country-name.png", "country-name.png", 688, 502, "#8a8a8a" ] } ] } [/block] 4 - After the project has been created, click on the gear icon and select "Project settings" [block:image] { "images": [ { "image": [ "https://files.readme.io/f06c749-project_settings.png", "project settings.png", 715, 485, "#0e91cd" ] } ] } [/block] 5 - Select `CLOUD MESSAGING`. Here you will see two keys: [block:image] { "images": [ { "image": [ "https://files.readme.io/d484dbe-keys.png", "keys.png", 674, 397, "#0593dc" ] } ] } [/block] - The **Server Key** is needed to configure the service in the MOCA Console. - The **Sender ID** should be used for the [Android SDK configuration](./moca-android-sdk-configuration). (also known as GCM Sender Id). [block:api-header] { "type": "basic", "title": "Using the Key in the MOCA Console." } [/block] 1 - [Log in to your MOCA Account](https://console.mocaplatform.com/) and go to Apps **>** *app_to_be_configured* ** >** Settings **>** Services 2 - Select `Add` in Google Cloud Messaging (GCM) and paste your server API Key there ![](https://files.readme.io/da9ff5b-APi-server-key-moca.png) - All done. You can now start sending notifications to your users using MOCA Platform to your Android users.
{"_id":"55a930bdcf45e1390093f353","__v":2,"api":{"settings":"","url":"","auth":"required","params":[],"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{}","name":""}]}},"slug":"moca-api","link_external":false,"sync_unique":"","user":"559a618bdbcfd20d00710b38","category":"55a93098cf45e1390093f351","isReference":false,"hidden":false,"link_url":"","order":0,"parentDoc":null,"project":"559a61d2dbcfd20d00710b39","body":"The `MOCA static class` is a main entry point to MOCA APIs.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\n\\t/**\\n\\t * Returns the current MOCA SDK version.\\n\\t * \\n\\t * @return The version of the MOCA SDK library.\\n\\t */\\n\\tpublic static String getVersion()\\n\\t\\n\\t/**\\n\\t * Return the key of this application in MOCA service.\\n\\t * \\n\\t * @return MOCA app key.\\n\\t */\\n\\tpublic static String getAppKey()\\n\\t\\n\\t/**\\n\\t * Return the secret key of this application in MOCA service.\\n\\t * \\n\\t * @return MOCA app secret.\\n\\t */\\n\\tpublic static String getAppSecret()\\n\\t\\n\\t/**\\n\\t * Gets the level of logging that will be displayed.\\n\\t */\\n\\tpublic static MOCALogLevel getLogLevel()\\n\\n\\t/**\\n\\t * Returns the current Application.\\n\\t * \\n\\t * @return The current application.\\n\\t */\\n\\tpublic static Application getApplication () \\n\\n  /**\\n   * Gets instance object.\\n   */\\n  public static MOCAInstance getInstance ()\\n \\n\\t/**\\n\\t * Provides access to MOCA Proximity Service. This service is only available\\n\\t * on Android 4.4 and newer.\\n\\t * \\n\\t * @return MOCAProximityService instance or null if it is not available or\\n\\t *         has not been initialized.\\n\\t */\\n\\tpublic static MOCAProximityService getProximityService()\\n\\n\\t/**\\n\\t * Returns true if MOCA Proximity Service is available on this device.\\n\\t * \\n\\t * @return true if the proximity service is available on this device.\\n     * Note: it can be disabled by configuration.\\n\\t */\\n\\tpublic static boolean isProximityAvailable()\\n\\n  /**\\n   * Returns true if MOCA Proximity Service is available and enabled.\\n   *\\n   * @return true if the proximity service is enabled, or false otherwise.\\n   */\\n  public static boolean proximityEnabled ()\\n\\n  /**\\n   * Starts/stops MOCA Proximity service.\\n   * @param enable\\n   */\\n  public static void setProximityEnabled (boolean enable) \\n\\n  private static final String\\tMOCA_AUTOINIT_ON_PUSH_KEY\\t= \\\"MOCA_AUTO_INIT_ON_PUSH\\\";\\n\\n  /**\\n   * Global settings. Enables MOCA to auto-initialize SDK on certain events.\\n   */\\n  public static void setAutoInitOnPush (Context context, boolean enable)\\n    \\n  public static boolean getAutoInitOnPush (Context context)\\n\\t\\n  /**\\n\\t * Tracks a custom in-app event.\\n\\t * \\n\\t * @param verb Action verb.\\n\\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\\n\\t *         error.\\n\\t */\\n\\tpublic static boolean track(final String verb)\\n\\t\\n\\t/**\\n\\t * Tracks an event.\\n\\t * \\n\\t * @param verb Action verb.\\n\\t * @param value Value associated with the event.\\n\\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\\n\\t *         error.\\n\\t */\\n\\tpublic static boolean track(final String verb, long value)\\n\\n\\t/**\\n\\t * Tracks an event.\\n\\t * \\n\\t * @param verb Action verb.\\n\\t * @param item Item associated with the event.\\n\\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\\n\\t *         error.\\n\\t */\\n\\tpublic static boolean track(final String verb, final String item)\\n\\n\\t/**\\n\\t * Tracks an event.\\n\\t * \\n\\t * @param verb Action verb.\\n\\t * @param item Item associated with the event.\\n\\t * @param value Value associated with the event.\\n\\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\\n\\t *         error.\\n\\t */\\n\\tpublic static boolean track(final String verb, final String item, final long value)\\n\\n\\t/**\\n\\t * Tracks an event.\\n\\t * \\n\\t * @param verb Action verb.\\n\\t * @param item Item associated with the event.\\n\\t * @param category Category the item belongs to.\\n\\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\\n\\t *         error.\\n\\t */\\n\\tpublic static boolean track(final String verb, final String category, final String item)\\n\\n\\t/**\\n\\t * Tracks an event.\\n\\t * \\n\\t * @param verb Action verb.\\n\\t * @param item Item associated with the event.\\n\\t * @param category Category the item belongs to.\\n\\t * @param value Value associated with the event.\\n\\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\\n\\t *         error.\\n\\t */\\n\\tpublic static boolean track(final String verb, final String category, final String item, final long value)\\n\\n\\t/**\\n\\t * Tracks an event with custom attributes.\\n\\t * \\n\\t * @param verb Action verb.\\n\\t * @param attrs Collection of attributes associated with this event (up to\\n\\t *            10). Value types are restricted to: {@link String},\\n\\t *            {@link Integer}, {@link Long}, {@link Double}, {@link Float},\\n\\t *            {@link Date} and {@link Location}.\\n\\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\\n\\t *         error.\\n\\t */\\n\\tpublic static boolean track(final String verb, final Map<String, Object> attrs)\\n\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","excerpt":"","githubsync":"","updates":[],"version":"559a61d2dbcfd20d00710b3c","createdAt":"2015-07-17T16:43:41.170Z","title":"MOCA API","type":"basic","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

MOCA API


The `MOCA static class` is a main entry point to MOCA APIs. [block:code] { "codes": [ { "code": "\n\t/**\n\t * Returns the current MOCA SDK version.\n\t * \n\t * @return The version of the MOCA SDK library.\n\t */\n\tpublic static String getVersion()\n\t\n\t/**\n\t * Return the key of this application in MOCA service.\n\t * \n\t * @return MOCA app key.\n\t */\n\tpublic static String getAppKey()\n\t\n\t/**\n\t * Return the secret key of this application in MOCA service.\n\t * \n\t * @return MOCA app secret.\n\t */\n\tpublic static String getAppSecret()\n\t\n\t/**\n\t * Gets the level of logging that will be displayed.\n\t */\n\tpublic static MOCALogLevel getLogLevel()\n\n\t/**\n\t * Returns the current Application.\n\t * \n\t * @return The current application.\n\t */\n\tpublic static Application getApplication () \n\n /**\n * Gets instance object.\n */\n public static MOCAInstance getInstance ()\n \n\t/**\n\t * Provides access to MOCA Proximity Service. This service is only available\n\t * on Android 4.4 and newer.\n\t * \n\t * @return MOCAProximityService instance or null if it is not available or\n\t * has not been initialized.\n\t */\n\tpublic static MOCAProximityService getProximityService()\n\n\t/**\n\t * Returns true if MOCA Proximity Service is available on this device.\n\t * \n\t * @return true if the proximity service is available on this device.\n * Note: it can be disabled by configuration.\n\t */\n\tpublic static boolean isProximityAvailable()\n\n /**\n * Returns true if MOCA Proximity Service is available and enabled.\n *\n * @return true if the proximity service is enabled, or false otherwise.\n */\n public static boolean proximityEnabled ()\n\n /**\n * Starts/stops MOCA Proximity service.\n * @param enable\n */\n public static void setProximityEnabled (boolean enable) \n\n private static final String\tMOCA_AUTOINIT_ON_PUSH_KEY\t= \"MOCA_AUTO_INIT_ON_PUSH\";\n\n /**\n * Global settings. Enables MOCA to auto-initialize SDK on certain events.\n */\n public static void setAutoInitOnPush (Context context, boolean enable)\n \n public static boolean getAutoInitOnPush (Context context)\n\t\n /**\n\t * Tracks a custom in-app event.\n\t * \n\t * @param verb Action verb.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb)\n\t\n\t/**\n\t * Tracks an event.\n\t * \n\t * @param verb Action verb.\n\t * @param value Value associated with the event.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb, long value)\n\n\t/**\n\t * Tracks an event.\n\t * \n\t * @param verb Action verb.\n\t * @param item Item associated with the event.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb, final String item)\n\n\t/**\n\t * Tracks an event.\n\t * \n\t * @param verb Action verb.\n\t * @param item Item associated with the event.\n\t * @param value Value associated with the event.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb, final String item, final long value)\n\n\t/**\n\t * Tracks an event.\n\t * \n\t * @param verb Action verb.\n\t * @param item Item associated with the event.\n\t * @param category Category the item belongs to.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb, final String category, final String item)\n\n\t/**\n\t * Tracks an event.\n\t * \n\t * @param verb Action verb.\n\t * @param item Item associated with the event.\n\t * @param category Category the item belongs to.\n\t * @param value Value associated with the event.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb, final String category, final String item, final long value)\n\n\t/**\n\t * Tracks an event with custom attributes.\n\t * \n\t * @param verb Action verb.\n\t * @param attrs Collection of attributes associated with this event (up to\n\t * 10). Value types are restricted to: {@link String},\n\t * {@link Integer}, {@link Long}, {@link Double}, {@link Float},\n\t * {@link Date} and {@link Location}.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb, final Map<String, Object> attrs)\n", "language": "java" } ] } [/block]
The `MOCA static class` is a main entry point to MOCA APIs. [block:code] { "codes": [ { "code": "\n\t/**\n\t * Returns the current MOCA SDK version.\n\t * \n\t * @return The version of the MOCA SDK library.\n\t */\n\tpublic static String getVersion()\n\t\n\t/**\n\t * Return the key of this application in MOCA service.\n\t * \n\t * @return MOCA app key.\n\t */\n\tpublic static String getAppKey()\n\t\n\t/**\n\t * Return the secret key of this application in MOCA service.\n\t * \n\t * @return MOCA app secret.\n\t */\n\tpublic static String getAppSecret()\n\t\n\t/**\n\t * Gets the level of logging that will be displayed.\n\t */\n\tpublic static MOCALogLevel getLogLevel()\n\n\t/**\n\t * Returns the current Application.\n\t * \n\t * @return The current application.\n\t */\n\tpublic static Application getApplication () \n\n /**\n * Gets instance object.\n */\n public static MOCAInstance getInstance ()\n \n\t/**\n\t * Provides access to MOCA Proximity Service. This service is only available\n\t * on Android 4.4 and newer.\n\t * \n\t * @return MOCAProximityService instance or null if it is not available or\n\t * has not been initialized.\n\t */\n\tpublic static MOCAProximityService getProximityService()\n\n\t/**\n\t * Returns true if MOCA Proximity Service is available on this device.\n\t * \n\t * @return true if the proximity service is available on this device.\n * Note: it can be disabled by configuration.\n\t */\n\tpublic static boolean isProximityAvailable()\n\n /**\n * Returns true if MOCA Proximity Service is available and enabled.\n *\n * @return true if the proximity service is enabled, or false otherwise.\n */\n public static boolean proximityEnabled ()\n\n /**\n * Starts/stops MOCA Proximity service.\n * @param enable\n */\n public static void setProximityEnabled (boolean enable) \n\n private static final String\tMOCA_AUTOINIT_ON_PUSH_KEY\t= \"MOCA_AUTO_INIT_ON_PUSH\";\n\n /**\n * Global settings. Enables MOCA to auto-initialize SDK on certain events.\n */\n public static void setAutoInitOnPush (Context context, boolean enable)\n \n public static boolean getAutoInitOnPush (Context context)\n\t\n /**\n\t * Tracks a custom in-app event.\n\t * \n\t * @param verb Action verb.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb)\n\t\n\t/**\n\t * Tracks an event.\n\t * \n\t * @param verb Action verb.\n\t * @param value Value associated with the event.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb, long value)\n\n\t/**\n\t * Tracks an event.\n\t * \n\t * @param verb Action verb.\n\t * @param item Item associated with the event.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb, final String item)\n\n\t/**\n\t * Tracks an event.\n\t * \n\t * @param verb Action verb.\n\t * @param item Item associated with the event.\n\t * @param value Value associated with the event.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb, final String item, final long value)\n\n\t/**\n\t * Tracks an event.\n\t * \n\t * @param verb Action verb.\n\t * @param item Item associated with the event.\n\t * @param category Category the item belongs to.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb, final String category, final String item)\n\n\t/**\n\t * Tracks an event.\n\t * \n\t * @param verb Action verb.\n\t * @param item Item associated with the event.\n\t * @param category Category the item belongs to.\n\t * @param value Value associated with the event.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb, final String category, final String item, final long value)\n\n\t/**\n\t * Tracks an event with custom attributes.\n\t * \n\t * @param verb Action verb.\n\t * @param attrs Collection of attributes associated with this event (up to\n\t * 10). Value types are restricted to: {@link String},\n\t * {@link Integer}, {@link Long}, {@link Double}, {@link Float},\n\t * {@link Date} and {@link Location}.\n\t * @return <code>YES</code> in case of success, <code>NO</code> in case of\n\t * error.\n\t */\n\tpublic static boolean track(final String verb, final Map<String, Object> attrs)\n", "language": "java" } ] } [/block]
{"_id":"55a932afc8bd450d000dd1d6","api":{"params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"code":"{}","name":"","status":400,"language":"json"}]},"settings":"","url":"","auth":"required"},"isReference":false,"order":1,"updates":[],"user":"559a618bdbcfd20d00710b38","__v":5,"githubsync":"","project":"559a61d2dbcfd20d00710b39","sync_unique":"","type":"basic","excerpt":"","body":"- The app Instance object is a local representation of an app instance downloaded and installed in a user device. \n- The instance object is automatically managed by MOCA. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"MOCAInstance instance = MOCA.getInstance();\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n- The instance object holds a collection of properties. Property-value pairs can be set and retrieved and are persisted between app sessions\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"/*Returns true if this map contains a mapping for the specified key.*/\\ncontainsProperty(java.lang.String key)\\n\\n/*Returns the Object Array value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\\ngetArrayProperty(java.lang.String key)\\n\\n/*Returns the Boolean value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\\ngetBoolProperty(java.lang.String key)\\n\\n/*Returns the Float value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\\ngetFloatProperty(java.lang.String key)\\n  \\n/*Returns the Integer value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\\ngetIntegerProperty(java.lang.String key)\\n  \\n/*Returns the long value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\\ngetLongProperty(java.lang.String key)\\n  \\n/*Returns the value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\\ngetProperty(java.lang.String key)\\n\\n/*Returns the String Array value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\\ngetStringArrayProperty(java.lang.String key)\\n  \\n/*Returns the String value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\\ngetStringProperty(java.lang.String key)\\n\\n/*Gets existing property keys.*/\\npropertySet()\\n  \\n/*Associates the specified property value with the specified property key in this container.*/\\nsetProperty(java.lang.String key, java.lang.Object value)\\n\\n\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nThe instance object holds **predefined properties** collected automatically:\n\n- Device-oriented, including:\n - device_model – the device model (i.e. iPhone 4S, iPhone 5C, iPhone 5S)\n - device_type – the type of device (i.e. iPhone, iPad, Simulator)\n - local_timezone – the local time zone's abbreviated name (i.e. EDT, GMT, PST)\n - country – the country code as defined by the user in Settings\n - lang – the user preferred language code as defined in Settings\n - os_name – the OS name (i.e. “Android”)\n - os_version – the OS version (i.e. “4.4”)\n - carrier_name – the name of the user’s home cellular service provider (E.g. Vodafone)\n - carrier_country – the ISO country code for the user’s cellular service provider.\n- App-oriented, including:\n - app_name – the app name\n - app_version – the app version number\n - vendor_id – the unique identifier for app vendor (i.e. UUID string)\n - moca_version – the version of MOCA SDK\n - gcm_token – the push notification device token (optional)\n - session – session counter (how many times a user launched the app).\n\n\n- The object may also store any custom property-value pairs. \n- Each instance object is persisted both locally and in the cloud. The instance is automatically uploaded to the cloud each time the app starts.\n- The instance can be saved manually to the cloud. All saves are asynchronous.\n- It is recommended to perform as many sets as desired and then just invoke a single save operation.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"MOCAInstance instance = MOCA.getInstance ();\\n// set MOCA custom properties\\ninstance.setProperty(\\\"job_position\\\", \\\"CTO\\\");\\ninstance.setProperty(”user_identifier\\\", 2948579);\\ninstance.setProperty(”user_score\\\", 147.61);\\ninstance.setProperty(”last_timestamp\\\", System.currentTimeMillis());\\nString[] skills = new String[]{“NoSQL\\\", ”Ruby\\\", “Java\\\", ”Objective-C\\\"};\\ninstance.setProperty(”user_skills\\\", skills );\\n                     // asynchronously upload to cloud\\ninstance.save(new MOCACallback<MOCAInstance>() {\\n                @Override\\n                public void success(MOCAInstance mocaInstance) {\\n                    MLog.i(\\\"Instance uploaded to cloud\\\");\\n                }\\n\\n                @Override\\n                public void failure(MOCAException e) {\\n                    MLog.e(\\\"Instance upload failed\\\", e);\\n                }\\n});\\n\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","hidden":false,"link_url":"","version":"559a61d2dbcfd20d00710b3c","createdAt":"2015-07-17T16:51:59.713Z","link_external":false,"parentDoc":null,"slug":"instance-api-1","title":"Instance API","category":"55a93098cf45e1390093f351","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Instance API


- The app Instance object is a local representation of an app instance downloaded and installed in a user device. - The instance object is automatically managed by MOCA. [block:code] { "codes": [ { "code": "MOCAInstance instance = MOCA.getInstance();", "language": "java" } ] } [/block] - The instance object holds a collection of properties. Property-value pairs can be set and retrieved and are persisted between app sessions [block:code] { "codes": [ { "code": "/*Returns true if this map contains a mapping for the specified key.*/\ncontainsProperty(java.lang.String key)\n\n/*Returns the Object Array value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetArrayProperty(java.lang.String key)\n\n/*Returns the Boolean value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetBoolProperty(java.lang.String key)\n\n/*Returns the Float value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetFloatProperty(java.lang.String key)\n \n/*Returns the Integer value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetIntegerProperty(java.lang.String key)\n \n/*Returns the long value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetLongProperty(java.lang.String key)\n \n/*Returns the value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetProperty(java.lang.String key)\n\n/*Returns the String Array value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetStringArrayProperty(java.lang.String key)\n \n/*Returns the String value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetStringProperty(java.lang.String key)\n\n/*Gets existing property keys.*/\npropertySet()\n \n/*Associates the specified property value with the specified property key in this container.*/\nsetProperty(java.lang.String key, java.lang.Object value)\n\n", "language": "java" } ] } [/block] The instance object holds **predefined properties** collected automatically: - Device-oriented, including: - device_model – the device model (i.e. iPhone 4S, iPhone 5C, iPhone 5S) - device_type – the type of device (i.e. iPhone, iPad, Simulator) - local_timezone – the local time zone's abbreviated name (i.e. EDT, GMT, PST) - country – the country code as defined by the user in Settings - lang – the user preferred language code as defined in Settings - os_name – the OS name (i.e. “Android”) - os_version – the OS version (i.e. “4.4”) - carrier_name – the name of the user’s home cellular service provider (E.g. Vodafone) - carrier_country – the ISO country code for the user’s cellular service provider. - App-oriented, including: - app_name – the app name - app_version – the app version number - vendor_id – the unique identifier for app vendor (i.e. UUID string) - moca_version – the version of MOCA SDK - gcm_token – the push notification device token (optional) - session – session counter (how many times a user launched the app). - The object may also store any custom property-value pairs. - Each instance object is persisted both locally and in the cloud. The instance is automatically uploaded to the cloud each time the app starts. - The instance can be saved manually to the cloud. All saves are asynchronous. - It is recommended to perform as many sets as desired and then just invoke a single save operation. [block:code] { "codes": [ { "code": "MOCAInstance instance = MOCA.getInstance ();\n// set MOCA custom properties\ninstance.setProperty(\"job_position\", \"CTO\");\ninstance.setProperty(”user_identifier\", 2948579);\ninstance.setProperty(”user_score\", 147.61);\ninstance.setProperty(”last_timestamp\", System.currentTimeMillis());\nString[] skills = new String[]{“NoSQL\", ”Ruby\", “Java\", ”Objective-C\"};\ninstance.setProperty(”user_skills\", skills );\n // asynchronously upload to cloud\ninstance.save(new MOCACallback<MOCAInstance>() {\n @Override\n public void success(MOCAInstance mocaInstance) {\n MLog.i(\"Instance uploaded to cloud\");\n }\n\n @Override\n public void failure(MOCAException e) {\n MLog.e(\"Instance upload failed\", e);\n }\n});\n", "language": "java" } ] } [/block]
- The app Instance object is a local representation of an app instance downloaded and installed in a user device. - The instance object is automatically managed by MOCA. [block:code] { "codes": [ { "code": "MOCAInstance instance = MOCA.getInstance();", "language": "java" } ] } [/block] - The instance object holds a collection of properties. Property-value pairs can be set and retrieved and are persisted between app sessions [block:code] { "codes": [ { "code": "/*Returns true if this map contains a mapping for the specified key.*/\ncontainsProperty(java.lang.String key)\n\n/*Returns the Object Array value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetArrayProperty(java.lang.String key)\n\n/*Returns the Boolean value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetBoolProperty(java.lang.String key)\n\n/*Returns the Float value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetFloatProperty(java.lang.String key)\n \n/*Returns the Integer value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetIntegerProperty(java.lang.String key)\n \n/*Returns the long value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetLongProperty(java.lang.String key)\n \n/*Returns the value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetProperty(java.lang.String key)\n\n/*Returns the String Array value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetStringArrayProperty(java.lang.String key)\n \n/*Returns the String value to which the specified property key is mapped, or null if this map contains no mapping for the key.*/\ngetStringProperty(java.lang.String key)\n\n/*Gets existing property keys.*/\npropertySet()\n \n/*Associates the specified property value with the specified property key in this container.*/\nsetProperty(java.lang.String key, java.lang.Object value)\n\n", "language": "java" } ] } [/block] The instance object holds **predefined properties** collected automatically: - Device-oriented, including: - device_model – the device model (i.e. iPhone 4S, iPhone 5C, iPhone 5S) - device_type – the type of device (i.e. iPhone, iPad, Simulator) - local_timezone – the local time zone's abbreviated name (i.e. EDT, GMT, PST) - country – the country code as defined by the user in Settings - lang – the user preferred language code as defined in Settings - os_name – the OS name (i.e. “Android”) - os_version – the OS version (i.e. “4.4”) - carrier_name – the name of the user’s home cellular service provider (E.g. Vodafone) - carrier_country – the ISO country code for the user’s cellular service provider. - App-oriented, including: - app_name – the app name - app_version – the app version number - vendor_id – the unique identifier for app vendor (i.e. UUID string) - moca_version – the version of MOCA SDK - gcm_token – the push notification device token (optional) - session – session counter (how many times a user launched the app). - The object may also store any custom property-value pairs. - Each instance object is persisted both locally and in the cloud. The instance is automatically uploaded to the cloud each time the app starts. - The instance can be saved manually to the cloud. All saves are asynchronous. - It is recommended to perform as many sets as desired and then just invoke a single save operation. [block:code] { "codes": [ { "code": "MOCAInstance instance = MOCA.getInstance ();\n// set MOCA custom properties\ninstance.setProperty(\"job_position\", \"CTO\");\ninstance.setProperty(”user_identifier\", 2948579);\ninstance.setProperty(”user_score\", 147.61);\ninstance.setProperty(”last_timestamp\", System.currentTimeMillis());\nString[] skills = new String[]{“NoSQL\", ”Ruby\", “Java\", ”Objective-C\"};\ninstance.setProperty(”user_skills\", skills );\n // asynchronously upload to cloud\ninstance.save(new MOCACallback<MOCAInstance>() {\n @Override\n public void success(MOCAInstance mocaInstance) {\n MLog.i(\"Instance uploaded to cloud\");\n }\n\n @Override\n public void failure(MOCAException e) {\n MLog.e(\"Instance upload failed\", e);\n }\n});\n", "language": "java" } ] } [/block]
{"_id":"55a938ba4c661b3700cf4e1f","hidden":false,"isReference":false,"project":"559a61d2dbcfd20d00710b39","updates":[],"body":"- The app User object manages information about current application user.\n- This object is optional, and it is used when the app needs to authenticate the user. \n- The authentication provides data about user’s identity a *unique user* ID or similar. \n- The user login and logout calls are managed by the app.\n\n\nTo access existing *User object*, use currentUser property: \u000b\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Access authenticated user object\\nMOCAUser theUser = MOCA.getInstance().getUser();\\nif (theUser != null) {\\n    // ...\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nTo *authenticate* a new user, use *login(id)* call:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Authenticate a user by e-mail address    \\nMOCAUser theUser = MOCA.getInstance().login(”UNIQUE_USER_ID”);\\n// ...\\n\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nTo **logout** a user, call:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"theUser.logout();\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n- The user object holds a **collection of properties**. Property-value pairs can be set and retrieved.\n- Each user object is **persisted both locally and in the cloud**. \n- It is recommended to perform as many sets as desired and then \njust invoke a single save operation to persist them to the MOCA cloud.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"MOCAUser theUser = MOCA.getInstance().login(\\\"some_unique_id\\\");\\nif (theUser != null) {\\n    theUser.save(new MOCACallback<MOCAUser>() {\\n        @Override\\n        public void success(MOCAUser user) {\\n            Log.i(TAG, \\\"Login successful\\\");\\n        }\\n\\n        @Override\\n        public void failure(MOCAException e) {\\n            Log.e(TAG, \\\"Login failed\\\", e);\\n        }\\n    });\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","category":"55a93098cf45e1390093f351","createdAt":"2015-07-17T17:17:46.264Z","link_url":"","parentDoc":null,"sync_unique":"","title":"User API","user":"559a618bdbcfd20d00710b38","version":"559a61d2dbcfd20d00710b3c","__v":2,"api":{"auth":"required","params":[],"results":{"codes":[{"language":"json","code":"{}","name":"","status":200},{"code":"{}","name":"","status":400,"language":"json"}]},"settings":"","url":""},"excerpt":"","link_external":false,"slug":"user-api-1","githubsync":"","order":2,"type":"basic","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

User API


- The app User object manages information about current application user. - This object is optional, and it is used when the app needs to authenticate the user. - The authentication provides data about user’s identity a *unique user* ID or similar. - The user login and logout calls are managed by the app. To access existing *User object*, use currentUser property: [block:code] { "codes": [ { "code": "// Access authenticated user object\nMOCAUser theUser = MOCA.getInstance().getUser();\nif (theUser != null) {\n // ...\n}", "language": "java" } ] } [/block] To *authenticate* a new user, use *login(id)* call: [block:code] { "codes": [ { "code": "// Authenticate a user by e-mail address \nMOCAUser theUser = MOCA.getInstance().login(”UNIQUE_USER_ID”);\n// ...\n", "language": "java" } ] } [/block] To **logout** a user, call: [block:code] { "codes": [ { "code": "theUser.logout();", "language": "java" } ] } [/block] - The user object holds a **collection of properties**. Property-value pairs can be set and retrieved. - Each user object is **persisted both locally and in the cloud**. - It is recommended to perform as many sets as desired and then just invoke a single save operation to persist them to the MOCA cloud. [block:code] { "codes": [ { "code": "MOCAUser theUser = MOCA.getInstance().login(\"some_unique_id\");\nif (theUser != null) {\n theUser.save(new MOCACallback<MOCAUser>() {\n @Override\n public void success(MOCAUser user) {\n Log.i(TAG, \"Login successful\");\n }\n\n @Override\n public void failure(MOCAException e) {\n Log.e(TAG, \"Login failed\", e);\n }\n });\n}", "language": "java" } ] } [/block]
- The app User object manages information about current application user. - This object is optional, and it is used when the app needs to authenticate the user. - The authentication provides data about user’s identity a *unique user* ID or similar. - The user login and logout calls are managed by the app. To access existing *User object*, use currentUser property: [block:code] { "codes": [ { "code": "// Access authenticated user object\nMOCAUser theUser = MOCA.getInstance().getUser();\nif (theUser != null) {\n // ...\n}", "language": "java" } ] } [/block] To *authenticate* a new user, use *login(id)* call: [block:code] { "codes": [ { "code": "// Authenticate a user by e-mail address \nMOCAUser theUser = MOCA.getInstance().login(”UNIQUE_USER_ID”);\n// ...\n", "language": "java" } ] } [/block] To **logout** a user, call: [block:code] { "codes": [ { "code": "theUser.logout();", "language": "java" } ] } [/block] - The user object holds a **collection of properties**. Property-value pairs can be set and retrieved. - Each user object is **persisted both locally and in the cloud**. - It is recommended to perform as many sets as desired and then just invoke a single save operation to persist them to the MOCA cloud. [block:code] { "codes": [ { "code": "MOCAUser theUser = MOCA.getInstance().login(\"some_unique_id\");\nif (theUser != null) {\n theUser.save(new MOCACallback<MOCAUser>() {\n @Override\n public void success(MOCAUser user) {\n Log.i(TAG, \"Login successful\");\n }\n\n @Override\n public void failure(MOCAException e) {\n Log.e(TAG, \"Login failed\", e);\n }\n });\n}", "language": "java" } ] } [/block]
{"_id":"55a939b502becf2d007aac34","api":{"params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":"","auth":"required"},"body":"- The MOCA SDK, once the user has opted in, passively develops \u000ba **User Profile **of mobile usage and other behaviors.\n- The profile ensures that the app can deliver much more personalized, relevant content based on: \n - Interests – sports, video games, books, cooking\n - Places of Interest (POIs) – top locations where the user spends time (e.g. home, work, restaurant, etc.)\n- User profile is elaborated automatically without user interaction\n- MOCA respects user’s privacy. Contact us for privacy policy recommendations.","excerpt":"","parentDoc":null,"sync_unique":"","version":"559a61d2dbcfd20d00710b3c","createdAt":"2015-07-17T17:21:57.339Z","hidden":false,"isReference":false,"link_external":false,"title":"User Profile","type":"basic","githubsync":"","project":"559a61d2dbcfd20d00710b39","updates":[],"user":"559a618bdbcfd20d00710b38","__v":2,"category":"55a93098cf45e1390093f351","link_url":"","order":3,"slug":"user-profile-1","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

User Profile


- The MOCA SDK, once the user has opted in, passively develops a **User Profile **of mobile usage and other behaviors. - The profile ensures that the app can deliver much more personalized, relevant content based on: - Interests – sports, video games, books, cooking - Places of Interest (POIs) – top locations where the user spends time (e.g. home, work, restaurant, etc.) - User profile is elaborated automatically without user interaction - MOCA respects user’s privacy. Contact us for privacy policy recommendations.
- The MOCA SDK, once the user has opted in, passively develops a **User Profile **of mobile usage and other behaviors. - The profile ensures that the app can deliver much more personalized, relevant content based on: - Interests – sports, video games, books, cooking - Places of Interest (POIs) – top locations where the user spends time (e.g. home, work, restaurant, etc.) - User profile is elaborated automatically without user interaction - MOCA respects user’s privacy. Contact us for privacy policy recommendations.
{"_id":"55a93a015d3abb0d0012f184","excerpt":"","githubsync":"","hidden":false,"link_external":false,"parentDoc":null,"type":"basic","user":"559a618bdbcfd20d00710b38","version":"559a61d2dbcfd20d00710b3c","__v":3,"api":{"auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"category":"55a93098cf45e1390093f351","link_url":"","slug":"tag-api","updates":[],"body":"- To sense user interests, MOCA uses *Tags*.\n- Tags are small items of information with well defined semantics. \n- Each tag is associated with a ***counter***. The counter is used to track how many times the user was tagged or to sum points associated with the tag. \n- Tags are defined in MOCA Console or by the app.\n- For example: `Restaurant` `Video Store` `Woman` `Parking` `Gym`\n- Tags can be attached to specific locations by using beacons or programmatically by API.\n- Tag counters are used to rank the tags.\n\n\n-A single Tag is modeled as follows:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"/**\\n * MOCATag represents a category of interest. Sample tags include \\\"books\\\",\\n * \\\"video\\\", \\\"music\\\", \\\"food\\\", or\\n */\\npublic interface MOCATag {\\n    /**\\n     * Get tag's name.\\n     *\\n     * @return tag name\\n     */\\n    public String getName();\\n\\n    /**\\n     * Get tag's weight.\\n     *\\n     * @return weight value\\n     */\\n    public double getValue();\\n\\n    /**\\n     * Get date tag was created.\\n     * @return UTC timestamp\\n     */\\n    public long getCreatedAt();\\n\\n    /**\\n     * Get last modification date.\\n     * @return UTC timestamp\\n     */\\n    public long getModifiedAt ();\\n\\n}\\n\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nMOCA provides the following methods to manipulate Tags.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\n\\t  /**\\n\\t   * Retrieves a collection of tags for this instance.\\n\\t   */\\n\\t  public Set<MOCATag> getTags();\\n\\n    /**\\n     * Add a tag to this instance and increment its value by 1.\\n     */\\n    public void addTag (String tagName);\\n\\n    /**\\n     * Add a tag with a given value to this instance.\\n     * @value - update expression with syntax [=|+|-] <double> value.\\n     * For example \\\"+1\\\" increments the tag value by 1.\\n     * For example \\\"-2\\\" decrements the tag value by 2.\\n     * For example \\\"3\\\" or \\\"=3\\\" assign value of 3 to the tag's value.\\n     */\\n    public void addTag (String tagName, String value);\\n\\n    /**\\n     * Checks if this instance contains a specific tag.\\n     * @return <code>YES</code> if the instance contains a tag, or <code>NO</code> otherwise.\\n     */\\n    public boolean containsTag (String tagName);\\n\\n    /**\\n     * Retrieves a value of a specific tag associated with this instance.\\n     * @return tag value or <code>nil</code> if the tag doest not exist.\\n     */\\n    public Double getTagValue (String tagName);\\n\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","order":4,"sync_unique":"","title":"Tag API","createdAt":"2015-07-17T17:23:13.913Z","isReference":false,"project":"559a61d2dbcfd20d00710b39","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Tag API


- To sense user interests, MOCA uses *Tags*. - Tags are small items of information with well defined semantics. - Each tag is associated with a ***counter***. The counter is used to track how many times the user was tagged or to sum points associated with the tag. - Tags are defined in MOCA Console or by the app. - For example: `Restaurant` `Video Store` `Woman` `Parking` `Gym` - Tags can be attached to specific locations by using beacons or programmatically by API. - Tag counters are used to rank the tags. -A single Tag is modeled as follows: [block:code] { "codes": [ { "code": "/**\n * MOCATag represents a category of interest. Sample tags include \"books\",\n * \"video\", \"music\", \"food\", or\n */\npublic interface MOCATag {\n /**\n * Get tag's name.\n *\n * @return tag name\n */\n public String getName();\n\n /**\n * Get tag's weight.\n *\n * @return weight value\n */\n public double getValue();\n\n /**\n * Get date tag was created.\n * @return UTC timestamp\n */\n public long getCreatedAt();\n\n /**\n * Get last modification date.\n * @return UTC timestamp\n */\n public long getModifiedAt ();\n\n}\n", "language": "java" } ] } [/block] MOCA provides the following methods to manipulate Tags. [block:code] { "codes": [ { "code": "\n\t /**\n\t * Retrieves a collection of tags for this instance.\n\t */\n\t public Set<MOCATag> getTags();\n\n /**\n * Add a tag to this instance and increment its value by 1.\n */\n public void addTag (String tagName);\n\n /**\n * Add a tag with a given value to this instance.\n * @value - update expression with syntax [=|+|-] <double> value.\n * For example \"+1\" increments the tag value by 1.\n * For example \"-2\" decrements the tag value by 2.\n * For example \"3\" or \"=3\" assign value of 3 to the tag's value.\n */\n public void addTag (String tagName, String value);\n\n /**\n * Checks if this instance contains a specific tag.\n * @return <code>YES</code> if the instance contains a tag, or <code>NO</code> otherwise.\n */\n public boolean containsTag (String tagName);\n\n /**\n * Retrieves a value of a specific tag associated with this instance.\n * @return tag value or <code>nil</code> if the tag doest not exist.\n */\n public Double getTagValue (String tagName);\n", "language": "java" } ] } [/block]
- To sense user interests, MOCA uses *Tags*. - Tags are small items of information with well defined semantics. - Each tag is associated with a ***counter***. The counter is used to track how many times the user was tagged or to sum points associated with the tag. - Tags are defined in MOCA Console or by the app. - For example: `Restaurant` `Video Store` `Woman` `Parking` `Gym` - Tags can be attached to specific locations by using beacons or programmatically by API. - Tag counters are used to rank the tags. -A single Tag is modeled as follows: [block:code] { "codes": [ { "code": "/**\n * MOCATag represents a category of interest. Sample tags include \"books\",\n * \"video\", \"music\", \"food\", or\n */\npublic interface MOCATag {\n /**\n * Get tag's name.\n *\n * @return tag name\n */\n public String getName();\n\n /**\n * Get tag's weight.\n *\n * @return weight value\n */\n public double getValue();\n\n /**\n * Get date tag was created.\n * @return UTC timestamp\n */\n public long getCreatedAt();\n\n /**\n * Get last modification date.\n * @return UTC timestamp\n */\n public long getModifiedAt ();\n\n}\n", "language": "java" } ] } [/block] MOCA provides the following methods to manipulate Tags. [block:code] { "codes": [ { "code": "\n\t /**\n\t * Retrieves a collection of tags for this instance.\n\t */\n\t public Set<MOCATag> getTags();\n\n /**\n * Add a tag to this instance and increment its value by 1.\n */\n public void addTag (String tagName);\n\n /**\n * Add a tag with a given value to this instance.\n * @value - update expression with syntax [=|+|-] <double> value.\n * For example \"+1\" increments the tag value by 1.\n * For example \"-2\" decrements the tag value by 2.\n * For example \"3\" or \"=3\" assign value of 3 to the tag's value.\n */\n public void addTag (String tagName, String value);\n\n /**\n * Checks if this instance contains a specific tag.\n * @return <code>YES</code> if the instance contains a tag, or <code>NO</code> otherwise.\n */\n public boolean containsTag (String tagName);\n\n /**\n * Retrieves a value of a specific tag associated with this instance.\n * @return tag value or <code>nil</code> if the tag doest not exist.\n */\n public Double getTagValue (String tagName);\n", "language": "java" } ] } [/block]
{"_id":"55a93b225d3abb0d0012f191","order":5,"slug":"event-api-1","sync_unique":"","title":"Event API","user":"559a618bdbcfd20d00710b38","createdAt":"2015-07-17T17:28:02.199Z","githubsync":"","link_external":false,"project":"559a61d2dbcfd20d00710b39","version":"559a61d2dbcfd20d00710b3c","link_url":"","parentDoc":null,"type":"basic","category":"55a93098cf45e1390093f351","excerpt":"","hidden":false,"isReference":false,"updates":[],"__v":6,"api":{"auth":"required","params":[],"results":{"codes":[{"language":"json","code":"{}","name":"","status":200},{"code":"{}","name":"","status":400,"language":"json"}]},"settings":"","url":""},"body":"A single `event object` record contains:\n\n- Event data:\n - Identifier – unique event ID (UUID)\n - Timestamp – GMT timestamp when event occurred\n - Local timestamp – timestamp with local timezone\n - Event type – type of event\n - Action verb – string that describes performed action (i.e. Buy, View, Search, Enter, etc.)\n - Item – item associated with the event (i.e. Product ID)\n - Item Category – category the item belongs to (Product Category)\n - Value – value associated with the event (E.g. purchase amount)\n\n- Context data:\n - Instance ID – the instance object ID that generated the event\n - User ID – the logged-in user that generated the event (optional)\n - Device model/type\n - OS name/version\n - Country\n - Language\n - And other attributes\n\nBy default, the SDK automatically tracks predefined events:\n - _start_session – when the new app session was started\n - _session – when the user’s session ends\n - _geo – track last coordinates of the current location *\n - _visit – when a user visits a frequent place *\n - _push – when push notification has been received while the app was running\n - _launching_push – when app was started by a push notification\n - _action – when proximity action has been triggered\n - _beacon_proximity – when the device entered/exited a beacon region *\n - _zone_proximity – when the device entered/exited a proximity zone *\n - _place_proximity – when the device entered/exited a proximity place *\n - _tick – indicates if the app is active\n - _user_login – when user logged in\n - _user_logout – when user logged out\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"`*` Used when available and allowed by user privacy settings.\",\n  \"sidebar\": true\n}\n[/block]\nTo track custom events in your app, use the following API:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public class MOCA {\\n  /**\\n   * Tracks an event represented by an action verb \\n   *\\n   * @param verb Action verb. (E.g. Buy, View, Search, etc.).\\n   *\\n   * @return <code>true</code> in case of success, <code>false</code> in case of error.\\n   */\\n   public static boolean track (final String verb);\\n\\n   /**\\n    * Track event helper methods. \\n    */\\n    public static boolean track (final String verb, long value);\\n    public static boolean track (final String verb, final String item);\\n    public static boolean track (final String verb, final String item, final long value);\\n    public static boolean track (final String verb, final String category, final String item);\\n    public static boolean track (final String verb, final String category, final String item, final long value);\\n    public static boolean track (final String verb, final Map<String, Object> attrs);\\n}\\n\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Event API


A single `event object` record contains: - Event data: - Identifier – unique event ID (UUID) - Timestamp – GMT timestamp when event occurred - Local timestamp – timestamp with local timezone - Event type – type of event - Action verb – string that describes performed action (i.e. Buy, View, Search, Enter, etc.) - Item – item associated with the event (i.e. Product ID) - Item Category – category the item belongs to (Product Category) - Value – value associated with the event (E.g. purchase amount) - Context data: - Instance ID – the instance object ID that generated the event - User ID – the logged-in user that generated the event (optional) - Device model/type - OS name/version - Country - Language - And other attributes By default, the SDK automatically tracks predefined events: - _start_session – when the new app session was started - _session – when the user’s session ends - _geo – track last coordinates of the current location * - _visit – when a user visits a frequent place * - _push – when push notification has been received while the app was running - _launching_push – when app was started by a push notification - _action – when proximity action has been triggered - _beacon_proximity – when the device entered/exited a beacon region * - _zone_proximity – when the device entered/exited a proximity zone * - _place_proximity – when the device entered/exited a proximity place * - _tick – indicates if the app is active - _user_login – when user logged in - _user_logout – when user logged out [block:callout] { "type": "warning", "body": "`*` Used when available and allowed by user privacy settings.", "sidebar": true } [/block] To track custom events in your app, use the following API: [block:code] { "codes": [ { "code": "public class MOCA {\n /**\n * Tracks an event represented by an action verb \n *\n * @param verb Action verb. (E.g. Buy, View, Search, etc.).\n *\n * @return <code>true</code> in case of success, <code>false</code> in case of error.\n */\n public static boolean track (final String verb);\n\n /**\n * Track event helper methods. \n */\n public static boolean track (final String verb, long value);\n public static boolean track (final String verb, final String item);\n public static boolean track (final String verb, final String item, final long value);\n public static boolean track (final String verb, final String category, final String item);\n public static boolean track (final String verb, final String category, final String item, final long value);\n public static boolean track (final String verb, final Map<String, Object> attrs);\n}\n", "language": "java" } ] } [/block]
A single `event object` record contains: - Event data: - Identifier – unique event ID (UUID) - Timestamp – GMT timestamp when event occurred - Local timestamp – timestamp with local timezone - Event type – type of event - Action verb – string that describes performed action (i.e. Buy, View, Search, Enter, etc.) - Item – item associated with the event (i.e. Product ID) - Item Category – category the item belongs to (Product Category) - Value – value associated with the event (E.g. purchase amount) - Context data: - Instance ID – the instance object ID that generated the event - User ID – the logged-in user that generated the event (optional) - Device model/type - OS name/version - Country - Language - And other attributes By default, the SDK automatically tracks predefined events: - _start_session – when the new app session was started - _session – when the user’s session ends - _geo – track last coordinates of the current location * - _visit – when a user visits a frequent place * - _push – when push notification has been received while the app was running - _launching_push – when app was started by a push notification - _action – when proximity action has been triggered - _beacon_proximity – when the device entered/exited a beacon region * - _zone_proximity – when the device entered/exited a proximity zone * - _place_proximity – when the device entered/exited a proximity place * - _tick – indicates if the app is active - _user_login – when user logged in - _user_logout – when user logged out [block:callout] { "type": "warning", "body": "`*` Used when available and allowed by user privacy settings.", "sidebar": true } [/block] To track custom events in your app, use the following API: [block:code] { "codes": [ { "code": "public class MOCA {\n /**\n * Tracks an event represented by an action verb \n *\n * @param verb Action verb. (E.g. Buy, View, Search, etc.).\n *\n * @return <code>true</code> in case of success, <code>false</code> in case of error.\n */\n public static boolean track (final String verb);\n\n /**\n * Track event helper methods. \n */\n public static boolean track (final String verb, long value);\n public static boolean track (final String verb, final String item);\n public static boolean track (final String verb, final String item, final long value);\n public static boolean track (final String verb, final String category, final String item);\n public static boolean track (final String verb, final String category, final String item, final long value);\n public static boolean track (final String verb, final Map<String, Object> attrs);\n}\n", "language": "java" } ] } [/block]
{"_id":"55a93d4c02becf2d007aac4c","excerpt":"","body":"##Introduction\n\n- The *MOCA SDK* lets you effortlessly add Bluetooth beacon based proximity experiences to your Android app.\n- The SDK comes with a powerful proximity engine based on Complex Event Processing logic (see CEP).\n- MOCA defines some fundamental concepts:\n - Place, Zone, and Beacon\n - Trigger and Action\n - Visit\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/WLyeYphSEG6RZQzRWIvs_Da-proximity-experience.png\",\n        \"Da-proximity-experience.png\",\n        \"911\",\n        \"457\",\n        \"#3ba0da\",\n        \"\"\n      ],\n      \"caption\": \"MOCA Fundamental concepts\"\n    }\n  ]\n}\n[/block]\nTo start using** Beacon-based proximity experiences** in your Android app, you’ll need to enable proximity service.\n\n\n- Ensure proximity service is enabled in `AndroidManifest.xml file\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \" <application …>\\n\\n\\t<meta-data android:name=”moca.PROXIMITY_SERVICE_ENABLED\\\" android:value=\\\"true\\\"/>\\n\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n- The MOCA.initializeSDK() call, will automatically start MOCA proximity engine and synchronize proximity campaigns defined in your MOCA cloud account.\n\n###Places\nRepresents a real-world location, such as a store, venue, museum, building, office and so on.\n- A place can be localized by a geo-fence (GPS location and radius in meters) \n- A place contains a collection of zones, where each zone defines semantics for an indoor location, such as Kids Clothes, Women Clothes, Entrance, Exit, Books, Videogames, etc.\n\n###Zone\nRepresents a indoor area or micro-location within the place with user-defined semantics. \n- Examples include Kids Clothes, Women Clothes, Entrance, Exit, Books, Videogames, etc.\n- A zone is defined by a range of one or more beacon sensors. \n\n###Beacon\nIt is a BLE, iBeacon-compatible proximity sensor.\n- Each beacon is identified by { Proximity UUID, Major and Minor } tuple.\n- MOCA SDK works with any iBeacon-compatible devices. \n - This includes MOCA Beacons \n - And beacons provided by other manufacturers such as Kontakt.io, Estimote, etc.\n- Beacons are assigned to Zones that define their micro-location semantics. \n- Each beacon must be registered in MOCA Management Console.\n\n###Campaigns \nCollections of proximity experiences that are delivered to a user within a specified time frame.\n\n###Experience \nDefines a proximity interaction with a user. \n- An experience is composed of a trigger condition and an action. \n- When proximity trigger conditions are met, the corresponding action is fired.\n\n###Trigger\nIt is a condition or a collection of conditions that must be met to fire an action associated with an experience. For example:\n- Enter place, \n- Exit place, \n- Enter zone, \n- Exit zone,\n- Enter beacon range with given proximity, \n- Exit beacon range,\n- Custom trigger (implemented as app-provided delegate callback)\n\n###Action\nDescribes an activity to be performed when experience trigger conditions are met. The SDK supports the following actions:\n- Show local push notification with a specific message\n- Play sound with a specific file name (included in app bundle)\n- Play video from URL\n- Show image from URL\n- Show HTML content from URL\n- Open custom URL\n- Show PassBook card\n- Custom action (implemented as app-provided delegate callback)","hidden":false,"isReference":false,"link_external":false,"order":6,"parentDoc":null,"version":"559a61d2dbcfd20d00710b3c","api":{"url":"","auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":""},"createdAt":"2015-07-17T17:37:16.339Z","link_url":"","project":"559a61d2dbcfd20d00710b39","title":"Proximity API","updates":[],"user":"559a618bdbcfd20d00710b38","__v":10,"category":"55a93098cf45e1390093f351","githubsync":"","slug":"proximity-api-1","sync_unique":"","type":"basic","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Proximity API


##Introduction - The *MOCA SDK* lets you effortlessly add Bluetooth beacon based proximity experiences to your Android app. - The SDK comes with a powerful proximity engine based on Complex Event Processing logic (see CEP). - MOCA defines some fundamental concepts: - Place, Zone, and Beacon - Trigger and Action - Visit [block:image] { "images": [ { "image": [ "https://files.readme.io/WLyeYphSEG6RZQzRWIvs_Da-proximity-experience.png", "Da-proximity-experience.png", "911", "457", "#3ba0da", "" ], "caption": "MOCA Fundamental concepts" } ] } [/block] To start using** Beacon-based proximity experiences** in your Android app, you’ll need to enable proximity service. - Ensure proximity service is enabled in `AndroidManifest.xml file [block:code] { "codes": [ { "code": " <application …>\n\n\t<meta-data android:name=”moca.PROXIMITY_SERVICE_ENABLED\" android:value=\"true\"/>\n", "language": "xml" } ] } [/block] - The MOCA.initializeSDK() call, will automatically start MOCA proximity engine and synchronize proximity campaigns defined in your MOCA cloud account. ###Places Represents a real-world location, such as a store, venue, museum, building, office and so on. - A place can be localized by a geo-fence (GPS location and radius in meters) - A place contains a collection of zones, where each zone defines semantics for an indoor location, such as Kids Clothes, Women Clothes, Entrance, Exit, Books, Videogames, etc. ###Zone Represents a indoor area or micro-location within the place with user-defined semantics. - Examples include Kids Clothes, Women Clothes, Entrance, Exit, Books, Videogames, etc. - A zone is defined by a range of one or more beacon sensors. ###Beacon It is a BLE, iBeacon-compatible proximity sensor. - Each beacon is identified by { Proximity UUID, Major and Minor } tuple. - MOCA SDK works with any iBeacon-compatible devices. - This includes MOCA Beacons - And beacons provided by other manufacturers such as Kontakt.io, Estimote, etc. - Beacons are assigned to Zones that define their micro-location semantics. - Each beacon must be registered in MOCA Management Console. ###Campaigns Collections of proximity experiences that are delivered to a user within a specified time frame. ###Experience Defines a proximity interaction with a user. - An experience is composed of a trigger condition and an action. - When proximity trigger conditions are met, the corresponding action is fired. ###Trigger It is a condition or a collection of conditions that must be met to fire an action associated with an experience. For example: - Enter place, - Exit place, - Enter zone, - Exit zone, - Enter beacon range with given proximity, - Exit beacon range, - Custom trigger (implemented as app-provided delegate callback) ###Action Describes an activity to be performed when experience trigger conditions are met. The SDK supports the following actions: - Show local push notification with a specific message - Play sound with a specific file name (included in app bundle) - Play video from URL - Show image from URL - Show HTML content from URL - Open custom URL - Show PassBook card - Custom action (implemented as app-provided delegate callback)
##Introduction - The *MOCA SDK* lets you effortlessly add Bluetooth beacon based proximity experiences to your Android app. - The SDK comes with a powerful proximity engine based on Complex Event Processing logic (see CEP). - MOCA defines some fundamental concepts: - Place, Zone, and Beacon - Trigger and Action - Visit [block:image] { "images": [ { "image": [ "https://files.readme.io/WLyeYphSEG6RZQzRWIvs_Da-proximity-experience.png", "Da-proximity-experience.png", "911", "457", "#3ba0da", "" ], "caption": "MOCA Fundamental concepts" } ] } [/block] To start using** Beacon-based proximity experiences** in your Android app, you’ll need to enable proximity service. - Ensure proximity service is enabled in `AndroidManifest.xml file [block:code] { "codes": [ { "code": " <application …>\n\n\t<meta-data android:name=”moca.PROXIMITY_SERVICE_ENABLED\" android:value=\"true\"/>\n", "language": "xml" } ] } [/block] - The MOCA.initializeSDK() call, will automatically start MOCA proximity engine and synchronize proximity campaigns defined in your MOCA cloud account. ###Places Represents a real-world location, such as a store, venue, museum, building, office and so on. - A place can be localized by a geo-fence (GPS location and radius in meters) - A place contains a collection of zones, where each zone defines semantics for an indoor location, such as Kids Clothes, Women Clothes, Entrance, Exit, Books, Videogames, etc. ###Zone Represents a indoor area or micro-location within the place with user-defined semantics. - Examples include Kids Clothes, Women Clothes, Entrance, Exit, Books, Videogames, etc. - A zone is defined by a range of one or more beacon sensors. ###Beacon It is a BLE, iBeacon-compatible proximity sensor. - Each beacon is identified by { Proximity UUID, Major and Minor } tuple. - MOCA SDK works with any iBeacon-compatible devices. - This includes MOCA Beacons - And beacons provided by other manufacturers such as Kontakt.io, Estimote, etc. - Beacons are assigned to Zones that define their micro-location semantics. - Each beacon must be registered in MOCA Management Console. ###Campaigns Collections of proximity experiences that are delivered to a user within a specified time frame. ###Experience Defines a proximity interaction with a user. - An experience is composed of a trigger condition and an action. - When proximity trigger conditions are met, the corresponding action is fired. ###Trigger It is a condition or a collection of conditions that must be met to fire an action associated with an experience. For example: - Enter place, - Exit place, - Enter zone, - Exit zone, - Enter beacon range with given proximity, - Exit beacon range, - Custom trigger (implemented as app-provided delegate callback) ###Action Describes an activity to be performed when experience trigger conditions are met. The SDK supports the following actions: - Show local push notification with a specific message - Play sound with a specific file name (included in app bundle) - Play video from URL - Show image from URL - Show HTML content from URL - Open custom URL - Show PassBook card - Custom action (implemented as app-provided delegate callback)
{"_id":"55a940485d3abb0d0012f1af","body":"You may implement MOCAProximityService.EventListener to handle proximity events:\n\n1 - Add the listener class to MOCA:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"MOCAProximityService proxService = MOCA.getProximityService();\\nif (proxService != null) {\\n  proxService.setEventListener(this);\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n2 - Implement the methods.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"/**\\n* This listener defines the callback methods to respond to\\n* proximity-related events.\\n*/  \\npublic interface EventListener {\\n  public void didEnterRange(MOCABeacon beacon, MOCAProximity proximity);\\n  public void didExitRange(MOCABeacon beacon);\\n  public void didBeaconProximityChange(MOCABeacon beacon, MOCAProximity prevProximity, MOCAProximity curProximity);\\n  public void didEnterPlace(MOCAPlace place);\\n  public void didExitPlace(MOCAPlace place);\\n  public void didEnterZone(MOCAZone zone);\\n  public void didExitZone(MOCAZone zone);\\n  public boolean handleCustomTrigger(String customAttribute);\\n  public void didLoadedBeaconsData(List<MOCABeacon> beacons);        \\n} \\n\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Important\",\n  \"body\": \"Please note that implementing this interface is **completely optional** , MOCA SDK will take care of detecting beacons, geofences and showing experiences on top of your App UI without having to implement this interface. Use this methods if you want to create custom behaviors inside your application.\",\n  \"sidebar\": true\n}\n[/block]","isReference":false,"link_url":"","slug":"proximity-events-listener","title":"Proximity Events Listener","version":"559a61d2dbcfd20d00710b3c","parentDoc":null,"project":"559a61d2dbcfd20d00710b39","__v":1,"api":{"params":[],"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":"","auth":"required"},"createdAt":"2015-07-17T17:50:00.964Z","githubsync":"","hidden":false,"order":7,"sync_unique":"","excerpt":"","link_external":false,"category":"55a93098cf45e1390093f351","type":"basic","updates":[],"user":"559a618bdbcfd20d00710b38","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Proximity Events Listener


You may implement MOCAProximityService.EventListener to handle proximity events: 1 - Add the listener class to MOCA: [block:code] { "codes": [ { "code": "MOCAProximityService proxService = MOCA.getProximityService();\nif (proxService != null) {\n proxService.setEventListener(this);\n}", "language": "java" } ] } [/block] 2 - Implement the methods. [block:code] { "codes": [ { "code": "/**\n* This listener defines the callback methods to respond to\n* proximity-related events.\n*/ \npublic interface EventListener {\n public void didEnterRange(MOCABeacon beacon, MOCAProximity proximity);\n public void didExitRange(MOCABeacon beacon);\n public void didBeaconProximityChange(MOCABeacon beacon, MOCAProximity prevProximity, MOCAProximity curProximity);\n public void didEnterPlace(MOCAPlace place);\n public void didExitPlace(MOCAPlace place);\n public void didEnterZone(MOCAZone zone);\n public void didExitZone(MOCAZone zone);\n public boolean handleCustomTrigger(String customAttribute);\n public void didLoadedBeaconsData(List<MOCABeacon> beacons); \n} \n", "language": "java" } ] } [/block] [block:callout] { "type": "warning", "title": "Important", "body": "Please note that implementing this interface is **completely optional** , MOCA SDK will take care of detecting beacons, geofences and showing experiences on top of your App UI without having to implement this interface. Use this methods if you want to create custom behaviors inside your application.", "sidebar": true } [/block]
You may implement MOCAProximityService.EventListener to handle proximity events: 1 - Add the listener class to MOCA: [block:code] { "codes": [ { "code": "MOCAProximityService proxService = MOCA.getProximityService();\nif (proxService != null) {\n proxService.setEventListener(this);\n}", "language": "java" } ] } [/block] 2 - Implement the methods. [block:code] { "codes": [ { "code": "/**\n* This listener defines the callback methods to respond to\n* proximity-related events.\n*/ \npublic interface EventListener {\n public void didEnterRange(MOCABeacon beacon, MOCAProximity proximity);\n public void didExitRange(MOCABeacon beacon);\n public void didBeaconProximityChange(MOCABeacon beacon, MOCAProximity prevProximity, MOCAProximity curProximity);\n public void didEnterPlace(MOCAPlace place);\n public void didExitPlace(MOCAPlace place);\n public void didEnterZone(MOCAZone zone);\n public void didExitZone(MOCAZone zone);\n public boolean handleCustomTrigger(String customAttribute);\n public void didLoadedBeaconsData(List<MOCABeacon> beacons); \n} \n", "language": "java" } ] } [/block] [block:callout] { "type": "warning", "title": "Important", "body": "Please note that implementing this interface is **completely optional** , MOCA SDK will take care of detecting beacons, geofences and showing experiences on top of your App UI without having to implement this interface. Use this methods if you want to create custom behaviors inside your application.", "sidebar": true } [/block]
{"_id":"55a9409802becf2d007aac64","order":8,"slug":"proximity-actions-listener","sync_unique":"","type":"basic","user":"559a618bdbcfd20d00710b38","__v":7,"isReference":false,"category":"55a93098cf45e1390093f351","link_external":false,"link_url":"","project":"559a61d2dbcfd20d00710b39","api":{"auth":"required","params":[],"results":{"codes":[{"name":"","status":200,"language":"json","code":"{}"},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"title":"Proximity Actions Listener","updates":[],"version":"559a61d2dbcfd20d00710b3c","excerpt":"","hidden":false,"githubsync":"","parentDoc":null,"body":"You may also customize actions using `MOCAProximityService.ActionListener`:\n\n1 - Add the listener to MOCA:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"MOCAProximityService proxService = MOCA.getProximityService();\\nif (proxService != null) {\\n\\tproxService.setActionListener(this);\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Important\",\n  \"body\": \"If you implement this interface within an Activity, your actions won't be always executed in background. If you **always** want to listen to this actions, even in background, ensure you implement this in a class that inherits from **Application** (the same where you initialize MOCA SDK).\"\n}\n[/block]\n1 - Implement the methods:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"/**       \\n* This listener defines the callback methods to respond to       \\n* proximity-invoked actions.       \\n*/      \\npublic interface ActionListener {\\n\\n   boolean displayNotificationAlert(String alertMessage);\\n   boolean openUrl(URL url);   \\n   boolean showHtmlWithString (String html);   \\n   boolean playVideoFromUrl(URL url);   \\n   boolean displayImageFromUrl(URL url); \\n   boolean displayPassFromUrl(URL url);  \\n   boolean addTag(String tagName, String value);\\n   boolean playNotificationSound(String soundFilename);\\n//return true if you want to track this action in MOCA Campaign Analytics\\n   boolean performCustomAction(String customAttribute);         \\n\\n}\\n \\n\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"body\": \"By implementing this interface, you will be notified when an experience is about to be shown to the user. If the method returns `true`, MOCA assumes you have completely handled the behavior, so **no further action will be performed**. Return `false` if you want to be notified about the experience, but still want MOCA to execute the default behavior.\",\n  \"title\": \"\",\n  \"sidebar\": true\n}\n[/block]","createdAt":"2015-07-17T17:51:20.498Z","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Proximity Actions Listener


You may also customize actions using `MOCAProximityService.ActionListener`: 1 - Add the listener to MOCA: [block:code] { "codes": [ { "code": "MOCAProximityService proxService = MOCA.getProximityService();\nif (proxService != null) {\n\tproxService.setActionListener(this);\n}", "language": "java" } ] } [/block] [block:callout] { "type": "warning", "title": "Important", "body": "If you implement this interface within an Activity, your actions won't be always executed in background. If you **always** want to listen to this actions, even in background, ensure you implement this in a class that inherits from **Application** (the same where you initialize MOCA SDK)." } [/block] 1 - Implement the methods: [block:code] { "codes": [ { "code": "/** \n* This listener defines the callback methods to respond to \n* proximity-invoked actions. \n*/ \npublic interface ActionListener {\n\n boolean displayNotificationAlert(String alertMessage);\n boolean openUrl(URL url); \n boolean showHtmlWithString (String html); \n boolean playVideoFromUrl(URL url); \n boolean displayImageFromUrl(URL url); \n boolean displayPassFromUrl(URL url); \n boolean addTag(String tagName, String value);\n boolean playNotificationSound(String soundFilename);\n//return true if you want to track this action in MOCA Campaign Analytics\n boolean performCustomAction(String customAttribute);  \n\n}\n \n", "language": "java" } ] } [/block] [block:callout] { "type": "danger", "body": "By implementing this interface, you will be notified when an experience is about to be shown to the user. If the method returns `true`, MOCA assumes you have completely handled the behavior, so **no further action will be performed**. Return `false` if you want to be notified about the experience, but still want MOCA to execute the default behavior.", "title": "", "sidebar": true } [/block]
You may also customize actions using `MOCAProximityService.ActionListener`: 1 - Add the listener to MOCA: [block:code] { "codes": [ { "code": "MOCAProximityService proxService = MOCA.getProximityService();\nif (proxService != null) {\n\tproxService.setActionListener(this);\n}", "language": "java" } ] } [/block] [block:callout] { "type": "warning", "title": "Important", "body": "If you implement this interface within an Activity, your actions won't be always executed in background. If you **always** want to listen to this actions, even in background, ensure you implement this in a class that inherits from **Application** (the same where you initialize MOCA SDK)." } [/block] 1 - Implement the methods: [block:code] { "codes": [ { "code": "/** \n* This listener defines the callback methods to respond to \n* proximity-invoked actions. \n*/ \npublic interface ActionListener {\n\n boolean displayNotificationAlert(String alertMessage);\n boolean openUrl(URL url); \n boolean showHtmlWithString (String html); \n boolean playVideoFromUrl(URL url); \n boolean displayImageFromUrl(URL url); \n boolean displayPassFromUrl(URL url); \n boolean addTag(String tagName, String value);\n boolean playNotificationSound(String soundFilename);\n//return true if you want to track this action in MOCA Campaign Analytics\n boolean performCustomAction(String customAttribute);  \n\n}\n \n", "language": "java" } ] } [/block] [block:callout] { "type": "danger", "body": "By implementing this interface, you will be notified when an experience is about to be shown to the user. If the method returns `true`, MOCA assumes you have completely handled the behavior, so **no further action will be performed**. Return `false` if you want to be notified about the experience, but still want MOCA to execute the default behavior.", "title": "", "sidebar": true } [/block]
{"_id":"55a9410c5d3abb0d0012f1b4","title":"Design considerations","type":"basic","api":{"auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"language":"json","code":"{}","name":"","status":400}]},"settings":"","url":""},"link_external":false,"slug":"design-considerations-1","user":"559a618bdbcfd20d00710b38","version":"559a61d2dbcfd20d00710b3c","hidden":false,"order":9,"sync_unique":"","updates":[],"body":"##Location service authorization\n- By default, MOCA tracks user location and proximity interactions\n- The geo-location is tracked with 100-meter precision. \n- This is performed by means of Google Play Services Locations API\n- The user must allow the location tracking for the device\n- The geo-location minimizes battery usage by employing adaptive tracking\n- When the permission is not granted, MOCA does not track user location.\n\n##How event tracking works\n- MOCA SDK uses SQLite database stored in a local file on your phone to store all locally tracked events.\n- Periodically, when your device is connected to Internet (via Edge, 3G, LTE or Wifi), \u000bthe SDK incrementally transfers the packs of events to the cloud.\n- The local database is freed only when the transfer is successful (Store-And-Forward)\n- By default, the event transfer is performed every 15 minutes\n\n##Offline behavior\n- MOCA SDK downloads proximity campaigns data from the cloud asynchronously using \u000bperiodic asynchronous background fetch mechanism. \n- The frequency is controlled by SDK but can also be tuned by the app.\n- The downloaded data is persisted locally and acts as a cache.\n- If the connection to Internet is not available, the cached data is used to run the campaigns.\n- This enables you to offer proximity experiences even if the Internet connection is saturated or not available.","parentDoc":null,"githubsync":"","isReference":false,"link_url":"","project":"559a61d2dbcfd20d00710b39","__v":3,"category":"55a93098cf45e1390093f351","createdAt":"2015-07-17T17:53:16.944Z","excerpt":"","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Design considerations


##Location service authorization - By default, MOCA tracks user location and proximity interactions - The geo-location is tracked with 100-meter precision. - This is performed by means of Google Play Services Locations API - The user must allow the location tracking for the device - The geo-location minimizes battery usage by employing adaptive tracking - When the permission is not granted, MOCA does not track user location. ##How event tracking works - MOCA SDK uses SQLite database stored in a local file on your phone to store all locally tracked events. - Periodically, when your device is connected to Internet (via Edge, 3G, LTE or Wifi), the SDK incrementally transfers the packs of events to the cloud. - The local database is freed only when the transfer is successful (Store-And-Forward) - By default, the event transfer is performed every 15 minutes ##Offline behavior - MOCA SDK downloads proximity campaigns data from the cloud asynchronously using periodic asynchronous background fetch mechanism. - The frequency is controlled by SDK but can also be tuned by the app. - The downloaded data is persisted locally and acts as a cache. - If the connection to Internet is not available, the cached data is used to run the campaigns. - This enables you to offer proximity experiences even if the Internet connection is saturated or not available.
##Location service authorization - By default, MOCA tracks user location and proximity interactions - The geo-location is tracked with 100-meter precision. - This is performed by means of Google Play Services Locations API - The user must allow the location tracking for the device - The geo-location minimizes battery usage by employing adaptive tracking - When the permission is not granted, MOCA does not track user location. ##How event tracking works - MOCA SDK uses SQLite database stored in a local file on your phone to store all locally tracked events. - Periodically, when your device is connected to Internet (via Edge, 3G, LTE or Wifi), the SDK incrementally transfers the packs of events to the cloud. - The local database is freed only when the transfer is successful (Store-And-Forward) - By default, the event transfer is performed every 15 minutes ##Offline behavior - MOCA SDK downloads proximity campaigns data from the cloud asynchronously using periodic asynchronous background fetch mechanism. - The frequency is controlled by SDK but can also be tuned by the app. - The downloaded data is persisted locally and acts as a cache. - If the connection to Internet is not available, the cached data is used to run the campaigns. - This enables you to offer proximity experiences even if the Internet connection is saturated or not available.
{"_id":"55a58a500f354f0d00fd0313","api":{"auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"createdAt":"2015-07-14T22:16:48.027Z","excerpt":"","isReference":false,"link_external":false,"type":"basic","updates":[],"__v":17,"title":"Getting Started","link_url":"","body":"The MOCA API can be used to automate beacon fleet management, connect your CRM data, built custom functionalities, and query analytics reports. Through MOCA REST API, you can integrate third-party systems and access raw data. It enables the inclusion of maps and analysis of mobile users’ flow indoors and outdoors.\n\nThe MOCA API is organized around REST. The API lets you interact with MOCA Platform from anything that can send an HTTP request. Our API is designed to have predictable, resource-oriented URLs and to use HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which can be understood by off-the-shelf HTTP clients, and we support cross-origin resource sharing to allow you to interact securely with our API from a client-side web application (though you should remember that you should never expose your secret API key in any public website's client-side code). JSON will be returned in all responses from the API, including errors.\n\nThere are many things you can do with the REST API. For example:\n* Register new mobile app\n* Manage fleet of beacons\n* Automatically register all your places (i.e. physical locations)\n* Create audience segments\n* Program marketing campaigns targeted to selected segments\n* Send push notifications\n* Query analytics data \n* Query user profiles\n* Export raw data\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"SSL only\"\n}\n[/block]\nWe require that all requests are done over SSL. Calls made over plain HTTP will fail. You must authenticate for all requests.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"UTF-8 encoding\"\n}\n[/block]\nEvery string passed to and from the MOCA API needs to be UTF-8 encoded. For maximum compatibility, normalize to [Unicode Normalization Form C (NFC)](http://unicode.org/reports/tr15/) before UTF-8 encoding.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Date & time format\"\n}\n[/block]\nAll dates and times in the API are 64-big long integer that encode number of milliseconds since midnight, January 1, 1970 UTC.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Making a request\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"The MOCA REST API is accessed from the URL `https://api.mocaplatform.com/v1/`. The path is prefixed with the API version which is currently *`v1`*.\"\n}\n[/block]\nTo send a new request, you must include a `User-Agent` header, `Content-Type` header and JSON payload.\t\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"You must include a User-Agent header with name of your client application. If you don't supply this header, you will get a 400 Bad Request.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"HTTP verbs\"\n}\n[/block]\nWhere possible, API v1 strives to use appropriate HTTP verbs for each action.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Verb\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"GET\",\n    \"1-0\": \"POST\",\n    \"2-0\": \"PUT\",\n    \"3-0\": \"DELETE\",\n    \"3-1\": \"Used for deleting resources.\",\n    \"2-1\": \"Used for replacing resources or collections. For PUT requests with no body attribute, be sure to set the Content-Length header to zero.\",\n    \"1-1\": \"Used for creating resources.\",\n    \"0-1\": \"Used for retrieving resources.\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Error handling\"\n}\n[/block]\nMOCA uses conventional HTTP response codes to indicate success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that resulted from the caller provided information (e.g. a required parameter was missing, a charge failed, etc.), and codes in the 5xx range indicate an error with MOCA's servers.\n\nErrors are returned using standard HTTP error code syntax. Any additional info is included in the body of the return call, JSON-formatted. See [complete list of error codes](moca-rest-api-error-handling).\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Authentication\"\n}\n[/block]\nMOCA supports [OAuth 2.0](http://oauth.net/) for authenticating all API requests. Find out more in the [Authentication](moca-rest-api-authentication) guide.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Pagination\"\n}\n[/block]\nAll top-level MOCA API resources have support for bulk fetches — \"list\" API methods. For instance you can *List Apps*, *List Beacons*, and *List Experiences*. These list API methods share a common structure.\n\nMOCA utilizes cursor-based pagination, using the parameters `firstResult` and `maxResults`.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Argument\",\n    \"h-1\": \"Optional?\",\n    \"h-2\": \"Data type\",\n    \"h-3\": \"Description\",\n    \"0-0\": \"firstResult\",\n    \"0-3\": \"the sequential index of the first object to return.\",\n    \"0-1\": \"YES\",\n    \"0-2\": \"integer\",\n    \"1-0\": \"maxResults\",\n    \"1-1\": \"YES\",\n    \"1-2\": \"integer\",\n    \"1-3\": \"the maximum number of objects to retrieve.\"\n  },\n  \"cols\": 4,\n  \"rows\": 2\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Response headers\"\n}\n[/block]\nEach API response has an associated header automatically generated by MOCA servers.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Header name\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"X-Server-Timestamp\",\n    \"0-1\": \"UTC timestamp generated by the server when generating this response.\",\n    \"1-0\": \"X-Api-Version\",\n    \"1-1\": \"REST API version number\",\n    \"2-0\": \"Server\",\n    \"2-1\": \"Name of the server that generated the response.\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]","category":"55afb260902fd51700f5f8c2","hidden":false,"order":0,"parentDoc":null,"project":"559a61d2dbcfd20d00710b39","sync_unique":"","slug":"moca-rest-api-getting-started","user":"55a575ebaaf9cf1900114d73","version":"559a61d2dbcfd20d00710b3c","githubsync":"","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Getting Started


The MOCA API can be used to automate beacon fleet management, connect your CRM data, built custom functionalities, and query analytics reports. Through MOCA REST API, you can integrate third-party systems and access raw data. It enables the inclusion of maps and analysis of mobile users’ flow indoors and outdoors. The MOCA API is organized around REST. The API lets you interact with MOCA Platform from anything that can send an HTTP request. Our API is designed to have predictable, resource-oriented URLs and to use HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which can be understood by off-the-shelf HTTP clients, and we support cross-origin resource sharing to allow you to interact securely with our API from a client-side web application (though you should remember that you should never expose your secret API key in any public website's client-side code). JSON will be returned in all responses from the API, including errors. There are many things you can do with the REST API. For example: * Register new mobile app * Manage fleet of beacons * Automatically register all your places (i.e. physical locations) * Create audience segments * Program marketing campaigns targeted to selected segments * Send push notifications * Query analytics data * Query user profiles * Export raw data [block:api-header] { "type": "basic", "title": "SSL only" } [/block] We require that all requests are done over SSL. Calls made over plain HTTP will fail. You must authenticate for all requests. [block:api-header] { "type": "basic", "title": "UTF-8 encoding" } [/block] Every string passed to and from the MOCA API needs to be UTF-8 encoded. For maximum compatibility, normalize to [Unicode Normalization Form C (NFC)](http://unicode.org/reports/tr15/) before UTF-8 encoding. [block:api-header] { "type": "basic", "title": "Date & time format" } [/block] All dates and times in the API are 64-big long integer that encode number of milliseconds since midnight, January 1, 1970 UTC. [block:api-header] { "type": "basic", "title": "Making a request" } [/block] [block:callout] { "type": "info", "body": "The MOCA REST API is accessed from the URL `https://api.mocaplatform.com/v1/`. The path is prefixed with the API version which is currently *`v1`*." } [/block] To send a new request, you must include a `User-Agent` header, `Content-Type` header and JSON payload. [block:callout] { "type": "warning", "body": "You must include a User-Agent header with name of your client application. If you don't supply this header, you will get a 400 Bad Request." } [/block] [block:api-header] { "type": "basic", "title": "HTTP verbs" } [/block] Where possible, API v1 strives to use appropriate HTTP verbs for each action. [block:parameters] { "data": { "h-0": "Verb", "h-1": "Description", "0-0": "GET", "1-0": "POST", "2-0": "PUT", "3-0": "DELETE", "3-1": "Used for deleting resources.", "2-1": "Used for replacing resources or collections. For PUT requests with no body attribute, be sure to set the Content-Length header to zero.", "1-1": "Used for creating resources.", "0-1": "Used for retrieving resources." }, "cols": 2, "rows": 4 } [/block] [block:api-header] { "type": "basic", "title": "Error handling" } [/block] MOCA uses conventional HTTP response codes to indicate success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that resulted from the caller provided information (e.g. a required parameter was missing, a charge failed, etc.), and codes in the 5xx range indicate an error with MOCA's servers. Errors are returned using standard HTTP error code syntax. Any additional info is included in the body of the return call, JSON-formatted. See [complete list of error codes](moca-rest-api-error-handling). [block:api-header] { "type": "basic", "title": "Authentication" } [/block] MOCA supports [OAuth 2.0](http://oauth.net/) for authenticating all API requests. Find out more in the [Authentication](moca-rest-api-authentication) guide. [block:api-header] { "type": "basic", "title": "Pagination" } [/block] All top-level MOCA API resources have support for bulk fetches — "list" API methods. For instance you can *List Apps*, *List Beacons*, and *List Experiences*. These list API methods share a common structure. MOCA utilizes cursor-based pagination, using the parameters `firstResult` and `maxResults`. [block:parameters] { "data": { "h-0": "Argument", "h-1": "Optional?", "h-2": "Data type", "h-3": "Description", "0-0": "firstResult", "0-3": "the sequential index of the first object to return.", "0-1": "YES", "0-2": "integer", "1-0": "maxResults", "1-1": "YES", "1-2": "integer", "1-3": "the maximum number of objects to retrieve." }, "cols": 4, "rows": 2 } [/block] [block:api-header] { "type": "basic", "title": "Response headers" } [/block] Each API response has an associated header automatically generated by MOCA servers. [block:parameters] { "data": { "h-0": "Header name", "h-1": "Description", "0-0": "X-Server-Timestamp", "0-1": "UTC timestamp generated by the server when generating this response.", "1-0": "X-Api-Version", "1-1": "REST API version number", "2-0": "Server", "2-1": "Name of the server that generated the response." }, "cols": 2, "rows": 3 } [/block]
The MOCA API can be used to automate beacon fleet management, connect your CRM data, built custom functionalities, and query analytics reports. Through MOCA REST API, you can integrate third-party systems and access raw data. It enables the inclusion of maps and analysis of mobile users’ flow indoors and outdoors. The MOCA API is organized around REST. The API lets you interact with MOCA Platform from anything that can send an HTTP request. Our API is designed to have predictable, resource-oriented URLs and to use HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which can be understood by off-the-shelf HTTP clients, and we support cross-origin resource sharing to allow you to interact securely with our API from a client-side web application (though you should remember that you should never expose your secret API key in any public website's client-side code). JSON will be returned in all responses from the API, including errors. There are many things you can do with the REST API. For example: * Register new mobile app * Manage fleet of beacons * Automatically register all your places (i.e. physical locations) * Create audience segments * Program marketing campaigns targeted to selected segments * Send push notifications * Query analytics data * Query user profiles * Export raw data [block:api-header] { "type": "basic", "title": "SSL only" } [/block] We require that all requests are done over SSL. Calls made over plain HTTP will fail. You must authenticate for all requests. [block:api-header] { "type": "basic", "title": "UTF-8 encoding" } [/block] Every string passed to and from the MOCA API needs to be UTF-8 encoded. For maximum compatibility, normalize to [Unicode Normalization Form C (NFC)](http://unicode.org/reports/tr15/) before UTF-8 encoding. [block:api-header] { "type": "basic", "title": "Date & time format" } [/block] All dates and times in the API are 64-big long integer that encode number of milliseconds since midnight, January 1, 1970 UTC. [block:api-header] { "type": "basic", "title": "Making a request" } [/block] [block:callout] { "type": "info", "body": "The MOCA REST API is accessed from the URL `https://api.mocaplatform.com/v1/`. The path is prefixed with the API version which is currently *`v1`*." } [/block] To send a new request, you must include a `User-Agent` header, `Content-Type` header and JSON payload. [block:callout] { "type": "warning", "body": "You must include a User-Agent header with name of your client application. If you don't supply this header, you will get a 400 Bad Request." } [/block] [block:api-header] { "type": "basic", "title": "HTTP verbs" } [/block] Where possible, API v1 strives to use appropriate HTTP verbs for each action. [block:parameters] { "data": { "h-0": "Verb", "h-1": "Description", "0-0": "GET", "1-0": "POST", "2-0": "PUT", "3-0": "DELETE", "3-1": "Used for deleting resources.", "2-1": "Used for replacing resources or collections. For PUT requests with no body attribute, be sure to set the Content-Length header to zero.", "1-1": "Used for creating resources.", "0-1": "Used for retrieving resources." }, "cols": 2, "rows": 4 } [/block] [block:api-header] { "type": "basic", "title": "Error handling" } [/block] MOCA uses conventional HTTP response codes to indicate success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that resulted from the caller provided information (e.g. a required parameter was missing, a charge failed, etc.), and codes in the 5xx range indicate an error with MOCA's servers. Errors are returned using standard HTTP error code syntax. Any additional info is included in the body of the return call, JSON-formatted. See [complete list of error codes](moca-rest-api-error-handling). [block:api-header] { "type": "basic", "title": "Authentication" } [/block] MOCA supports [OAuth 2.0](http://oauth.net/) for authenticating all API requests. Find out more in the [Authentication](moca-rest-api-authentication) guide. [block:api-header] { "type": "basic", "title": "Pagination" } [/block] All top-level MOCA API resources have support for bulk fetches — "list" API methods. For instance you can *List Apps*, *List Beacons*, and *List Experiences*. These list API methods share a common structure. MOCA utilizes cursor-based pagination, using the parameters `firstResult` and `maxResults`. [block:parameters] { "data": { "h-0": "Argument", "h-1": "Optional?", "h-2": "Data type", "h-3": "Description", "0-0": "firstResult", "0-3": "the sequential index of the first object to return.", "0-1": "YES", "0-2": "integer", "1-0": "maxResults", "1-1": "YES", "1-2": "integer", "1-3": "the maximum number of objects to retrieve." }, "cols": 4, "rows": 2 } [/block] [block:api-header] { "type": "basic", "title": "Response headers" } [/block] Each API response has an associated header automatically generated by MOCA servers. [block:parameters] { "data": { "h-0": "Header name", "h-1": "Description", "0-0": "X-Server-Timestamp", "0-1": "UTC timestamp generated by the server when generating this response.", "1-0": "X-Api-Version", "1-1": "REST API version number", "2-0": "Server", "2-1": "Name of the server that generated the response." }, "cols": 2, "rows": 3 } [/block]
{"_id":"55a58ae5aaf9cf1900114dd5","body":"All API access is over HTTPS, and accessed via the *https://api.mocaplatform.com* domain. The relative path prefix /v1/ indicates that we are currently using version 1 of the API.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Objects\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"URL\",\n    \"h-1\": \"HTTP Verb\",\n    \"h-2\": \"Functionality\",\n    \"0-0\": \"/v1/beacons\",\n    \"0-1\": \"GET\",\n    \"0-2\": \"Retrieving Beacons\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]","excerpt":"This reference documentation is designed for those interested in developing for platforms not supported by the SDKs or for those interested in exploring API features in detail.","githubsync":"","isReference":false,"project":"559a61d2dbcfd20d00710b39","slug":"quick-reference","title":"Quick Reference","type":"basic","version":"559a61d2dbcfd20d00710b3c","createdAt":"2015-07-14T22:19:17.009Z","link_url":"","parentDoc":null,"sync_unique":"","__v":1,"api":{"results":{"codes":[{"language":"json","code":"{}","name":"","status":200},{"code":"{}","name":"","status":400,"language":"json"}]},"settings":"","url":"","auth":"required","params":[]},"hidden":false,"link_external":false,"updates":[],"category":"55afb260902fd51700f5f8c2","order":1,"user":"55a575ebaaf9cf1900114d73","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Quick Reference

This reference documentation is designed for those interested in developing for platforms not supported by the SDKs or for those interested in exploring API features in detail.

All API access is over HTTPS, and accessed via the *https://api.mocaplatform.com* domain. The relative path prefix /v1/ indicates that we are currently using version 1 of the API. [block:api-header] { "type": "basic", "title": "Objects" } [/block] [block:parameters] { "data": { "h-0": "URL", "h-1": "HTTP Verb", "h-2": "Functionality", "0-0": "/v1/beacons", "0-1": "GET", "0-2": "Retrieving Beacons" }, "cols": 3, "rows": 1 } [/block]
All API access is over HTTPS, and accessed via the *https://api.mocaplatform.com* domain. The relative path prefix /v1/ indicates that we are currently using version 1 of the API. [block:api-header] { "type": "basic", "title": "Objects" } [/block] [block:parameters] { "data": { "h-0": "URL", "h-1": "HTTP Verb", "h-2": "Functionality", "0-0": "/v1/beacons", "0-1": "GET", "0-2": "Retrieving Beacons" }, "cols": 3, "rows": 1 } [/block]
{"_id":"55a5924d0f354f0d00fd034c","project":"559a61d2dbcfd20d00710b39","version":"559a61d2dbcfd20d00710b3c","api":{"settings":"","url":"","auth":"required","params":[],"results":{"codes":[{"code":"{}","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{}","name":""}]}},"excerpt":"","hidden":false,"order":2,"__v":1,"title":"Authentication","updates":[],"sync_unique":"","githubsync":"","isReference":false,"link_external":false,"link_url":"","parentDoc":null,"user":"55a575ebaaf9cf1900114d73","body":"","category":"55afb260902fd51700f5f8c2","createdAt":"2015-07-14T22:50:53.674Z","slug":"moca-rest-api-authentication","type":"basic","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}
{"_id":"55a58eac0f354f0d00fd0324","githubsync":"","isReference":false,"link_external":false,"slug":"moca-rest-api-error-handling","sync_unique":"","body":"[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Code\",\n    \"h-1\": \"Name\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"200\",\n    \"0-1\": \"OK\",\n    \"0-2\": \"Everything worked successfully!\",\n    \"1-0\": \"201\",\n    \"1-1\": \"Created\",\n    \"1-2\": \"When you're creating a new object, this will be returned upon success.\",\n    \"2-0\": \"400\",\n    \"2-1\": \"Bad Request\",\n    \"2-2\": \"We could not process the action due to client error.\",\n    \"3-0\": \"403\",\n    \"3-1\": \"Forbidden\",\n    \"3-2\": \"We couldn't authenticate you, or you don't have access to that resource.\",\n    \"4-0\": \"404\",\n    \"4-1\": \"Not Found\",\n    \"4-2\": \"The requested resource could not be found.\",\n    \"5-0\": \"408\",\n    \"5-1\": \"Request Timeout\",\n    \"5-2\": \"The server timed out waiting for the request. The client may repeat the request without modifications at any later time.\",\n    \"7-0\": \"415\",\n    \"7-1\": \"Unsupported Media Type\",\n    \"7-2\": \"The request entity has a media type which the server or resource does not support.\",\n    \"8-0\": \"500\",\n    \"8-1\": \"Internal Server Error\",\n    \"8-2\": \"Ooops! Something went wrong in MOCA Backend. The team will look into it.\",\n    \"9-0\": \"503\",\n    \"9-1\": \"Service Unavailable\",\n    \"9-2\": \"The service is currently unavailable because it is overloaded or down for maintenance.\",\n    \"6-0\": \"409\",\n    \"6-1\": \"Conflict\",\n    \"6-2\": \"The request could not be processed because of a conflict in the request.\"\n  },\n  \"cols\": 3,\n  \"rows\": 10\n}\n[/block]\nOur API libraries can raise exceptions for many reasons, such as a failed charge, invalid parameters, authentication errors, and network unavailability. We recommend always trying to gracefully handle exceptions from our API.","link_url":"","order":3,"title":"Error Handling","updates":[],"api":{"auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"code":"{}","name":"","status":400,"language":"json"}]},"settings":"","url":""},"category":"55afb260902fd51700f5f8c2","createdAt":"2015-07-14T22:35:24.198Z","excerpt":"The following is a list of response status code MOCA REST API may return.","hidden":false,"user":"55a575ebaaf9cf1900114d73","__v":6,"parentDoc":null,"project":"559a61d2dbcfd20d00710b39","type":"basic","version":"559a61d2dbcfd20d00710b3c","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Error Handling

The following is a list of response status code MOCA REST API may return.

[block:parameters] { "data": { "h-0": "Code", "h-1": "Name", "h-2": "Description", "0-0": "200", "0-1": "OK", "0-2": "Everything worked successfully!", "1-0": "201", "1-1": "Created", "1-2": "When you're creating a new object, this will be returned upon success.", "2-0": "400", "2-1": "Bad Request", "2-2": "We could not process the action due to client error.", "3-0": "403", "3-1": "Forbidden", "3-2": "We couldn't authenticate you, or you don't have access to that resource.", "4-0": "404", "4-1": "Not Found", "4-2": "The requested resource could not be found.", "5-0": "408", "5-1": "Request Timeout", "5-2": "The server timed out waiting for the request. The client may repeat the request without modifications at any later time.", "7-0": "415", "7-1": "Unsupported Media Type", "7-2": "The request entity has a media type which the server or resource does not support.", "8-0": "500", "8-1": "Internal Server Error", "8-2": "Ooops! Something went wrong in MOCA Backend. The team will look into it.", "9-0": "503", "9-1": "Service Unavailable", "9-2": "The service is currently unavailable because it is overloaded or down for maintenance.", "6-0": "409", "6-1": "Conflict", "6-2": "The request could not be processed because of a conflict in the request." }, "cols": 3, "rows": 10 } [/block] Our API libraries can raise exceptions for many reasons, such as a failed charge, invalid parameters, authentication errors, and network unavailability. We recommend always trying to gracefully handle exceptions from our API.
[block:parameters] { "data": { "h-0": "Code", "h-1": "Name", "h-2": "Description", "0-0": "200", "0-1": "OK", "0-2": "Everything worked successfully!", "1-0": "201", "1-1": "Created", "1-2": "When you're creating a new object, this will be returned upon success.", "2-0": "400", "2-1": "Bad Request", "2-2": "We could not process the action due to client error.", "3-0": "403", "3-1": "Forbidden", "3-2": "We couldn't authenticate you, or you don't have access to that resource.", "4-0": "404", "4-1": "Not Found", "4-2": "The requested resource could not be found.", "5-0": "408", "5-1": "Request Timeout", "5-2": "The server timed out waiting for the request. The client may repeat the request without modifications at any later time.", "7-0": "415", "7-1": "Unsupported Media Type", "7-2": "The request entity has a media type which the server or resource does not support.", "8-0": "500", "8-1": "Internal Server Error", "8-2": "Ooops! Something went wrong in MOCA Backend. The team will look into it.", "9-0": "503", "9-1": "Service Unavailable", "9-2": "The service is currently unavailable because it is overloaded or down for maintenance.", "6-0": "409", "6-1": "Conflict", "6-2": "The request could not be processed because of a conflict in the request." }, "cols": 3, "rows": 10 } [/block] Our API libraries can raise exceptions for many reasons, such as a failed charge, invalid parameters, authentication errors, and network unavailability. We recommend always trying to gracefully handle exceptions from our API.
{"_id":"55bb4450a8400c2d00873dd9","__v":24,"hidden":false,"parentDoc":null,"slug":"installation","sync_unique":"","type":"basic","updates":[],"body":"This plugin supports **PhoneGap/Cordova** apps running on iOS and Android.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Version requirements\"\n}\n[/block]\nThis plugin is meant to work with Cordova 3.4.0+ and the latest versions of the MOCA SDK libraries.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Installation\"\n}\n[/block]\nAutomatic installation using PhoneGap/Cordova CLI (iOS and Android)\n\n1. For iOS, make sure you update your iOS project to Cordova iOS version 3.4.1 or newer before installing this plugin.\n\n  ````\n    cordova platform add ios\n  ````\n  \n2. For Android, make sure the Android SDK is up to date. Google Play Services 7.5+ is required (8.5+ for Remote Push Notifications through Google Cloud Messaging).\n\n  ````\n    cordova platform add android\n  ````\n   \n3. Install this plugin using PhoneGap/Cordova cli:\n\n   ````\n    cordova plugin add https://github.com/mocaplatform/moca-phonegap-sdk.git#:/MOCASDK\n   ````\n   \n4. Modify the config.xml directory to contain (replacing with your configuration settings):\n   \n   ````\n   <!-- MOCA SDK credentials -->\n   <preference name=\"moca_app_key\" value=\"YOUR_APP_KEY\" />\n   <preference name=\"moca_app_secret\" value=\"YOUR-APP-SECRET\" />\n   <preference name=\"gcm_sender\" value=\"\\ YOUR_GCM_SENDER\" />\n    <platform name=\"android\">\n    ...\n        <preference name=\"android-minSdkVersion\" value=\"14\" />\n        <preference name=\"android-targetSdkVersion\" value=\"23\" />\n    ...\n    </platform>\n   ````\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"NOTE\",\n  \"body\": \"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]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Android - Caveats\"\n}\n[/block]\n##Permissions in Android 6+\n\nStarting with Android Marshmallow (6.0), some permissions must be requested at runtime, rather than at install time. For the MOCA SDK, this means that you need to ask to the user for the 'ACCESS_FINE_LOCATION' permission when the App is executed for the first time. Otherwise, neither beacons nor geofences will be detected.\n\nYou can use a 3rd party plugin to do this, such as [this one](https://www.npmjs.com/package/cordova-plugin-android-permissions).\n\nAfter the permission is granted, you can manually start the affected services by calling:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"MOCA.setGeoTrackingEnabled(true, callback);\\nMOCA.setProximityEnabled(true, callback);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nBelow you will find a working code sample of this integration, notice the `requestMocaPermissions` and `startProximityServices` methods. And how `requestMocaPermissions` is called in `onDeviceReady`.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var app = {\\n    // Application Constructor\\n    initialize: function() {\\n        this.bindEvents();\\n    },\\n    // Bind Event Listeners\\n    //\\n    // Bind any events that are required on startup. Common events are:\\n    // 'load', 'deviceready', 'offline', and 'online'.\\n    bindEvents: function() {\\n        document.addEventListener('deviceready', this.onDeviceReady, false);\\n    },\\n    // deviceready Event Handler\\n    //\\n    // The scope of 'this' is the event. In order to call the 'receivedEvent'\\n    // function, we must explicitly call 'app.receivedEvent(...);'\\n    onDeviceReady: function() {\\n        app.receivedEvent('deviceready');\\n      \\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\\n      \\n        /*Request permissions at RunTime*/\\n        app.requestMocaPermissions();\\n    },\\n    requestMocaPermissions: function(){\\n        var permissions = cordova.plugins.permissions;\\n        var onError = function(e) {\\n            console.error(error, e);\\n        };\\n        var onRequestPermissionResult = function(permStatus){\\n            permStatus.hasPermission? app.startProximityServices(): console.warn(\\\"Location Permission denied\\\");  \\n        };\\n        var onPermissionStatus = function(permStatus) {\\n            if(!permStatus.hasPermission){\\n                permissions.requestPermission(permissions.ACCESS_FINE_LOCATION, onRequestPermissionResult, onError);\\n            }\\n            else {\\n               app.startProximityServices();\\n            }\\n        };\\n        permissions.hasPermission(permissions.ACCESS_FINE_LOCATION, onPermissionStatus, onError);\\n    },\\n    startProximityServices: function() {\\n        MOCA.setProximityEnabled(true);\\n        MOCA.setGeoTrackingEnabled(true);\\n    },\\n  \\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\\n\\n    // Update DOM on a Received Event\\n    receivedEvent: function(id) {\\n        var parentElement = document.getElementById(id);\\n        var listeningElement = parentElement.querySelector('.listening');\\n        var receivedElement = parentElement.querySelector('.received');\\n\\n        listeningElement.setAttribute('style', 'display:none;');\\n        receivedElement.setAttribute('style', 'display:block;');\\n\\n        console.log('Received Event: ' + id);\\n    }\\n};\",\n      \"language\": \"javascript\",\n      \"name\": \"Permissions Sample\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"iOS - Caveats\"\n}\n[/block]\n##App Transport Security\n\nIn order to receive experiences served through non-secured connections, [please configure *App Transport Security* ](http://developer.mocaplatform.com/docs/moca-ios-sdk-configuration#section-app-transport-security) properly within the Xcode project,\n\n##Customizing text when requesting Location Permission\n\nYou may want to modify the message shown to the user when prompting for location permission. In order to do so, open the `YourAppName-Info.plist` file and edit the `NSLocationAlwaysUsageDescription` key.","category":"55bb441b54f9640d006e6cf2","excerpt":"","title":"Installation","user":"559a618bdbcfd20d00710b38","api":{"auth":"required","params":[],"results":{"codes":[{"name":"","status":200,"language":"json","code":"{}"},{"language":"json","code":"{}","name":"","status":400}]},"settings":"","url":""},"githubsync":"","order":0,"version":"559a61d2dbcfd20d00710b3c","createdAt":"2015-07-31T09:48:00.282Z","isReference":false,"link_external":false,"link_url":"","project":"559a61d2dbcfd20d00710b39","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Installation


This plugin supports **PhoneGap/Cordova** apps running on iOS and Android. [block:api-header] { "type": "basic", "title": "Version requirements" } [/block] This plugin is meant to work with Cordova 3.4.0+ and the latest versions of the MOCA SDK libraries. [block:api-header] { "type": "basic", "title": "Installation" } [/block] Automatic installation using PhoneGap/Cordova CLI (iOS and Android) 1. For iOS, make sure you update your iOS project to Cordova iOS version 3.4.1 or newer before installing this plugin. ```` cordova platform add ios ```` 2. For Android, make sure the Android SDK is up to date. Google Play Services 7.5+ is required (8.5+ for Remote Push Notifications through Google Cloud Messaging). ```` cordova platform add android ```` 3. Install this plugin using PhoneGap/Cordova cli: ```` cordova plugin add https://github.com/mocaplatform/moca-phonegap-sdk.git#:/MOCASDK ```` 4. Modify the config.xml directory to contain (replacing with your configuration settings): ```` <!-- MOCA SDK credentials --> <preference name="moca_app_key" value="YOUR_APP_KEY" /> <preference name="moca_app_secret" value="YOUR-APP-SECRET" /> <preference name="gcm_sender" value="\ YOUR_GCM_SENDER" /> <platform name="android"> ... <preference name="android-minSdkVersion" value="14" /> <preference name="android-targetSdkVersion" value="23" /> ... </platform> ```` [block:callout] { "type": "danger", "title": "NOTE", "body": "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] [block:api-header] { "type": "basic", "title": "Android - Caveats" } [/block] ##Permissions in Android 6+ Starting with Android Marshmallow (6.0), some permissions must be requested at runtime, rather than at install time. For the MOCA SDK, this means that you need to ask to the user for the 'ACCESS_FINE_LOCATION' permission when the App is executed for the first time. Otherwise, neither beacons nor geofences will be detected. You can use a 3rd party plugin to do this, such as [this one](https://www.npmjs.com/package/cordova-plugin-android-permissions). After the permission is granted, you can manually start the affected services by calling: [block:code] { "codes": [ { "code": "MOCA.setGeoTrackingEnabled(true, callback);\nMOCA.setProximityEnabled(true, callback);", "language": "javascript" } ] } [/block] Below you will find a working code sample of this integration, notice the `requestMocaPermissions` and `startProximityServices` methods. And how `requestMocaPermissions` is called in `onDeviceReady`. [block:code] { "codes": [ { "code": "var app = {\n // Application Constructor\n initialize: function() {\n this.bindEvents();\n },\n // Bind Event Listeners\n //\n // Bind any events that are required on startup. Common events are:\n // 'load', 'deviceready', 'offline', and 'online'.\n bindEvents: function() {\n document.addEventListener('deviceready', this.onDeviceReady, false);\n },\n // deviceready Event Handler\n //\n // The scope of 'this' is the event. In order to call the 'receivedEvent'\n // function, we must explicitly call 'app.receivedEvent(...);'\n onDeviceReady: function() {\n app.receivedEvent('deviceready');\n \n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n \n /*Request permissions at RunTime*/\n app.requestMocaPermissions();\n },\n requestMocaPermissions: function(){\n var permissions = cordova.plugins.permissions;\n var onError = function(e) {\n console.error(error, e);\n };\n var onRequestPermissionResult = function(permStatus){\n permStatus.hasPermission? app.startProximityServices(): console.warn(\"Location Permission denied\"); \n };\n var onPermissionStatus = function(permStatus) {\n if(!permStatus.hasPermission){\n permissions.requestPermission(permissions.ACCESS_FINE_LOCATION, onRequestPermissionResult, onError);\n }\n else {\n app.startProximityServices();\n }\n };\n permissions.hasPermission(permissions.ACCESS_FINE_LOCATION, onPermissionStatus, onError);\n },\n startProximityServices: function() {\n MOCA.setProximityEnabled(true);\n MOCA.setGeoTrackingEnabled(true);\n },\n \n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\n // Update DOM on a Received Event\n receivedEvent: function(id) {\n var parentElement = document.getElementById(id);\n var listeningElement = parentElement.querySelector('.listening');\n var receivedElement = parentElement.querySelector('.received');\n\n listeningElement.setAttribute('style', 'display:none;');\n receivedElement.setAttribute('style', 'display:block;');\n\n console.log('Received Event: ' + id);\n }\n};", "language": "javascript", "name": "Permissions Sample" } ] } [/block] [block:api-header] { "type": "basic", "title": "iOS - Caveats" } [/block] ##App Transport Security In order to receive experiences served through non-secured connections, [please configure *App Transport Security* ](http://developer.mocaplatform.com/docs/moca-ios-sdk-configuration#section-app-transport-security) properly within the Xcode project, ##Customizing text when requesting Location Permission You may want to modify the message shown to the user when prompting for location permission. In order to do so, open the `YourAppName-Info.plist` file and edit the `NSLocationAlwaysUsageDescription` key.
This plugin supports **PhoneGap/Cordova** apps running on iOS and Android. [block:api-header] { "type": "basic", "title": "Version requirements" } [/block] This plugin is meant to work with Cordova 3.4.0+ and the latest versions of the MOCA SDK libraries. [block:api-header] { "type": "basic", "title": "Installation" } [/block] Automatic installation using PhoneGap/Cordova CLI (iOS and Android) 1. For iOS, make sure you update your iOS project to Cordova iOS version 3.4.1 or newer before installing this plugin. ```` cordova platform add ios ```` 2. For Android, make sure the Android SDK is up to date. Google Play Services 7.5+ is required (8.5+ for Remote Push Notifications through Google Cloud Messaging). ```` cordova platform add android ```` 3. Install this plugin using PhoneGap/Cordova cli: ```` cordova plugin add https://github.com/mocaplatform/moca-phonegap-sdk.git#:/MOCASDK ```` 4. Modify the config.xml directory to contain (replacing with your configuration settings): ```` <!-- MOCA SDK credentials --> <preference name="moca_app_key" value="YOUR_APP_KEY" /> <preference name="moca_app_secret" value="YOUR-APP-SECRET" /> <preference name="gcm_sender" value="\ YOUR_GCM_SENDER" /> <platform name="android"> ... <preference name="android-minSdkVersion" value="14" /> <preference name="android-targetSdkVersion" value="23" /> ... </platform> ```` [block:callout] { "type": "danger", "title": "NOTE", "body": "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] [block:api-header] { "type": "basic", "title": "Android - Caveats" } [/block] ##Permissions in Android 6+ Starting with Android Marshmallow (6.0), some permissions must be requested at runtime, rather than at install time. For the MOCA SDK, this means that you need to ask to the user for the 'ACCESS_FINE_LOCATION' permission when the App is executed for the first time. Otherwise, neither beacons nor geofences will be detected. You can use a 3rd party plugin to do this, such as [this one](https://www.npmjs.com/package/cordova-plugin-android-permissions). After the permission is granted, you can manually start the affected services by calling: [block:code] { "codes": [ { "code": "MOCA.setGeoTrackingEnabled(true, callback);\nMOCA.setProximityEnabled(true, callback);", "language": "javascript" } ] } [/block] Below you will find a working code sample of this integration, notice the `requestMocaPermissions` and `startProximityServices` methods. And how `requestMocaPermissions` is called in `onDeviceReady`. [block:code] { "codes": [ { "code": "var app = {\n // Application Constructor\n initialize: function() {\n this.bindEvents();\n },\n // Bind Event Listeners\n //\n // Bind any events that are required on startup. Common events are:\n // 'load', 'deviceready', 'offline', and 'online'.\n bindEvents: function() {\n document.addEventListener('deviceready', this.onDeviceReady, false);\n },\n // deviceready Event Handler\n //\n // The scope of 'this' is the event. In order to call the 'receivedEvent'\n // function, we must explicitly call 'app.receivedEvent(...);'\n onDeviceReady: function() {\n app.receivedEvent('deviceready');\n \n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n \n /*Request permissions at RunTime*/\n app.requestMocaPermissions();\n },\n requestMocaPermissions: function(){\n var permissions = cordova.plugins.permissions;\n var onError = function(e) {\n console.error(error, e);\n };\n var onRequestPermissionResult = function(permStatus){\n permStatus.hasPermission? app.startProximityServices(): console.warn(\"Location Permission denied\"); \n };\n var onPermissionStatus = function(permStatus) {\n if(!permStatus.hasPermission){\n permissions.requestPermission(permissions.ACCESS_FINE_LOCATION, onRequestPermissionResult, onError);\n }\n else {\n app.startProximityServices();\n }\n };\n permissions.hasPermission(permissions.ACCESS_FINE_LOCATION, onPermissionStatus, onError);\n },\n startProximityServices: function() {\n MOCA.setProximityEnabled(true);\n MOCA.setGeoTrackingEnabled(true);\n },\n \n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\n // Update DOM on a Received Event\n receivedEvent: function(id) {\n var parentElement = document.getElementById(id);\n var listeningElement = parentElement.querySelector('.listening');\n var receivedElement = parentElement.querySelector('.received');\n\n listeningElement.setAttribute('style', 'display:none;');\n receivedElement.setAttribute('style', 'display:block;');\n\n console.log('Received Event: ' + id);\n }\n};", "language": "javascript", "name": "Permissions Sample" } ] } [/block] [block:api-header] { "type": "basic", "title": "iOS - Caveats" } [/block] ##App Transport Security In order to receive experiences served through non-secured connections, [please configure *App Transport Security* ](http://developer.mocaplatform.com/docs/moca-ios-sdk-configuration#section-app-transport-security) properly within the Xcode project, ##Customizing text when requesting Location Permission You may want to modify the message shown to the user when prompting for location permission. In order to do so, open the `YourAppName-Info.plist` file and edit the `NSLocationAlwaysUsageDescription` key.
{"_id":"568166af30018c0d006bf7fd","title":"Configuration","api":{"auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"category":"55bb441b54f9640d006e6cf2","createdAt":"2015-12-28T16:43:27.410Z","githubsync":"","link_url":"","sync_unique":"","user":"55a61860249a40190051d941","version":"559a61d2dbcfd20d00710b3c","body":"The following are a set of required and optional configuration values you should set in your config.xml\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Key\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Default Value\",\n    \"h-3\": \"Description\",\n    \"h-4\": \"\",\n    \"0-0\": \"moca_app_key\",\n    \"0-1\": \"String (required)\",\n    \"0-3\": \"App key from MOCA Console\",\n    \"1-0\": \"moca_app_secret\",\n    \"1-1\": \"String (required)\",\n    \"1-3\": \"App secret from MOCA Console\",\n    \"2-0\": \"moca_log_level\",\n    \"2-1\": \"String\",\n    \"2-3\": \"MOCA SDK logging level:\\n* trace\\n* debug\\n* info\\n* warn\\n* error\",\n    \"2-2\": \"\\\"info\\\"\",\n    \"3-0\": \"moca_cache_disk_size_in_mb\",\n    \"3-1\": \"Integer\",\n    \"3-3\": \"Maximum local disk space available for SDK cache.\",\n    \"3-2\": \"100\",\n    \"4-0\": \"moca_automatic_push_setup_enabled\",\n    \"4-3\": \"If enabled, the SDK will automatically subscribe the app to push notification services and obtain push token.\",\n    \"4-1\": \"BOOL\",\n    \"4-2\": \"YES\",\n    \"5-0\": \"moca_proximity_service_enabled\",\n    \"5-1\": \"BOOL\",\n    \"5-2\": \"YES\",\n    \"5-3\": \"Enables or disables Bluetooth Beacon monitoring and ranging & geofence detection using *iOS Location Services*\",\n    \"6-0\": \"moca_geolocation_service_enabled\",\n    \"6-1\": \"BOOL\",\n    \"6-2\": \"YES\",\n    \"6-3\": \"Enables/disables tracking of significant changes in user location by GPS/Cellular Trilateration/Wifi.\\n\\nWhen enabled (YES), user location will be tracked when the app is in foreground. Additionally, background tracking is controlled by BACKGROUND_LOCATION_ENABLED flag. This is the default.\\n\\nWhen disabled (NO), user location will not be tracked at all (neither in foreground nor on background). However, Bluetooth beacons and geofences will still be detected if this flag is set to NO.\",\n    \"7-0\": \"moca_background_location_enabled\",\n    \"7-1\": \"BOOL\",\n    \"7-2\": \"YES\",\n    \"7-3\": \"Enables/disables location tracking when the app is in background or suspended mode.\\n\\nThis flag has no effect if GEOLOCATION_SERVICE_ENABLED is set to NO.\\n\\nBy default background location tracking is enabled.\"\n  },\n  \"cols\": 4,\n  \"rows\": 8\n}\n[/block]\nFor further app permission configuration requirements please checkout [iOS'](http://developer.mocaplatform.com/docs/moca-ios-sdk-configuration#app-capabilities) and [Android's](http://developer.mocaplatform.com/docs/moca-android-sdk-configuration#setting-app-permissions) different needs.","excerpt":"","hidden":false,"isReference":false,"order":1,"parentDoc":null,"project":"559a61d2dbcfd20d00710b39","type":"basic","updates":[],"link_external":false,"slug":"configuration","__v":4,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Configuration


The following are a set of required and optional configuration values you should set in your config.xml [block:parameters] { "data": { "h-0": "Key", "h-1": "Type", "h-2": "Default Value", "h-3": "Description", "h-4": "", "0-0": "moca_app_key", "0-1": "String (required)", "0-3": "App key from MOCA Console", "1-0": "moca_app_secret", "1-1": "String (required)", "1-3": "App secret from MOCA Console", "2-0": "moca_log_level", "2-1": "String", "2-3": "MOCA SDK logging level:\n* trace\n* debug\n* info\n* warn\n* error", "2-2": "\"info\"", "3-0": "moca_cache_disk_size_in_mb", "3-1": "Integer", "3-3": "Maximum local disk space available for SDK cache.", "3-2": "100", "4-0": "moca_automatic_push_setup_enabled", "4-3": "If enabled, the SDK will automatically subscribe the app to push notification services and obtain push token.", "4-1": "BOOL", "4-2": "YES", "5-0": "moca_proximity_service_enabled", "5-1": "BOOL", "5-2": "YES", "5-3": "Enables or disables Bluetooth Beacon monitoring and ranging & geofence detection using *iOS Location Services*", "6-0": "moca_geolocation_service_enabled", "6-1": "BOOL", "6-2": "YES", "6-3": "Enables/disables tracking of significant changes in user location by GPS/Cellular Trilateration/Wifi.\n\nWhen enabled (YES), user location will be tracked when the app is in foreground. Additionally, background tracking is controlled by BACKGROUND_LOCATION_ENABLED flag. This is the default.\n\nWhen disabled (NO), user location will not be tracked at all (neither in foreground nor on background). However, Bluetooth beacons and geofences will still be detected if this flag is set to NO.", "7-0": "moca_background_location_enabled", "7-1": "BOOL", "7-2": "YES", "7-3": "Enables/disables location tracking when the app is in background or suspended mode.\n\nThis flag has no effect if GEOLOCATION_SERVICE_ENABLED is set to NO.\n\nBy default background location tracking is enabled." }, "cols": 4, "rows": 8 } [/block] For further app permission configuration requirements please checkout [iOS'](http://developer.mocaplatform.com/docs/moca-ios-sdk-configuration#app-capabilities) and [Android's](http://developer.mocaplatform.com/docs/moca-android-sdk-configuration#setting-app-permissions) different needs.
The following are a set of required and optional configuration values you should set in your config.xml [block:parameters] { "data": { "h-0": "Key", "h-1": "Type", "h-2": "Default Value", "h-3": "Description", "h-4": "", "0-0": "moca_app_key", "0-1": "String (required)", "0-3": "App key from MOCA Console", "1-0": "moca_app_secret", "1-1": "String (required)", "1-3": "App secret from MOCA Console", "2-0": "moca_log_level", "2-1": "String", "2-3": "MOCA SDK logging level:\n* trace\n* debug\n* info\n* warn\n* error", "2-2": "\"info\"", "3-0": "moca_cache_disk_size_in_mb", "3-1": "Integer", "3-3": "Maximum local disk space available for SDK cache.", "3-2": "100", "4-0": "moca_automatic_push_setup_enabled", "4-3": "If enabled, the SDK will automatically subscribe the app to push notification services and obtain push token.", "4-1": "BOOL", "4-2": "YES", "5-0": "moca_proximity_service_enabled", "5-1": "BOOL", "5-2": "YES", "5-3": "Enables or disables Bluetooth Beacon monitoring and ranging & geofence detection using *iOS Location Services*", "6-0": "moca_geolocation_service_enabled", "6-1": "BOOL", "6-2": "YES", "6-3": "Enables/disables tracking of significant changes in user location by GPS/Cellular Trilateration/Wifi.\n\nWhen enabled (YES), user location will be tracked when the app is in foreground. Additionally, background tracking is controlled by BACKGROUND_LOCATION_ENABLED flag. This is the default.\n\nWhen disabled (NO), user location will not be tracked at all (neither in foreground nor on background). However, Bluetooth beacons and geofences will still be detected if this flag is set to NO.", "7-0": "moca_background_location_enabled", "7-1": "BOOL", "7-2": "YES", "7-3": "Enables/disables location tracking when the app is in background or suspended mode.\n\nThis flag has no effect if GEOLOCATION_SERVICE_ENABLED is set to NO.\n\nBy default background location tracking is enabled." }, "cols": 4, "rows": 8 } [/block] For further app permission configuration requirements please checkout [iOS'](http://developer.mocaplatform.com/docs/moca-ios-sdk-configuration#app-capabilities) and [Android's](http://developer.mocaplatform.com/docs/moca-android-sdk-configuration#setting-app-permissions) different needs.
{"_id":"55bb46afa8400c2d00873de6","link_external":false,"sync_unique":"","body":"The JavaScript API follows an asynchronous callback approach with hooks for events such as Enter Beacon Range, Enter Place or Display Notification Alert event. Below is a brief example of this API in use:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"/*\\n * Licensed to the Apache Software Foundation (ASF) under one\\n * or more contributor license agreements.  See the NOTICE file\\n * distributed with this work for additional information\\n * regarding copyright ownership.  The ASF licenses this file\\n * to you under the Apache License, Version 2.0 (the\\n * \\\"License\\\"); you may not use this file except in compliance\\n * with the License.  You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing,\\n * software distributed under the License is distributed on an\\n * \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\\n * KIND, either express or implied.  See the License for the\\n * specific language governing permissions and limitations\\n * under the License.\\n */\\n\\nconsole.log(\\\"App is on! Initializing stuff...\\\");\\nvar app = {\\n    // Application Constructor\\n    initialize: function () {\\n        this.bindEvents();\\n    },\\n    // Bind Event Listeners\\n    //\\n    // Bind any events that are required on startup. Common events are:\\n    // 'load', 'deviceready', 'offline', and 'online'.\\n\\n    bindEvents: function () {\\n        document.addEventListener('deviceready', this.onDeviceReady, false);\\n    },\\n    // deviceready Event Handler\\n    //\\n    // The scope of 'this' is the event. In order to call the 'receivedEvent'\\n    // function, we must explicitly call 'app.receivedEvent(...);'\\n    onDeviceReady: function () {\\n        app.receivedEvent('deviceready');\\n        MOCA.addEnterBeaconListener(onEnterBeacon);\\n        MOCA.addExitBeaconListener(onExitBeacon);\\n        MOCA.addBeaconProximityChangeListener(onBeaconProximityChange);\\n        MOCA.addEnterPlaceListener(onEnterPlace);\\n        MOCA.addExitPlaceListener(onExitPlace);\\n        MOCA.addEnterZoneListener(onEnterZone);\\n        MOCA.addExitZoneListener(onExitZone);\\n\\n        MOCA.addDisplayAlertListener(false, displayAlert);\\n        MOCA.addOpenUrlListener(false, openUrl);\\n        MOCA.addShowEmbeddedHtmlListener(false, showEmbeddedHtml);\\n        MOCA.addPlayVideoListener(false, playVideo);\\n        MOCA.addShowImageListener(false, showImage);\\n        MOCA.addAddPassbookListener(false, addPassbook);\\n        MOCA.addAddTagListener(addTag);\\n        MOCA.addPlaySoundListener(false, playSound);\\n        MOCA.addCustomActionListener(performCustomAction);\\n        MOCA.addDataReadyListener(didLoadedBeaconsData);\\n\\n\\n        getMOCAValues();\\n    },\\n    // Update DOM on a Received Event\\n    receivedEvent: function (id) {\\n        var parentElement = document.getElementById(id);\\n        var listeningElement = parentElement.querySelector('.listening');\\n        var receivedElement = parentElement.querySelector('.received');\\n\\n        listeningElement.setAttribute('style', 'display:none;');\\n        receivedElement.setAttribute('style', 'display:block;');\\n\\n        console.log('Received Event: ' + id);\\n    }\\n};\\n\\nvar getMOCAValues = function(){\\n    MOCA.placesInside(placesInside);\\n    var ver = document.getElementById(\\\"ver\\\");\\n    var appKey = document.getElementById(\\\"appKey\\\");\\n    var appSecret = document.getElementById(\\\"appSecret\\\");\\n    var logLevel = document.getElementById(\\\"logLevel\\\");\\n    MOCA.version(function(e){ ver.innerHTML = \\\"Native SDK version: <b>\\\" + e +\\\"</b>\\\"});\\n    MOCA.appKey(function(e){ appKey.innerHTML = \\\"appKey: <b>\\\" + e + \\\"</b>\\\"});\\n    MOCA.appSecret(function(e){ appSecret.innerHTML = \\\"appSecret: <b>\\\" + e + \\\"</b>\\\"});\\n    MOCA.logLevel(function(e){ logLevel.innerHTML = \\\"logLevel: <b>\\\" + e + \\\"</b>\\\"});\\n}\\n\\n//console.log = function(message) {\\n//    var logger = document.getElementById(\\\"logger\\\");\\n//    logger.innerHTML = logger.innerHTML + \\\"<li>\\\" + message + \\\"</li>\\\";\\n//};\\n\\nvar onEnterBeacon= function (e) {\\n    console.log(\\\"MOCA On Enter beacon\\\");\\n    console.log(e.detail);\\n};\\nvar onExitBeacon= function (e) {\\n    console.log(\\\"Event On exit beacon with detail \\\");\\n    console.log(e.detail);\\n};\\nvar onEnterZone = function (e) {\\n    console.log(\\\"Event On Enter Zone\\\");\\n    console.log(e.detail);\\n};\\nvar onExitZone = function (e) {\\n    console.log(\\\"Event On Exit Zone\\\");\\n    console.log(e.detail);\\n};\\nvar onBeaconProximityChange= function (e) {\\n    console.log(e);\\n    console.log(\\\"Event On Proximity change with detail \\\");\\n    console.log(e.detail);\\n};\\nvar onEnterPlace= function (e) {\\n    console.log(e);\\n    console.log(\\\"Event On enter place with detail \\\");\\n    console.log(e.detail);\\n\\n};\\nvar onExitPlace= function (e) {\\n    console.log(e);\\n    console.log(\\\"Event On exit place with detail \\\");\\n    console.log(e.detail);\\n};\\nvar performCustomAction= function (e) {\\n    console.log(\\\"Callback Perform custom action on JS \\\");\\n    console.log(e.detail);\\n};\\nvar displayAlert= function (e) {\\n    console.log(\\\"Callback display alert \\\");\\n    console.log(e.detail);\\n};\\nvar openUrl= function (e) {\\n    console.log(\\\"Callback open URL\\\");\\n    console.log(e.detail);\\n};\\nvar showEmbeddedHtml= function (e) {\\n    console.log(\\\"Callback showEmbeddedHtml\\\");\\n    console.log(e.detail);\\n};\\nvar playVideo= function (e) {\\n    console.log(\\\"callback playVideo\\\");\\n    console.log(e.detail);\\n};\\nvar showImage= function (e) {\\n    console.log(\\\"callback showImage\\\");\\n    console.log(e.detail);\\n};\\nvar addPassbook= function (e) {\\n    console.log(\\\"callback addPassbook\\\");\\n    console.log(e.detail);\\n};\\nvar addTag= function (e) {\\n    console.log(\\\"Tag Added\\\");\\n};\\nvar playSound= function (e) {\\n    console.log(\\\"callback playSound\\\");\\n    console.log(e.detail);\\n};\\n\\nvar didLoadedBeaconsData = function (e){\\n    console.log(\\\"MOCA data loaded\\\");\\n    console.log(e.detail);\\n};\\n\\nvar placesInside = function (e) {\\n    console.log(\\\"places inside: \\\");\\n    console.log(e);\\n};\\n\\napp.initialize();\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","category":"55bb441b54f9640d006e6cf2","excerpt":"","link_url":"","type":"basic","updates":[],"user":"559a618bdbcfd20d00710b38","api":{"params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":"","auth":"required"},"version":"559a61d2dbcfd20d00710b3c","isReference":false,"project":"559a61d2dbcfd20d00710b39","title":"Basic examples","githubsync":"","createdAt":"2015-07-31T09:58:07.927Z","hidden":false,"order":2,"parentDoc":null,"slug":"basic-examples","__v":3,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Basic examples


The JavaScript API follows an asynchronous callback approach with hooks for events such as Enter Beacon Range, Enter Place or Display Notification Alert event. Below is a brief example of this API in use: [block:code] { "codes": [ { "code": "/*\n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nconsole.log(\"App is on! Initializing stuff...\");\nvar app = {\n // Application Constructor\n initialize: function () {\n this.bindEvents();\n },\n // Bind Event Listeners\n //\n // Bind any events that are required on startup. Common events are:\n // 'load', 'deviceready', 'offline', and 'online'.\n\n bindEvents: function () {\n document.addEventListener('deviceready', this.onDeviceReady, false);\n },\n // deviceready Event Handler\n //\n // The scope of 'this' is the event. In order to call the 'receivedEvent'\n // function, we must explicitly call 'app.receivedEvent(...);'\n onDeviceReady: function () {\n app.receivedEvent('deviceready');\n MOCA.addEnterBeaconListener(onEnterBeacon);\n MOCA.addExitBeaconListener(onExitBeacon);\n MOCA.addBeaconProximityChangeListener(onBeaconProximityChange);\n MOCA.addEnterPlaceListener(onEnterPlace);\n MOCA.addExitPlaceListener(onExitPlace);\n MOCA.addEnterZoneListener(onEnterZone);\n MOCA.addExitZoneListener(onExitZone);\n\n MOCA.addDisplayAlertListener(false, displayAlert);\n MOCA.addOpenUrlListener(false, openUrl);\n MOCA.addShowEmbeddedHtmlListener(false, showEmbeddedHtml);\n MOCA.addPlayVideoListener(false, playVideo);\n MOCA.addShowImageListener(false, showImage);\n MOCA.addAddPassbookListener(false, addPassbook);\n MOCA.addAddTagListener(addTag);\n MOCA.addPlaySoundListener(false, playSound);\n MOCA.addCustomActionListener(performCustomAction);\n MOCA.addDataReadyListener(didLoadedBeaconsData);\n\n\n getMOCAValues();\n },\n // Update DOM on a Received Event\n receivedEvent: function (id) {\n var parentElement = document.getElementById(id);\n var listeningElement = parentElement.querySelector('.listening');\n var receivedElement = parentElement.querySelector('.received');\n\n listeningElement.setAttribute('style', 'display:none;');\n receivedElement.setAttribute('style', 'display:block;');\n\n console.log('Received Event: ' + id);\n }\n};\n\nvar getMOCAValues = function(){\n MOCA.placesInside(placesInside);\n var ver = document.getElementById(\"ver\");\n var appKey = document.getElementById(\"appKey\");\n var appSecret = document.getElementById(\"appSecret\");\n var logLevel = document.getElementById(\"logLevel\");\n MOCA.version(function(e){ ver.innerHTML = \"Native SDK version: <b>\" + e +\"</b>\"});\n MOCA.appKey(function(e){ appKey.innerHTML = \"appKey: <b>\" + e + \"</b>\"});\n MOCA.appSecret(function(e){ appSecret.innerHTML = \"appSecret: <b>\" + e + \"</b>\"});\n MOCA.logLevel(function(e){ logLevel.innerHTML = \"logLevel: <b>\" + e + \"</b>\"});\n}\n\n//console.log = function(message) {\n// var logger = document.getElementById(\"logger\");\n// logger.innerHTML = logger.innerHTML + \"<li>\" + message + \"</li>\";\n//};\n\nvar onEnterBeacon= function (e) {\n console.log(\"MOCA On Enter beacon\");\n console.log(e.detail);\n};\nvar onExitBeacon= function (e) {\n console.log(\"Event On exit beacon with detail \");\n console.log(e.detail);\n};\nvar onEnterZone = function (e) {\n console.log(\"Event On Enter Zone\");\n console.log(e.detail);\n};\nvar onExitZone = function (e) {\n console.log(\"Event On Exit Zone\");\n console.log(e.detail);\n};\nvar onBeaconProximityChange= function (e) {\n console.log(e);\n console.log(\"Event On Proximity change with detail \");\n console.log(e.detail);\n};\nvar onEnterPlace= function (e) {\n console.log(e);\n console.log(\"Event On enter place with detail \");\n console.log(e.detail);\n\n};\nvar onExitPlace= function (e) {\n console.log(e);\n console.log(\"Event On exit place with detail \");\n console.log(e.detail);\n};\nvar performCustomAction= function (e) {\n console.log(\"Callback Perform custom action on JS \");\n console.log(e.detail);\n};\nvar displayAlert= function (e) {\n console.log(\"Callback display alert \");\n console.log(e.detail);\n};\nvar openUrl= function (e) {\n console.log(\"Callback open URL\");\n console.log(e.detail);\n};\nvar showEmbeddedHtml= function (e) {\n console.log(\"Callback showEmbeddedHtml\");\n console.log(e.detail);\n};\nvar playVideo= function (e) {\n console.log(\"callback playVideo\");\n console.log(e.detail);\n};\nvar showImage= function (e) {\n console.log(\"callback showImage\");\n console.log(e.detail);\n};\nvar addPassbook= function (e) {\n console.log(\"callback addPassbook\");\n console.log(e.detail);\n};\nvar addTag= function (e) {\n console.log(\"Tag Added\");\n};\nvar playSound= function (e) {\n console.log(\"callback playSound\");\n console.log(e.detail);\n};\n\nvar didLoadedBeaconsData = function (e){\n console.log(\"MOCA data loaded\");\n console.log(e.detail);\n};\n\nvar placesInside = function (e) {\n console.log(\"places inside: \");\n console.log(e);\n};\n\napp.initialize();", "language": "javascript" } ] } [/block]
The JavaScript API follows an asynchronous callback approach with hooks for events such as Enter Beacon Range, Enter Place or Display Notification Alert event. Below is a brief example of this API in use: [block:code] { "codes": [ { "code": "/*\n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nconsole.log(\"App is on! Initializing stuff...\");\nvar app = {\n // Application Constructor\n initialize: function () {\n this.bindEvents();\n },\n // Bind Event Listeners\n //\n // Bind any events that are required on startup. Common events are:\n // 'load', 'deviceready', 'offline', and 'online'.\n\n bindEvents: function () {\n document.addEventListener('deviceready', this.onDeviceReady, false);\n },\n // deviceready Event Handler\n //\n // The scope of 'this' is the event. In order to call the 'receivedEvent'\n // function, we must explicitly call 'app.receivedEvent(...);'\n onDeviceReady: function () {\n app.receivedEvent('deviceready');\n MOCA.addEnterBeaconListener(onEnterBeacon);\n MOCA.addExitBeaconListener(onExitBeacon);\n MOCA.addBeaconProximityChangeListener(onBeaconProximityChange);\n MOCA.addEnterPlaceListener(onEnterPlace);\n MOCA.addExitPlaceListener(onExitPlace);\n MOCA.addEnterZoneListener(onEnterZone);\n MOCA.addExitZoneListener(onExitZone);\n\n MOCA.addDisplayAlertListener(false, displayAlert);\n MOCA.addOpenUrlListener(false, openUrl);\n MOCA.addShowEmbeddedHtmlListener(false, showEmbeddedHtml);\n MOCA.addPlayVideoListener(false, playVideo);\n MOCA.addShowImageListener(false, showImage);\n MOCA.addAddPassbookListener(false, addPassbook);\n MOCA.addAddTagListener(addTag);\n MOCA.addPlaySoundListener(false, playSound);\n MOCA.addCustomActionListener(performCustomAction);\n MOCA.addDataReadyListener(didLoadedBeaconsData);\n\n\n getMOCAValues();\n },\n // Update DOM on a Received Event\n receivedEvent: function (id) {\n var parentElement = document.getElementById(id);\n var listeningElement = parentElement.querySelector('.listening');\n var receivedElement = parentElement.querySelector('.received');\n\n listeningElement.setAttribute('style', 'display:none;');\n receivedElement.setAttribute('style', 'display:block;');\n\n console.log('Received Event: ' + id);\n }\n};\n\nvar getMOCAValues = function(){\n MOCA.placesInside(placesInside);\n var ver = document.getElementById(\"ver\");\n var appKey = document.getElementById(\"appKey\");\n var appSecret = document.getElementById(\"appSecret\");\n var logLevel = document.getElementById(\"logLevel\");\n MOCA.version(function(e){ ver.innerHTML = \"Native SDK version: <b>\" + e +\"</b>\"});\n MOCA.appKey(function(e){ appKey.innerHTML = \"appKey: <b>\" + e + \"</b>\"});\n MOCA.appSecret(function(e){ appSecret.innerHTML = \"appSecret: <b>\" + e + \"</b>\"});\n MOCA.logLevel(function(e){ logLevel.innerHTML = \"logLevel: <b>\" + e + \"</b>\"});\n}\n\n//console.log = function(message) {\n// var logger = document.getElementById(\"logger\");\n// logger.innerHTML = logger.innerHTML + \"<li>\" + message + \"</li>\";\n//};\n\nvar onEnterBeacon= function (e) {\n console.log(\"MOCA On Enter beacon\");\n console.log(e.detail);\n};\nvar onExitBeacon= function (e) {\n console.log(\"Event On exit beacon with detail \");\n console.log(e.detail);\n};\nvar onEnterZone = function (e) {\n console.log(\"Event On Enter Zone\");\n console.log(e.detail);\n};\nvar onExitZone = function (e) {\n console.log(\"Event On Exit Zone\");\n console.log(e.detail);\n};\nvar onBeaconProximityChange= function (e) {\n console.log(e);\n console.log(\"Event On Proximity change with detail \");\n console.log(e.detail);\n};\nvar onEnterPlace= function (e) {\n console.log(e);\n console.log(\"Event On enter place with detail \");\n console.log(e.detail);\n\n};\nvar onExitPlace= function (e) {\n console.log(e);\n console.log(\"Event On exit place with detail \");\n console.log(e.detail);\n};\nvar performCustomAction= function (e) {\n console.log(\"Callback Perform custom action on JS \");\n console.log(e.detail);\n};\nvar displayAlert= function (e) {\n console.log(\"Callback display alert \");\n console.log(e.detail);\n};\nvar openUrl= function (e) {\n console.log(\"Callback open URL\");\n console.log(e.detail);\n};\nvar showEmbeddedHtml= function (e) {\n console.log(\"Callback showEmbeddedHtml\");\n console.log(e.detail);\n};\nvar playVideo= function (e) {\n console.log(\"callback playVideo\");\n console.log(e.detail);\n};\nvar showImage= function (e) {\n console.log(\"callback showImage\");\n console.log(e.detail);\n};\nvar addPassbook= function (e) {\n console.log(\"callback addPassbook\");\n console.log(e.detail);\n};\nvar addTag= function (e) {\n console.log(\"Tag Added\");\n};\nvar playSound= function (e) {\n console.log(\"callback playSound\");\n console.log(e.detail);\n};\n\nvar didLoadedBeaconsData = function (e){\n console.log(\"MOCA data loaded\");\n console.log(e.detail);\n};\n\nvar placesInside = function (e) {\n console.log(\"places inside: \");\n console.log(e);\n};\n\napp.initialize();", "language": "javascript" } ] } [/block]
{"_id":"57979d3e9eaa220e006128ca","api":{"url":"","results":{"codes":[{"language":"json","code":"{}","name":"","status":200},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","auth":"required","params":[]},"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Dependencies conflict (Android)\"\n}\n[/block]\n##Symptom\nYou receive the following error message at compile time:\n\n```\n:transformClassesWithDexForDebug\nUNEXPECTED TOP-LEVEL EXCEPTION:\ncom.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzr;\n```\n\n##Solution\n\nMOCA Plugin for Cordova / PhoneGap requires the following dependencies on Android:\n- Google Play Services (GPSS) - Cloud Messaging (GCM)\n- GPSS - Location Services\n- GPSS - Ads\n- MessagePack\n\nIf you are using other plugins within your project, it is common that some of these plugins also rely on GPSS for some functionality. So the problem comes when some of these libraries uses a different versions of GPSS.\n\nMOCA Plugin expects at least GPSS version 8.3. We provide you the plugin with this version in the plugin configuration, so you can have predictable builds in the future. \n\nIn order to fix this issue, please use one of the following solutions:\n\nOption A:\n\nChange the `mocabuild.gradle` file within the plugin folder and change **all** the versions to the latest one, bear in mind that **your other plugins should also use the same version**.\n\nOption B:\n\nCreate a file called `build-extras.gradle` in the following folder `your_app_name > platforms > android` and paste the following code there.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\n\\n// When set, this function allows code to run at the end of `build.gradle`\\next.postBuildExtras = {\\n    configurations.all {\\n\\t\\tresolutionStrategy {\\n      \\t//Google Cloud Messaging\\n    \\t\\tforce 'com.google.android.gms:play-services-gcm:+'\\n    \\t\\t\\n      \\t//Google Location, Activity Recognition, and Places\\n   \\t\\t\\tforce 'com.google.android.gms:play-services-location:+'\\n\\n    \\t\\t//Google Mobile Ads\\n   \\t\\t\\tforce 'com.google.android.gms:play-services-ads:+'\\n\\t\\t}\\n\\t}\\n}\\n\",\n      \"language\": \"groovy\",\n      \"name\": \"build-extras.gradle\"\n    }\n  ]\n}\n[/block]\nIf there is any other plugin that uses any part of GPSS, you should include it here as well, and remember: All GPSS dependencies must use the same version, otherwise you will get errors at Compile or at RunTime.\n\nBelow you will find a list of possible GPSS dependencies\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"# Google+\\nforce 'com.google.android.gms:play-services-plus:+'\\n# Google Account Login\\nforce 'com.google.android.gms:play-services-auth:+'\\n# Google Actions, Base Client Library\\nforce 'com.google.android.gms:play-services-base:+'\\n# Google Address API\\nforce 'com.google.android.gms:play-services-identity:+'\\n# Google App Indexing\\nforce 'com.google.android.gms:play-services-appindexing:+'\\n# Google App Invites\\nforce 'com.google.android.gms:play-services-appinvite:+'\\n# Google Analytics\\nforce 'com.google.android.gms:play-services-analytics:+'\\n# Google Cast\\nforce 'com.google.android.gms:play-services-cast:+'\\n# Google Cloud Messaging\\nforce 'com.google.android.gms:play-services-gcm:+'\\n# Google Drive\\nforce 'com.google.android.gms:play-services-drive:+'\\n# Google Fit\\nforce 'com.google.android.gms:play-services-fitness:+'\\n# Google Location, Activity Recognition, and Places\\nforce 'com.google.android.gms:play-services-location:+'\\n# Google Maps\\nforce 'com.google.android.gms:play-services-maps:+'\\n# Google Mobile Ads\\nforce 'com.google.android.gms:play-services-ads:+'\\n# Mobile Vision\\nforce 'com.google.android.gms:play-services-vision:+'\\n# Google Nearby\\nforce 'com.google.android.gms:play-services-nearby:+'\\n# Google Panorama Viewer\\nforce 'com.google.android.gms:play-services-panorama:+'\\n# Google Play Game services\\nforce 'com.google.android.gms:play-services-games:+'\\n# SafetyNet\\nforce 'com.google.android.gms:play-services-safetynet:+'\\n# Android Pay\\nforce 'com.google.android.gms:play-services-wallet:+'\\n# Android Wear\\nforce 'com.google.android.gms:play-services-wearable:+'\",\n      \"language\": \"groovy\",\n      \"name\": \"GPSS dependency examples\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Application crashes at startup\"\n}\n[/block]\n##Symptom\n\nApplication crashes at startup with the following error message\n\n`java.lang.ClassCastException: android.app.Application cannot be cast to com.innoquant.moca.phonegap.MOCApp`\n\n##Solution\n\nMOCA Plugin works even if the app is not running, in order to achieve this functionality, it requires a class to be declared in your `AndroidManifest.xml` `application` tag. If the Android platform is already created when you installed MOCA Plugin, this is done automatically by the installation scripts, however it may not work if there is a conflict with other plugin that has the same requirement, or if the android platform is added afterwards.\n\nOpen your `AndroidManifest.xml` and check the `application` tag, you should observe something similar to this example (notice the `android:name=\"com.innoquant.moca.phonegap.MOCApp\"`)\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/4dbf58c-android-name.png\",\n        \"android-name.png\",\n        579,\n        115,\n        \"#30302f\"\n      ]\n    }\n  ]\n}\n[/block]\n###Case 1: There is no `android:name` tag.\n\n####Solution\n- Just add the tag as shown in the image above.\n\n###Case 2: There are two `android:name` tags, or the class declared is from another plugin.\n\n####Solution\n- In this case the solution is not as straightforward and will require some Java coding in the project.\n\nIf there are two plugins with this requirement within your project, you will need to merge these two classes manually. If you have experience coding Java, just go ahead, create a new class with a name of your preference, merge all functionality in a single class (or create a proxy class that instantiates both classes) and declare this new class in the application tag.\n\nIn any case, if you are in this particular case, please open a [support ticket](mailto:[email protected]). We would like to study in detail any more conflicts that may arise with the 3rd party plugin.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Other Building errors\"\n}\n[/block]\n##Symptom\n\nYou receive the following error at compile time.\n\n```\n.../HelloWorld/platforms/android/build/intermediates/res/debug/values-v23/values.xml:5: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse\n\n...HelloWorld/platforms/android/build/intermediates/res/debug/values-v23/values.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.\n```\n\n####Solution\n\nMOCA Plugin requires project to be compiled against Android API level 23 (Android M). Please check you have included the min and target in your `config.xml` versions as follows:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<preference name=\\\"android-minSdkVersion\\\" value=\\\"14\\\" />\\n<preference name=\\\"android-targetSdkVersion\\\" value=\\\"23\\\" />\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\nIf problem persists, please check the following file:\n\n`YOUR_APP_FOLDER/platforms/android/project.properties`\n\nAnd change the configuration if needed:\n\n`target=android-23`","isReference":false,"next":{"description":"","pages":[]},"order":4,"title":"Common issues / Troubleshooting","type":"basic","user":"559a618bdbcfd20d00710b38","__v":1,"githubsync":"","link_external":false,"link_url":"","sync_unique":"","excerpt":"","hidden":false,"version":"559a61d2dbcfd20d00710b3c","category":"55bb441b54f9640d006e6cf2","createdAt":"2016-07-26T17:26:22.879Z","parentDoc":null,"project":"559a61d2dbcfd20d00710b39","slug":"common-issues-troubleshooting","updates":[],"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Common issues / Troubleshooting


[block:api-header] { "type": "basic", "title": "Dependencies conflict (Android)" } [/block] ##Symptom You receive the following error message at compile time: ``` :transformClassesWithDexForDebug UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzr; ``` ##Solution MOCA Plugin for Cordova / PhoneGap requires the following dependencies on Android: - Google Play Services (GPSS) - Cloud Messaging (GCM) - GPSS - Location Services - GPSS - Ads - MessagePack If you are using other plugins within your project, it is common that some of these plugins also rely on GPSS for some functionality. So the problem comes when some of these libraries uses a different versions of GPSS. MOCA Plugin expects at least GPSS version 8.3. We provide you the plugin with this version in the plugin configuration, so you can have predictable builds in the future. In order to fix this issue, please use one of the following solutions: Option A: Change the `mocabuild.gradle` file within the plugin folder and change **all** the versions to the latest one, bear in mind that **your other plugins should also use the same version**. Option B: Create a file called `build-extras.gradle` in the following folder `your_app_name > platforms > android` and paste the following code there. [block:code] { "codes": [ { "code": "\n\n// When set, this function allows code to run at the end of `build.gradle`\next.postBuildExtras = {\n configurations.all {\n\t\tresolutionStrategy {\n \t//Google Cloud Messaging\n \t\tforce 'com.google.android.gms:play-services-gcm:+'\n \t\t\n \t//Google Location, Activity Recognition, and Places\n \t\t\tforce 'com.google.android.gms:play-services-location:+'\n\n \t\t//Google Mobile Ads\n \t\t\tforce 'com.google.android.gms:play-services-ads:+'\n\t\t}\n\t}\n}\n", "language": "groovy", "name": "build-extras.gradle" } ] } [/block] If there is any other plugin that uses any part of GPSS, you should include it here as well, and remember: All GPSS dependencies must use the same version, otherwise you will get errors at Compile or at RunTime. Below you will find a list of possible GPSS dependencies [block:code] { "codes": [ { "code": "# Google+\nforce 'com.google.android.gms:play-services-plus:+'\n# Google Account Login\nforce 'com.google.android.gms:play-services-auth:+'\n# Google Actions, Base Client Library\nforce 'com.google.android.gms:play-services-base:+'\n# Google Address API\nforce 'com.google.android.gms:play-services-identity:+'\n# Google App Indexing\nforce 'com.google.android.gms:play-services-appindexing:+'\n# Google App Invites\nforce 'com.google.android.gms:play-services-appinvite:+'\n# Google Analytics\nforce 'com.google.android.gms:play-services-analytics:+'\n# Google Cast\nforce 'com.google.android.gms:play-services-cast:+'\n# Google Cloud Messaging\nforce 'com.google.android.gms:play-services-gcm:+'\n# Google Drive\nforce 'com.google.android.gms:play-services-drive:+'\n# Google Fit\nforce 'com.google.android.gms:play-services-fitness:+'\n# Google Location, Activity Recognition, and Places\nforce 'com.google.android.gms:play-services-location:+'\n# Google Maps\nforce 'com.google.android.gms:play-services-maps:+'\n# Google Mobile Ads\nforce 'com.google.android.gms:play-services-ads:+'\n# Mobile Vision\nforce 'com.google.android.gms:play-services-vision:+'\n# Google Nearby\nforce 'com.google.android.gms:play-services-nearby:+'\n# Google Panorama Viewer\nforce 'com.google.android.gms:play-services-panorama:+'\n# Google Play Game services\nforce 'com.google.android.gms:play-services-games:+'\n# SafetyNet\nforce 'com.google.android.gms:play-services-safetynet:+'\n# Android Pay\nforce 'com.google.android.gms:play-services-wallet:+'\n# Android Wear\nforce 'com.google.android.gms:play-services-wearable:+'", "language": "groovy", "name": "GPSS dependency examples" } ] } [/block] [block:api-header] { "type": "basic", "title": "Application crashes at startup" } [/block] ##Symptom Application crashes at startup with the following error message `java.lang.ClassCastException: android.app.Application cannot be cast to com.innoquant.moca.phonegap.MOCApp` ##Solution MOCA Plugin works even if the app is not running, in order to achieve this functionality, it requires a class to be declared in your `AndroidManifest.xml` `application` tag. If the Android platform is already created when you installed MOCA Plugin, this is done automatically by the installation scripts, however it may not work if there is a conflict with other plugin that has the same requirement, or if the android platform is added afterwards. Open your `AndroidManifest.xml` and check the `application` tag, you should observe something similar to this example (notice the `android:name="com.innoquant.moca.phonegap.MOCApp"`) [block:image] { "images": [ { "image": [ "https://files.readme.io/4dbf58c-android-name.png", "android-name.png", 579, 115, "#30302f" ] } ] } [/block] ###Case 1: There is no `android:name` tag. ####Solution - Just add the tag as shown in the image above. ###Case 2: There are two `android:name` tags, or the class declared is from another plugin. ####Solution - In this case the solution is not as straightforward and will require some Java coding in the project. If there are two plugins with this requirement within your project, you will need to merge these two classes manually. If you have experience coding Java, just go ahead, create a new class with a name of your preference, merge all functionality in a single class (or create a proxy class that instantiates both classes) and declare this new class in the application tag. In any case, if you are in this particular case, please open a [support ticket](mailto:[email protected]). We would like to study in detail any more conflicts that may arise with the 3rd party plugin. [block:api-header] { "type": "basic", "title": "Other Building errors" } [/block] ##Symptom You receive the following error at compile time. ``` .../HelloWorld/platforms/android/build/intermediates/res/debug/values-v23/values.xml:5: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse ...HelloWorld/platforms/android/build/intermediates/res/debug/values-v23/values.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'. ``` ####Solution MOCA Plugin requires project to be compiled against Android API level 23 (Android M). Please check you have included the min and target in your `config.xml` versions as follows: [block:code] { "codes": [ { "code": "<preference name=\"android-minSdkVersion\" value=\"14\" />\n<preference name=\"android-targetSdkVersion\" value=\"23\" />", "language": "xml" } ] } [/block] If problem persists, please check the following file: `YOUR_APP_FOLDER/platforms/android/project.properties` And change the configuration if needed: `target=android-23`
[block:api-header] { "type": "basic", "title": "Dependencies conflict (Android)" } [/block] ##Symptom You receive the following error message at compile time: ``` :transformClassesWithDexForDebug UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzr; ``` ##Solution MOCA Plugin for Cordova / PhoneGap requires the following dependencies on Android: - Google Play Services (GPSS) - Cloud Messaging (GCM) - GPSS - Location Services - GPSS - Ads - MessagePack If you are using other plugins within your project, it is common that some of these plugins also rely on GPSS for some functionality. So the problem comes when some of these libraries uses a different versions of GPSS. MOCA Plugin expects at least GPSS version 8.3. We provide you the plugin with this version in the plugin configuration, so you can have predictable builds in the future. In order to fix this issue, please use one of the following solutions: Option A: Change the `mocabuild.gradle` file within the plugin folder and change **all** the versions to the latest one, bear in mind that **your other plugins should also use the same version**. Option B: Create a file called `build-extras.gradle` in the following folder `your_app_name > platforms > android` and paste the following code there. [block:code] { "codes": [ { "code": "\n\n// When set, this function allows code to run at the end of `build.gradle`\next.postBuildExtras = {\n configurations.all {\n\t\tresolutionStrategy {\n \t//Google Cloud Messaging\n \t\tforce 'com.google.android.gms:play-services-gcm:+'\n \t\t\n \t//Google Location, Activity Recognition, and Places\n \t\t\tforce 'com.google.android.gms:play-services-location:+'\n\n \t\t//Google Mobile Ads\n \t\t\tforce 'com.google.android.gms:play-services-ads:+'\n\t\t}\n\t}\n}\n", "language": "groovy", "name": "build-extras.gradle" } ] } [/block] If there is any other plugin that uses any part of GPSS, you should include it here as well, and remember: All GPSS dependencies must use the same version, otherwise you will get errors at Compile or at RunTime. Below you will find a list of possible GPSS dependencies [block:code] { "codes": [ { "code": "# Google+\nforce 'com.google.android.gms:play-services-plus:+'\n# Google Account Login\nforce 'com.google.android.gms:play-services-auth:+'\n# Google Actions, Base Client Library\nforce 'com.google.android.gms:play-services-base:+'\n# Google Address API\nforce 'com.google.android.gms:play-services-identity:+'\n# Google App Indexing\nforce 'com.google.android.gms:play-services-appindexing:+'\n# Google App Invites\nforce 'com.google.android.gms:play-services-appinvite:+'\n# Google Analytics\nforce 'com.google.android.gms:play-services-analytics:+'\n# Google Cast\nforce 'com.google.android.gms:play-services-cast:+'\n# Google Cloud Messaging\nforce 'com.google.android.gms:play-services-gcm:+'\n# Google Drive\nforce 'com.google.android.gms:play-services-drive:+'\n# Google Fit\nforce 'com.google.android.gms:play-services-fitness:+'\n# Google Location, Activity Recognition, and Places\nforce 'com.google.android.gms:play-services-location:+'\n# Google Maps\nforce 'com.google.android.gms:play-services-maps:+'\n# Google Mobile Ads\nforce 'com.google.android.gms:play-services-ads:+'\n# Mobile Vision\nforce 'com.google.android.gms:play-services-vision:+'\n# Google Nearby\nforce 'com.google.android.gms:play-services-nearby:+'\n# Google Panorama Viewer\nforce 'com.google.android.gms:play-services-panorama:+'\n# Google Play Game services\nforce 'com.google.android.gms:play-services-games:+'\n# SafetyNet\nforce 'com.google.android.gms:play-services-safetynet:+'\n# Android Pay\nforce 'com.google.android.gms:play-services-wallet:+'\n# Android Wear\nforce 'com.google.android.gms:play-services-wearable:+'", "language": "groovy", "name": "GPSS dependency examples" } ] } [/block] [block:api-header] { "type": "basic", "title": "Application crashes at startup" } [/block] ##Symptom Application crashes at startup with the following error message `java.lang.ClassCastException: android.app.Application cannot be cast to com.innoquant.moca.phonegap.MOCApp` ##Solution MOCA Plugin works even if the app is not running, in order to achieve this functionality, it requires a class to be declared in your `AndroidManifest.xml` `application` tag. If the Android platform is already created when you installed MOCA Plugin, this is done automatically by the installation scripts, however it may not work if there is a conflict with other plugin that has the same requirement, or if the android platform is added afterwards. Open your `AndroidManifest.xml` and check the `application` tag, you should observe something similar to this example (notice the `android:name="com.innoquant.moca.phonegap.MOCApp"`) [block:image] { "images": [ { "image": [ "https://files.readme.io/4dbf58c-android-name.png", "android-name.png", 579, 115, "#30302f" ] } ] } [/block] ###Case 1: There is no `android:name` tag. ####Solution - Just add the tag as shown in the image above. ###Case 2: There are two `android:name` tags, or the class declared is from another plugin. ####Solution - In this case the solution is not as straightforward and will require some Java coding in the project. If there are two plugins with this requirement within your project, you will need to merge these two classes manually. If you have experience coding Java, just go ahead, create a new class with a name of your preference, merge all functionality in a single class (or create a proxy class that instantiates both classes) and declare this new class in the application tag. In any case, if you are in this particular case, please open a [support ticket](mailto:[email protected]). We would like to study in detail any more conflicts that may arise with the 3rd party plugin. [block:api-header] { "type": "basic", "title": "Other Building errors" } [/block] ##Symptom You receive the following error at compile time. ``` .../HelloWorld/platforms/android/build/intermediates/res/debug/values-v23/values.xml:5: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse ...HelloWorld/platforms/android/build/intermediates/res/debug/values-v23/values.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'. ``` ####Solution MOCA Plugin requires project to be compiled against Android API level 23 (Android M). Please check you have included the min and target in your `config.xml` versions as follows: [block:code] { "codes": [ { "code": "<preference name=\"android-minSdkVersion\" value=\"14\" />\n<preference name=\"android-targetSdkVersion\" value=\"23\" />", "language": "xml" } ] } [/block] If problem persists, please check the following file: `YOUR_APP_FOLDER/platforms/android/project.properties` And change the configuration if needed: `target=android-23`
{"_id":"55a58fdeaaf9cf1900114df7","excerpt":"App objects represent mobile apps in MOCA platform. The API allows you to create, delete and update your apps. You can retrieve individual apps as well as a list of all your apps.","githubsync":"","version":"559a61d2dbcfd20d00710b3c","category":"55afb22e902fd51700f5f8bf","order":0,"slug":"apps","type":"basic","project":"559a61d2dbcfd20d00710b39","title":"Apps","updates":[],"isReference":true,"link_external":false,"link_url":"","parentDoc":null,"user":"55a575ebaaf9cf1900114d73","sync_unique":"","__v":13,"api":{"settings":"","url":"","auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]}},"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"The app object\"\n}\n[/block]\nAttributes:\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Obligatory?\",\n    \"h-3\": \"Description\",\n    \"0-0\": \"createdAt\",\n    \"0-3\": \"Creation date (timestamp UTC)\",\n    \"0-1\": \"long\",\n    \"0-2\": \"Autogenerated\",\n    \"1-0\": \"accountId\",\n    \"1-1\": \"string\",\n    \"1-2\": \"Yes\",\n    \"1-3\": \"Account ID this app belongs to.\",\n    \"2-0\": \"appKey\",\n    \"2-1\": \"string\",\n    \"2-2\": \"Autogenerated\",\n    \"2-3\": \"App key\",\n    \"3-0\": \"config.appUrl\",\n    \"3-1\": \"string\",\n    \"3-2\": \"No\",\n    \"3-3\": \"App website URL\",\n    \"4-0\": \"config.category\",\n    \"4-1\": \"string\",\n    \"4-2\": \"No\",\n    \"4-3\": \"App category name\",\n    \"5-0\": \"config.version\",\n    \"5-1\": \"string\",\n    \"5-2\": \"Yes\",\n    \"5-3\": \"App version string\",\n    \"6-0\": \"config.description\",\n    \"6-1\": \"string\",\n    \"6-2\": \"No\",\n    \"6-3\": \"App description\",\n    \"7-0\": \"config.iconUrl\",\n    \"7-1\": \"string\",\n    \"7-2\": \"No\",\n    \"7-3\": \"App icon URL\",\n    \"8-0\": \"config.name\",\n    \"8-1\": \"string\",\n    \"8-2\": \"Yes\",\n    \"8-3\": \"App short name\",\n    \"9-0\": \"config.approxAppSize\",\n    \"9-1\": \"string\",\n    \"9-2\": \"No\",\n    \"9-3\": \"Estimated volume of users of this app\",\n    \"10-0\": \"config.updatedAt\",\n    \"10-1\": \"long\",\n    \"10-2\": \"Autogenerated\",\n    \"10-3\": \"Last modified date (timestamp UTC)\",\n    \"11-0\": \"targets\",\n    \"11-1\": \"array of objects\",\n    \"11-2\": \"No\",\n    \"11-3\": \"A list of AppTarget objects this app is associated to.\"\n  },\n  \"cols\": 4,\n  \"rows\": 12\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Sample app object\"\n}\n[/block]\nExample app object in JSON:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"createdAt\\\": 1411491803257,\\n    \\\"appKey\\\": \\\"Z2xxt0e4Tv29kGG-Ui0Jgg\\\",\\n    \\\"accountId\\\": \\\"WXPvOaYERlGkZ4AP6q_onw\\\",\\n    \\\"config\\\": {\\n      \\\"appUrl\\\": \\\"\\\",\\n      \\\"category\\\": \\\"Utilities\\\",\\n      \\\"version\\\": \\\"1.0\\\",\\n      \\\"description\\\": \\\"\\\",\\n      \\\"iconUrl\\\": \\\"\\\",\\n      \\\"name\\\": \\\"TestApp\\\",\\n      \\\"approxAppSize\\\": \\\"<2500\\\",\\n      \\\"updatedAt\\\": 1411491803258,\\n      \\\"production\\\": false\\n    },\\n    \\\"targets\\\": []\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]","createdAt":"2015-07-14T22:40:30.574Z","hidden":false,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Apps

App objects represent mobile apps in MOCA platform. The API allows you to create, delete and update your apps. You can retrieve individual apps as well as a list of all your apps.

[block:api-header] { "type": "basic", "title": "The app object" } [/block] Attributes: [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Obligatory?", "h-3": "Description", "0-0": "createdAt", "0-3": "Creation date (timestamp UTC)", "0-1": "long", "0-2": "Autogenerated", "1-0": "accountId", "1-1": "string", "1-2": "Yes", "1-3": "Account ID this app belongs to.", "2-0": "appKey", "2-1": "string", "2-2": "Autogenerated", "2-3": "App key", "3-0": "config.appUrl", "3-1": "string", "3-2": "No", "3-3": "App website URL", "4-0": "config.category", "4-1": "string", "4-2": "No", "4-3": "App category name", "5-0": "config.version", "5-1": "string", "5-2": "Yes", "5-3": "App version string", "6-0": "config.description", "6-1": "string", "6-2": "No", "6-3": "App description", "7-0": "config.iconUrl", "7-1": "string", "7-2": "No", "7-3": "App icon URL", "8-0": "config.name", "8-1": "string", "8-2": "Yes", "8-3": "App short name", "9-0": "config.approxAppSize", "9-1": "string", "9-2": "No", "9-3": "Estimated volume of users of this app", "10-0": "config.updatedAt", "10-1": "long", "10-2": "Autogenerated", "10-3": "Last modified date (timestamp UTC)", "11-0": "targets", "11-1": "array of objects", "11-2": "No", "11-3": "A list of AppTarget objects this app is associated to." }, "cols": 4, "rows": 12 } [/block] [block:api-header] { "type": "basic", "title": "Sample app object" } [/block] Example app object in JSON: [block:code] { "codes": [ { "code": "{\n \"createdAt\": 1411491803257,\n \"appKey\": \"Z2xxt0e4Tv29kGG-Ui0Jgg\",\n \"accountId\": \"WXPvOaYERlGkZ4AP6q_onw\",\n \"config\": {\n \"appUrl\": \"\",\n \"category\": \"Utilities\",\n \"version\": \"1.0\",\n \"description\": \"\",\n \"iconUrl\": \"\",\n \"name\": \"TestApp\",\n \"approxAppSize\": \"<2500\",\n \"updatedAt\": 1411491803258,\n \"production\": false\n },\n \"targets\": []\n}", "language": "json" } ] } [/block]
[block:api-header] { "type": "basic", "title": "The app object" } [/block] Attributes: [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Obligatory?", "h-3": "Description", "0-0": "createdAt", "0-3": "Creation date (timestamp UTC)", "0-1": "long", "0-2": "Autogenerated", "1-0": "accountId", "1-1": "string", "1-2": "Yes", "1-3": "Account ID this app belongs to.", "2-0": "appKey", "2-1": "string", "2-2": "Autogenerated", "2-3": "App key", "3-0": "config.appUrl", "3-1": "string", "3-2": "No", "3-3": "App website URL", "4-0": "config.category", "4-1": "string", "4-2": "No", "4-3": "App category name", "5-0": "config.version", "5-1": "string", "5-2": "Yes", "5-3": "App version string", "6-0": "config.description", "6-1": "string", "6-2": "No", "6-3": "App description", "7-0": "config.iconUrl", "7-1": "string", "7-2": "No", "7-3": "App icon URL", "8-0": "config.name", "8-1": "string", "8-2": "Yes", "8-3": "App short name", "9-0": "config.approxAppSize", "9-1": "string", "9-2": "No", "9-3": "Estimated volume of users of this app", "10-0": "config.updatedAt", "10-1": "long", "10-2": "Autogenerated", "10-3": "Last modified date (timestamp UTC)", "11-0": "targets", "11-1": "array of objects", "11-2": "No", "11-3": "A list of AppTarget objects this app is associated to." }, "cols": 4, "rows": 12 } [/block] [block:api-header] { "type": "basic", "title": "Sample app object" } [/block] Example app object in JSON: [block:code] { "codes": [ { "code": "{\n \"createdAt\": 1411491803257,\n \"appKey\": \"Z2xxt0e4Tv29kGG-Ui0Jgg\",\n \"accountId\": \"WXPvOaYERlGkZ4AP6q_onw\",\n \"config\": {\n \"appUrl\": \"\",\n \"category\": \"Utilities\",\n \"version\": \"1.0\",\n \"description\": \"\",\n \"iconUrl\": \"\",\n \"name\": \"TestApp\",\n \"approxAppSize\": \"<2500\",\n \"updatedAt\": 1411491803258,\n \"production\": false\n },\n \"targets\": []\n}", "language": "json" } ] } [/block]
{"_id":"55acb754f93f0c0d005b876b","type":"post","__v":2,"category":"55afb22e902fd51700f5f8bf","hidden":false,"slug":"apps-1","version":"559a61d2dbcfd20d00710b3c","api":{"auth":"required","examples":{"codes":[{"code":"{\n  \"appUrl\": \"\",\n  \"category\": \"Utilities\",\n  \"version\": \"1.0\",\n  \"description\": \"\",\n  \"iconUrl\": \"\",\n  \"name\": \"TestApp\",\n  \"approxAppSize\": \"<2500\",\n  \"production\": false\n}","language":"json"}]},"method":"post","params":[],"results":{"codes":[{"status":201,"language":"json","code":"{\n  \"createdAt\": 1411491803257,\n  \"appKey\": \"Z2xxt0e4Tv29kGG-Ui0Jgg\",\n  \"accountId\": \"WXPvOaYERlGkZ4AP6q_onw\",\n  \"config\": {\n    \"appUrl\": \"\",\n    \"category\": \"Utilities\",\n    \"version\": \"1.0\",\n    \"description\": \"\",\n    \"iconUrl\": \"\",\n    \"name\": \"TestApp\",\n    \"approxAppSize\": null,\n    \"updatedAt\": 1411491803258,\n    \"production\": false\n  },\n  \"targets\": []\n}","name":""},{"status":400,"language":"json","code":"{\n  \"ok\": false,\n  \"request_id\": \"72b3ac91-dde7-497c-8b93-bc4ae9f6a16d\",\n  \"error\": \"invalid-account\"\n}"},{"status":400,"language":"text","code":"{\n  \"status\": \"validation failed\",\n  \"errors\": [\n    {\n      \"object\": \"config\",\n      \"field\": \"name\",\n      \"code\": \"NotNull\"\n    }\n  ]\n}"}]},"settings":"","url":"/apps"},"excerpt":"Returns a list of apps across all the authenticated user's memberships including own apps, and apps from other organizations this user was invited to. The apps are returned in sorted order, with the most recent app appearing last.","githubsync":"","link_url":"","createdAt":"2015-07-20T08:54:44.469Z","order":1,"parentDoc":null,"sync_unique":"","title":"/apps/","updates":[],"user":"55a54dde9c32760d00ca78a8","body":"","isReference":true,"link_external":false,"project":"559a61d2dbcfd20d00710b39","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

post/apps/

Returns a list of apps across all the authenticated user's memberships including own apps, and apps from other organizations this user was invited to. The apps are returned in sorted order, with the most recent app appearing last.


User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"_id":"55a81680ccb09519008a773c","githubsync":"","order":2,"title":"/apps/","type":"get","body":"","excerpt":"Returns a list of apps across all the authenticated user's memberships including own apps, and apps from other organizations this user was invited to. The apps are returned in sorted order, with the most recent app appearing last.","hidden":false,"isReference":true,"sync_unique":"","slug":"moca-rest-api-list-apps","version":"559a61d2dbcfd20d00710b3c","__v":12,"api":{"auth":"required","examples":{"codes":[{"language":"text","code":""}]},"method":"get","params":[],"results":{"codes":[{"language":"json","code":"[\n  {\n    \"createdAt\": 1411491803257,\n    \"appKey\": \"Z2xxt0e4Tv29kGG-Ui0Jgg\",\n    \"accountId\": \"WXPvOaYERlGkZ4AP6q_onw\",\n    \"config\": {\n      \"appUrl\": \"\",\n      \"category\": \"Utilities\",\n      \"version\": \"1.0\",\n      \"description\": \"\",\n      \"iconUrl\": \"\",\n      \"name\": \"TestApp\",\n      \"approxAppSize\": null,\n      \"updatedAt\": 1411491803258,\n      \"production\": false\n    },\n    \"targets\": []\n  },\n  {\n    \"createdAt\": 1432235344340,\n    \"appKey\": \"PQ-sxnixS1juiaIshYmBIg\",\n    \"accountId\": \"WxPvOaYERlGkZ4AP6q_vnw\",\n    \"config\": {\n      \"appUrl\": \"\",\n      \"category\": \"Games\",\n      \"version\": \"2.0\",\n      \"description\": \"Tic Tac Toe Game\",\n      \"iconUrl\": \"\",\n      \"name\": \"TicTacToe\",\n      \"approxAppSize\": \"<2500\",\n      \"updatedAt\": 1432235344340,\n      \"production\": true\n    },\n    \"targets\": []\n  }\n]","name":"","status":200},{"status":400,"language":"json","code":"{\n  \"ok\": false,\n  \"request_id\": \"72b3ac91-dde7-497c-8b93-bc4ae9f6a16d\",\n  \"error\": \"invalid-account\"\n}","name":""}]},"settings":"","url":"/apps"},"createdAt":"2015-07-16T20:39:28.873Z","parentDoc":null,"user":"55a575ebaaf9cf1900114d73","category":"55afb22e902fd51700f5f8bf","link_external":false,"link_url":"","project":"559a61d2dbcfd20d00710b39","updates":[],"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

get/apps/

Returns a list of apps across all the authenticated user's memberships including own apps, and apps from other organizations this user was invited to. The apps are returned in sorted order, with the most recent app appearing last.


User Information

Try It Out

get
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Result Format



{"_id":"55a827d18b9fdf0d00117128","order":3,"type":"get","createdAt":"2015-07-16T21:53:21.009Z","isReference":true,"hidden":false,"link_url":"","updates":[],"editedParams":true,"editedParams2":true,"project":"559a61d2dbcfd20d00710b39","slug":"moca-rest-get-single-app","title":"/apps/:key","category":"55afb22e902fd51700f5f8bf","parentDoc":null,"api":{"settings":"","url":"/apps/:key","auth":"required","examples":{"codes":[]},"method":"get","params":[{"required":true,"type":"string","in":"query","_id":"55acc1aa6b4ff90d00784b47","default":"","desc":"Header: The app's Account Id","name":"X-MOCA-Account-Id"},{"_id":"55a8283172e7120d004ae67f","default":"","desc":"Requested app key","name":"key","required":true,"type":"string","in":"path"}],"results":{"codes":[{"code":"{\n  \"createdAt\": 1432235344340,\n  \"appKey\": \"PQ-sxnixS1juiaIshYmBIg\",\n  \"accountId\": \"WxPvOaYERlGkZ4AP6q_vnw\",\n  \"config\": {\n    \"appUrl\": \"\",\n    \"category\": \"Games\",\n    \"version\": \"2.0\",\n    \"description\": \"Tic Tac Toe Game\",\n    \"iconUrl\": \"\",\n    \"name\": \"TicTacToe\",\n    \"approxAppSize\": \"<2500\",\n    \"updatedAt\": 1432235344340,\n    \"production\": true\n  },\n  \"targets\": []\n}","language":"json","status":200,"name":""},{"name":"","code":"","language":"json","status":403},{"status":404,"language":"text","code":""}]}},"body":"","excerpt":"Retrieves a single app.","githubsync":"","link_external":false,"sync_unique":"","__v":3,"user":"55a575ebaaf9cf1900114d73","version":"559a61d2dbcfd20d00710b3c","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

get/apps/:key

Retrieves a single app.

Path Params

key:
required
string
Requested app key

Query Params

X-MOCA-Account-Id:
required
string
Header: The app's Account Id

User Information

Try It Out

get
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Result Format



{"_id":"55acb7bf6b4ff90d00784b1d","githubsync":"","order":4,"user":"55a54dde9c32760d00ca78a8","version":"559a61d2dbcfd20d00710b3c","slug":"apps-2","title":"/apps/:key","__v":1,"api":{"settings":"","url":"/apps/:key","auth":"required","examples":{"codes":[{"language":"json","code":"{\n  \"appUrl\": \"\",\n  \"category\": \"Utilities\",\n  \"version\": \"1.0\",\n  \"description\": \"\",\n  \"iconUrl\": \"\",\n  \"name\": \"TestApp\",\n  \"approxAppSize\": \"<2500\",\n  \"production\": false\n}"}]},"method":"put","params":[{"desc":"Header: The app's Account Id","name":"X-MOCA-Account-Id","required":true,"type":"string","in":"body","_id":"55acc180f93f0c0d005b87b2","default":""},{"name":"Key","required":true,"type":"string","in":"body","_id":"55acb7bf6b4ff90d00784b1e","default":"","desc":"Requested app key"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n  \"createdAt\": 1411491803257,\n  \"appKey\": \"Z2xxt0e4Tv29kGG-Ui0Jgg\",\n  \"accountId\": \"WXPvOaYERlGkZ4AP6q_onw\",\n  \"config\": {\n    \"appUrl\": \"\",\n    \"category\": \"Utilities\",\n    \"version\": \"1.0\",\n    \"description\": \"\",\n    \"iconUrl\": \"\",\n    \"name\": \"TestApp\",\n    \"approxAppSize\": null,\n    \"updatedAt\": 1411491803258,\n    \"production\": false\n  },\n  \"targets\": []\n}","name":""},{"status":400,"language":"json","code":"{\n  \"ok\": false,\n  \"request_id\": \"72b3ac91-dde7-497c-8b93-bc4ae9f6a16d\",\n  \"error\": \"invalid-app-key\"\n}","name":""},{"code":"{\n  \"status\": \"validation failed\",\n  \"errors\": [\n    {\n      \"object\": \"config\",\n      \"field\": \"name\",\n      \"code\": \"NotNull\"\n    }\n  ]\n}","status":400,"language":"json"},{"status":403,"language":"text","code":""}]}},"createdAt":"2015-07-20T08:56:31.403Z","editedParams2":true,"excerpt":"Updates an existing app.","link_external":false,"updates":[],"sync_unique":"","type":"put","editedParams":true,"hidden":false,"link_url":"","parentDoc":null,"project":"559a61d2dbcfd20d00710b39","body":"","category":"55afb22e902fd51700f5f8bf","isReference":true,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

put/apps/:key

Updates an existing app.

Body Params

X-MOCA-Account-Id:
required
string
Header: The app's Account Id
Key:
required
string
Requested app key

User Information

Try It Out

put
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"_id":"55acb8916b4ff90d00784b21","body":"","excerpt":"Deletes an app from the collection of apps in an account.","isReference":true,"sync_unique":"","title":"/apps/:key","type":"delete","user":"55a54dde9c32760d00ca78a8","__v":1,"api":{"settings":"","url":"/apps/:key","auth":"required","examples":{"codes":[{"language":"text","code":""}]},"method":"delete","params":[{"in":"body","_id":"55acc168f93f0c0d005b87b1","default":"","desc":"Header: The app's Account Id","name":"X-MOCA-Account-Id","required":true,"type":"string"},{"required":true,"type":"string","in":"body","_id":"55acb7bf6b4ff90d00784b1e","default":"","desc":"Requested app key","name":"Key"}],"results":{"codes":[{"status":200,"language":"json","code":"","name":""},{"status":400,"language":"json","code":"{\n  \"ok\": false,\n  \"request_id\": \"72b3ac91-dde7-497c-8b93-bc4ae9f6a16d\",\n  \"error\": \"invalid-app-key\"\n}"}]}},"link_external":false,"link_url":"","order":5,"slug":"appskey","createdAt":"2015-07-20T09:00:01.037Z","editedParams":true,"editedParams2":true,"parentDoc":null,"project":"559a61d2dbcfd20d00710b39","version":"559a61d2dbcfd20d00710b3c","category":"55afb22e902fd51700f5f8bf","githubsync":"","hidden":false,"updates":[],"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

delete/apps/:key

Deletes an app from the collection of apps in an account.

Body Params

X-MOCA-Account-Id:
required
string
Header: The app's Account Id
Key:
required
string
Requested app key

User Information

Try It Out

delete
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}


{"_id":"55acb8cef93f0c0d005b87a3","body":"","category":"55afb22e902fd51700f5f8bf","githubsync":"","project":"559a61d2dbcfd20d00710b39","user":"55a54dde9c32760d00ca78a8","__v":1,"isReference":true,"link_external":false,"link_url":"","slug":"appskeyicon","version":"559a61d2dbcfd20d00710b3c","editedParams":true,"editedParams2":true,"title":"/apps/:key/icon","updates":[],"api":{"method":"post","params":[{"name":"X-MOCA-Account-Id","required":true,"type":"string","in":"body","_id":"55acc11b6b4ff90d00784b46","default":"","desc":"Header: Account Id"},{"in":"path","_id":"55a8283172e7120d004ae67f","default":"","desc":"Requested app key","name":"key","required":true,"type":"string"},{"required":true,"type":"file","in":"body","_id":"55acc11b6b4ff90d00784b45","default":"","desc":"Request Body: New app icon","name":"file"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n  \"createdAt\": 1432235344340,\n  \"appKey\": \"PQ-sxnixS1juiaIshYmBIg\",\n  \"accountId\": \"WxPvOaYERlGkZ4AP6q_vnw\",\n  \"config\": {\n    \"appUrl\": \"\",\n    \"category\": \"Games\",\n    \"version\": \"2.0\",\n    \"description\": \"Tic Tac Toe Game\",\n    \"iconUrl\": \"https://d1ejjz5qg15st4.cloudfront.net/apps/PQ-sxnixS1juiaIshYmBIg/icons/PQ-sxnixS1juiaIshYmBIgqjqbtuzrqk-ck3w9rk8ncq.png\",\n    \"name\": \"TicTacToe\",\n    \"approxAppSize\": \"<2500\",\n    \"updatedAt\": 1432235344340,\n    \"production\": true\n  },\n  \"targets\": []\n}","name":""},{"language":"json","code":"","name":"","status":404}]},"settings":"","url":"/apps/:key","auth":"required","examples":{"codes":[{"language":"json","code":"Example goes here ?","name":""}]}},"order":6,"hidden":false,"parentDoc":null,"sync_unique":"","type":"post","createdAt":"2015-07-20T09:01:02.726Z","excerpt":"Sets the icon of a specific app.","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

post/apps/:key/icon

Sets the icon of a specific app.

Path Params

key:
required
string
Requested app key

Body Params

X-MOCA-Account-Id:
required
string
Header: Account Id
file:
required
file
Request Body: New app icon

User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"_id":"55a5901780c8a30d00b323f6","parentDoc":null,"updates":[],"__v":3,"api":{"settings":"","url":"","auth":"required","params":[],"results":{"codes":[{"name":"","status":200,"language":"json","code":"{}"},{"status":400,"language":"json","code":"{}","name":""}]}},"hidden":false,"link_url":"","slug":"campaigns","sync_unique":"","user":"55a575ebaaf9cf1900114d73","createdAt":"2015-07-14T22:41:27.985Z","isReference":true,"link_external":false,"project":"559a61d2dbcfd20d00710b39","title":"Campaigns","type":"basic","version":"559a61d2dbcfd20d00710b3c","category":"55afb294f202b12100cd9e95","excerpt":"Campaigns represent marketing campaigns within an app that take place in a period of time and usually target a segment of the users.","githubsync":"","body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"The Campaign Object\"\n}\n[/block]\nAttributes:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Obligatory?\",\n    \"h-3\": \"Description\",\n    \"0-0\": \"createdAt\",\n    \"0-3\": \"Creation date (timestamp UTC).\",\n    \"0-1\": \"long\",\n    \"0-2\": \"Autogenerated\",\n    \"1-0\": \"campaignId\",\n    \"1-1\": \"string\",\n    \"1-2\": \"Autogenerated\",\n    \"1-3\": \"Campaign Identifier\",\n    \"2-0\": \"config.name\",\n    \"2-1\": \"string\",\n    \"2-2\": \"Yes\",\n    \"2-3\": \"Name of the campaign\",\n    \"3-0\": \"config.description\",\n    \"3-1\": \"string\",\n    \"3-2\": \"No\",\n    \"3-3\": \"Description of the campaign\",\n    \"4-0\": \"config.updatedAt\",\n    \"4-1\": \"long\",\n    \"4-2\": \"Autogenerated\",\n    \"4-3\": \"Last modification date (timestamp UTC).\",\n    \"5-0\": \"config.startAt\",\n    \"5-1\": \"long\",\n    \"5-2\": \"Yes\",\n    \"5-3\": \"Campaign start date (timestamp UTC).\",\n    \"6-0\": \"config.endAt\",\n    \"6-1\": \"long\",\n    \"6-2\": \"Yes\",\n    \"6-3\": \"Campaign end date (timestamp UTC).\",\n    \"7-0\": \"config.segmentId\",\n    \"7-1\": \"string\",\n    \"7-2\": \"No\",\n    \"7-3\": \"Id of the target segment.\",\n    \"10-0\": \"status\",\n    \"10-1\": \"string\",\n    \"10-2\": \"Autogenerated\",\n    \"10-3\": \"Current status of the campaign.\",\n    \"11-0\": \"statusAt\",\n    \"11-1\": \"long\",\n    \"11-2\": \"Autogenerated\",\n    \"11-3\": \"Last status update date (timestamp UTC).\",\n    \"12-0\": \"appId\",\n    \"12-1\": \"string\",\n    \"12-2\": \"Yes\",\n    \"12-3\": \"Application key.\",\n    \"13-0\": \"numExperiences\",\n    \"13-1\": \"integer\",\n    \"13-2\": \"Autogenerated\",\n    \"13-3\": \"Number of experiences in this campaign.\",\n    \"8-0\": \"config.displayCap*\",\n    \"8-1\": \"integer\",\n    \"8-2\": \"No\",\n    \"8-3\": \"Maximum number of experiences that will be triggered within the campaign.\",\n    \"9-0\": \"config.displayWaitMs*\",\n    \"9-1\": \"integer\",\n    \"9-2\": \"No\",\n    \"9-3\": \"Minimum delay between experiences triggered within the campaign.\"\n  },\n  \"cols\": 4,\n  \"rows\": 14\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Advanced settings\",\n  \"body\": \"Fields marked with * will not be displayed in the response payload if not set.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Sample Campaign Object\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"createdAt\\\": 1437405339834,\\n  \\\"campaignId\\\": \\\"sZHuQ7enqPHJIHKkYnkxMw\\\",\\n  \\\"config\\\": {\\n    \\\"name\\\": \\\"Test\\\",\\n    \\\"description\\\": \\\"Test Campaign\\\",\\n    \\\"updatedAt\\\": 1437405339834,\\n    \\\"startAt\\\": 1437405300000,\\n    \\\"endAt\\\": 1438703200000,\\n    \\\"segmentId\\\": null\\n  },\\n  \\\"status\\\": \\\"New\\\",\\n  \\\"statusAt\\\": 1437405339834,\\n  \\\"updatedAt\\\": 1437405339834,\\n  \\\"appId\\\": \\\"ojvcFIS3kiAyIzcmvN1SvS\\\",\\n  \\\"numExperiences\\\": 12\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]","next":{"description":"","pages":[]},"order":0,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Campaigns

Campaigns represent marketing campaigns within an app that take place in a period of time and usually target a segment of the users.

[block:api-header] { "type": "basic", "title": "The Campaign Object" } [/block] Attributes: [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Obligatory?", "h-3": "Description", "0-0": "createdAt", "0-3": "Creation date (timestamp UTC).", "0-1": "long", "0-2": "Autogenerated", "1-0": "campaignId", "1-1": "string", "1-2": "Autogenerated", "1-3": "Campaign Identifier", "2-0": "config.name", "2-1": "string", "2-2": "Yes", "2-3": "Name of the campaign", "3-0": "config.description", "3-1": "string", "3-2": "No", "3-3": "Description of the campaign", "4-0": "config.updatedAt", "4-1": "long", "4-2": "Autogenerated", "4-3": "Last modification date (timestamp UTC).", "5-0": "config.startAt", "5-1": "long", "5-2": "Yes", "5-3": "Campaign start date (timestamp UTC).", "6-0": "config.endAt", "6-1": "long", "6-2": "Yes", "6-3": "Campaign end date (timestamp UTC).", "7-0": "config.segmentId", "7-1": "string", "7-2": "No", "7-3": "Id of the target segment.", "10-0": "status", "10-1": "string", "10-2": "Autogenerated", "10-3": "Current status of the campaign.", "11-0": "statusAt", "11-1": "long", "11-2": "Autogenerated", "11-3": "Last status update date (timestamp UTC).", "12-0": "appId", "12-1": "string", "12-2": "Yes", "12-3": "Application key.", "13-0": "numExperiences", "13-1": "integer", "13-2": "Autogenerated", "13-3": "Number of experiences in this campaign.", "8-0": "config.displayCap*", "8-1": "integer", "8-2": "No", "8-3": "Maximum number of experiences that will be triggered within the campaign.", "9-0": "config.displayWaitMs*", "9-1": "integer", "9-2": "No", "9-3": "Minimum delay between experiences triggered within the campaign." }, "cols": 4, "rows": 14 } [/block] [block:callout] { "type": "info", "title": "Advanced settings", "body": "Fields marked with * will not be displayed in the response payload if not set." } [/block] [block:api-header] { "type": "basic", "title": "Sample Campaign Object" } [/block] [block:code] { "codes": [ { "code": "{\n \"createdAt\": 1437405339834,\n \"campaignId\": \"sZHuQ7enqPHJIHKkYnkxMw\",\n \"config\": {\n \"name\": \"Test\",\n \"description\": \"Test Campaign\",\n \"updatedAt\": 1437405339834,\n \"startAt\": 1437405300000,\n \"endAt\": 1438703200000,\n \"segmentId\": null\n },\n \"status\": \"New\",\n \"statusAt\": 1437405339834,\n \"updatedAt\": 1437405339834,\n \"appId\": \"ojvcFIS3kiAyIzcmvN1SvS\",\n \"numExperiences\": 12\n}", "language": "json" } ] } [/block]
[block:api-header] { "type": "basic", "title": "The Campaign Object" } [/block] Attributes: [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Obligatory?", "h-3": "Description", "0-0": "createdAt", "0-3": "Creation date (timestamp UTC).", "0-1": "long", "0-2": "Autogenerated", "1-0": "campaignId", "1-1": "string", "1-2": "Autogenerated", "1-3": "Campaign Identifier", "2-0": "config.name", "2-1": "string", "2-2": "Yes", "2-3": "Name of the campaign", "3-0": "config.description", "3-1": "string", "3-2": "No", "3-3": "Description of the campaign", "4-0": "config.updatedAt", "4-1": "long", "4-2": "Autogenerated", "4-3": "Last modification date (timestamp UTC).", "5-0": "config.startAt", "5-1": "long", "5-2": "Yes", "5-3": "Campaign start date (timestamp UTC).", "6-0": "config.endAt", "6-1": "long", "6-2": "Yes", "6-3": "Campaign end date (timestamp UTC).", "7-0": "config.segmentId", "7-1": "string", "7-2": "No", "7-3": "Id of the target segment.", "10-0": "status", "10-1": "string", "10-2": "Autogenerated", "10-3": "Current status of the campaign.", "11-0": "statusAt", "11-1": "long", "11-2": "Autogenerated", "11-3": "Last status update date (timestamp UTC).", "12-0": "appId", "12-1": "string", "12-2": "Yes", "12-3": "Application key.", "13-0": "numExperiences", "13-1": "integer", "13-2": "Autogenerated", "13-3": "Number of experiences in this campaign.", "8-0": "config.displayCap*", "8-1": "integer", "8-2": "No", "8-3": "Maximum number of experiences that will be triggered within the campaign.", "9-0": "config.displayWaitMs*", "9-1": "integer", "9-2": "No", "9-3": "Minimum delay between experiences triggered within the campaign." }, "cols": 4, "rows": 14 } [/block] [block:callout] { "type": "info", "title": "Advanced settings", "body": "Fields marked with * will not be displayed in the response payload if not set." } [/block] [block:api-header] { "type": "basic", "title": "Sample Campaign Object" } [/block] [block:code] { "codes": [ { "code": "{\n \"createdAt\": 1437405339834,\n \"campaignId\": \"sZHuQ7enqPHJIHKkYnkxMw\",\n \"config\": {\n \"name\": \"Test\",\n \"description\": \"Test Campaign\",\n \"updatedAt\": 1437405339834,\n \"startAt\": 1437405300000,\n \"endAt\": 1438703200000,\n \"segmentId\": null\n },\n \"status\": \"New\",\n \"statusAt\": 1437405339834,\n \"updatedAt\": 1437405339834,\n \"appId\": \"ojvcFIS3kiAyIzcmvN1SvS\",\n \"numExperiences\": 12\n}", "language": "json" } ] } [/block]
{"_id":"55ad172cf93f0c0d005b88a5","isReference":true,"sync_unique":"","type":"post","user":"55a54dde9c32760d00ca78a8","hidden":false,"body":"","createdAt":"2015-07-20T15:43:40.465Z","editedParams":true,"githubsync":"","link_external":false,"next":{"description":"","pages":[]},"__v":1,"title":"/campaigns/","updates":[],"order":1,"category":"55afb294f202b12100cd9e95","editedParams2":true,"link_url":"","parentDoc":null,"project":"559a61d2dbcfd20d00710b39","slug":"campaigns-2","api":{"examples":{"codes":[{"language":"json","code":"{\n  \"name\": \"Summer Party 2015\",\n  \"description\": \"Campaign for summer 2015\",\n  \"group\": null,\n  \"startAt\": 1437405300000,\n  \"endAt\": 1439503800000,\n  \"segmentId\": null,\n  \"displayCap\": null,\n  \"displayWaitMs\": null\n}"}]},"method":"post","params":[{"type":"string","_id":"55accc9618eefd0d0071d5a5","default":"","desc":"Header: The campaign's Account Id","in":"body","name":"X-MOCA-Account-Id","ref":"","required":true},{"required":true,"type":"string","_id":"55ad11b7fb7b3c1900373a6d","default":"","desc":"Header: The campaign's App Key","in":"body","name":"X-MOCA-App-Key","ref":""}],"results":{"codes":[{"status":201,"language":"json","code":"[\n  {\n    \"createdAt\": 1437405834339,\n    \"campaignId\": \"nqPHJYnkxMwIHKksZHuQ7e\",\n    \"config\": {\n      \"name\": \"Summer Party 2015\",\n      \"description\": \"Campaign for summer 2015\",\n      \"group\": null,\n      \"updatedAt\": 1437405834339,\n      \"startAt\": 1437405300000,\n      \"endAt\": 1439503800000,\n      \"segmentId\": null\n    },\n    \"status\": \"Active\",\n    \"statusAt\": 1437405339834,\n    \"updatedAt\": 1437405339834,\n    \"appId\": \"ojvcFIS3kiAyIzcmvN1SvS\",\n    \"numExperiences\": 4\n  }\n]","name":""},{"status":400,"language":"json","code":"{\n  \"ok\": false,\n  \"request_id\": \"fcf52425-5ade-4d9a-80de-0bc4d910ea32\",\n  \"error\": \"invalid-app-key\"\n}","name":""},{"status":403,"language":"text","code":""}]},"settings":"","url":"/campaigns","auth":"required"},"version":"559a61d2dbcfd20d00710b3c","excerpt":"Creates a new campaign.","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

post/campaigns/

Creates a new campaign.

Body Params

X-MOCA-Account-Id:
required
string
Header: The campaign's Account Id
X-MOCA-App-Key:
required
string
Header: The campaign's App Key

User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"_id":"55ad11b7fb7b3c1900373a6c","link_external":false,"order":2,"api":{"auth":"required","examples":{"codes":[{"language":"text","code":""}]},"method":"get","params":[{"_id":"55accc9618eefd0d0071d5a5","default":"","desc":"Header: The campaign's Account Id","in":"query","name":"X-MOCA-Account-Id","ref":"","required":true,"type":"string"},{"type":"string","_id":"55ad11b7fb7b3c1900373a6d","default":"","desc":"Header: The campaign's App Key","in":"query","name":"X-MOCA-App-Key","ref":"","required":true},{"required":false,"type":"int","_id":"55ad1249f93f0c0d005b889a","default":"0","desc":"First result for paged queries","in":"query","name":"firstResult","ref":""},{"name":"maxResults","ref":"","required":false,"type":"int","_id":"55ad1249f93f0c0d005b8899","default":"<All>","desc":"Maximum results for paged queries","in":"query"}],"results":{"codes":[{"status":200,"language":"json","code":"[\n  {\n    \"createdAt\": 1437405339834,\n    \"campaignId\": \"sZHuQ7enqPHJIHKkYnkxMw\",\n    \"config\": {\n      \"name\": \"Test\",\n      \"description\": \"Test Campaign\",\n      \"group\": null,\n      \"updatedAt\": 1437405339834,\n      \"startAt\": 1437405300000,\n      \"endAt\": 1438703200000,\n      \"segmentId\": null\n    },\n    \"status\": \"New\",\n    \"statusAt\": 1437405339834,\n    \"updatedAt\": 1437405339834,\n    \"appId\": \"ojvcFIS3kiAyIzcmvN1SvS\",\n    \"numExperiences\": 12\n  },\n  {\n    \"createdAt\": 1437405834339,\n    \"campaignId\": \"nqPHJYnkxMwIHKksZHuQ7e\",\n    \"config\": {\n      \"name\": \"Summer Party 2015\",\n      \"description\": \"Campaign for summer 2015\",\n      \"group\": null,\n      \"updatedAt\": 1437405834339,\n      \"startAt\": 1437405300000,\n      \"endAt\": 1439503800000,\n      \"segmentId\": null\n    },\n    \"status\": \"Active\",\n    \"statusAt\": 1437405339834,\n    \"updatedAt\": 1437405339834,\n    \"appId\": \"ojvcFIS3kiAyIzcmvN1SvS\",\n    \"numExperiences\": 4\n  }\n]","name":""},{"code":"{\n  \"ok\": false,\n  \"request_id\": \"fcf52425-5ade-4d9a-80de-0bc4d910ea32\",\n  \"error\": \"invalid-app-key\"\n}","name":"","status":400,"language":"json"},{"status":403,"language":"text","code":""}]},"settings":"","url":"/campaigns"},"body":"","createdAt":"2015-07-20T15:20:23.571Z","editedParams2":true,"hidden":false,"link_url":"","updates":[],"user":"55a54dde9c32760d00ca78a8","version":"559a61d2dbcfd20d00710b3c","__v":1,"githubsync":"","isReference":true,"project":"559a61d2dbcfd20d00710b39","parentDoc":null,"slug":"campaigns-1","sync_unique":"","title":"/campaigns/","category":"55afb294f202b12100cd9e95","editedParams":true,"excerpt":"Retrieves a list of all campaigns for a specific app. Supports paging.","type":"get","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

get/campaigns/

Retrieves a list of all campaigns for a specific app. Supports paging.

Query Params

X-MOCA-Account-Id:
required
string
Header: The campaign's Account Id
X-MOCA-App-Key:
required
string
Header: The campaign's App Key
firstResult:
integer0
First result for paged queries
maxResults:
integer<All>
Maximum results for paged queries

User Information

Try It Out

get
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Result Format



{"_id":"55ad1a9d18eefd0d0071d67d","isReference":true,"link_external":false,"slug":"campaignsactive","updates":[],"user":"55a54dde9c32760d00ca78a8","__v":0,"category":"55afb294f202b12100cd9e95","excerpt":"Retrieves the list of active campaigns for a specific app.","project":"559a61d2dbcfd20d00710b39","type":"get","body":"","hidden":false,"link_url":"","editedParams":true,"parentDoc":null,"title":"/campaigns/active","editedParams2":true,"githubsync":"","order":3,"sync_unique":"","version":"559a61d2dbcfd20d00710b3c","api":{"url":"/campaigns/active","auth":"required","examples":{"codes":[{"language":"text","code":""}]},"method":"get","params":[{"type":"string","name":"X-MOCA-Account-Id","in":"query","_id":"55accc9618eefd0d0071d5a5","required":true,"desc":"Header: The campaign's Account Id","default":""},{"_id":"55ad11b7fb7b3c1900373a6d","required":true,"desc":"Header: The campaign's App Key","default":"","type":"string","name":"X-MOCA-App-Key","in":"query"},{"_id":"55ad1249f93f0c0d005b889a","required":false,"desc":"First result for paged queries","default":"0","type":"int","name":"firstResult","in":"query"},{"_id":"55ad1249f93f0c0d005b8899","required":false,"desc":"Maximum results for paged queries","default":"<All>","type":"int","name":"maxResults","in":"query"}],"results":{"codes":[{"status":200,"language":"json","code":"[\n  {\n    \"createdAt\": 1437405339834,\n    \"campaignId\": \"sZHuQ7enqPHJIHKkYnkxMw\",\n    \"config\": {\n      \"name\": \"Test\",\n      \"description\": \"Test Campaign\",\n      \"group\": null,\n      \"updatedAt\": 1437405339834,\n      \"startAt\": 1437405300000,\n      \"endAt\": 1438703200000,\n      \"segmentId\": null\n    },\n    \"status\": \"Active\",\n    \"statusAt\": 1437405339834,\n    \"updatedAt\": 1437405339834,\n    \"appId\": \"ojvcFIS3kiAyIzcmvN1SvS\",\n    \"numExperiences\": 12\n  },\n  {\n    \"createdAt\": 1437405834339,\n    \"campaignId\": \"nqPHJYnkxMwIHKksZHuQ7e\",\n    \"config\": {\n      \"name\": \"Summer Party 2015\",\n      \"description\": \"Campaign for summer 2015\",\n      \"group\": null,\n      \"updatedAt\": 1437405834339,\n      \"startAt\": 1437405300000,\n      \"endAt\": 1439503800000,\n      \"segmentId\": null\n    },\n    \"status\": \"Active\",\n    \"statusAt\": 1437405339834,\n    \"updatedAt\": 1437405339834,\n    \"appId\": \"ojvcFIS3kiAyIzcmvN1SvS\",\n    \"numExperiences\": 4\n  }\n]","name":""},{"status":400,"language":"json","code":"{\n  \"ok\": false,\n  \"request_id\": \"fcf52425-5ade-4d9a-80de-0bc4d910ea32\",\n  \"error\": \"invalid-app-key\"\n}","name":""},{"status":403,"language":"text","code":""}]},"settings":""},"createdAt":"2015-07-20T15:58:21.305Z","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

get/campaigns/active

Retrieves the list of active campaigns for a specific app.

Query Params

X-MOCA-Account-Id:
required
string
Header: The campaign's Account Id
X-MOCA-App-Key:
required
string
Header: The campaign's App Key
firstResult:
integer0
First result for paged queries
maxResults:
integer<All>
Maximum results for paged queries

User Information

Try It Out

get
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Result Format



{"_id":"55ad155e18eefd0d0071d671","isReference":true,"link_external":false,"__v":0,"body":"","excerpt":"Retrieves the list of campaigns that match the requested criteria.","githubsync":"","hidden":false,"title":"/campaigns/search","createdAt":"2015-07-20T15:35:58.105Z","project":"559a61d2dbcfd20d00710b39","slug":"campaignssearch","user":"55a54dde9c32760d00ca78a8","version":"559a61d2dbcfd20d00710b3c","editedParams":true,"order":4,"parentDoc":null,"sync_unique":"","type":"post","updates":[],"api":{"method":"post","params":[{"default":"","type":"string","name":"X-MOCA-Account-Id","in":"body","_id":"55accc9618eefd0d0071d5a5","required":true,"desc":"Header: The campaign's Account Id"},{"in":"body","_id":"55ad11b7fb7b3c1900373a6d","required":true,"desc":"Header: The campaign's App Key","default":"","type":"string","name":"X-MOCA-App-Key"}],"results":{"codes":[{"language":"json","code":"[\n  {\n    \"createdAt\": 1437405834339,\n    \"campaignId\": \"nqPHJYnkxMwIHKksZHuQ7e\",\n    \"config\": {\n      \"name\": \"Summer Party 2015\",\n      \"description\": \"Campaign for summer 2015\",\n      \"group\": null,\n      \"updatedAt\": 1437405834339,\n      \"startAt\": 1437405300000,\n      \"endAt\": 1439503800000,\n      \"segmentId\": null\n    },\n    \"status\": \"Active\",\n    \"statusAt\": 1437405339834,\n    \"updatedAt\": 1437405339834,\n    \"appId\": \"ojvcFIS3kiAyIzcmvN1SvS\",\n    \"numExperiences\": 4\n  }\n]","name":"","status":200},{"status":400,"language":"json","code":"{\n  \"ok\": false,\n  \"request_id\": \"fcf52425-5ade-4d9a-80de-0bc4d910ea32\",\n  \"error\": \"invalid-app-key\"\n}","name":""},{"status":403,"language":"text","code":""}]},"settings":"","url":"/campaigns/search","auth":"required","examples":{"codes":[{"language":"json","code":"{\n  \"firstResult\": 0,\n  \"maxResult\": 10,\n  \"name\": \"Summer%\",\n  \"description\": \"%2015%\",\n  \"group\": null,\n  \"startAt\": 1403256140157,\n  \"endAt\": 1439050000000,\n  \"segmentId\": 'bb0MYHqm-4Jpj4pgAt7ZS9',\n  \"status\": [ \"New\", \"Active\" ]\n}"}]}},"category":"55afb294f202b12100cd9e95","editedParams2":true,"link_url":"","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

post/campaigns/search

Retrieves the list of campaigns that match the requested criteria.

Body Params

X-MOCA-Account-Id:
required
string
Header: The campaign's Account Id
X-MOCA-App-Key:
required
string
Header: The campaign's App Key

User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"_id":"55ad163efb7b3c1900373a73","createdAt":"2015-07-20T15:39:42.112Z","editedParams2":true,"slug":"campaignsid","version":"559a61d2dbcfd20d00710b3c","link_url":"","next":{"description":"","pages":[]},"project":"559a61d2dbcfd20d00710b39","__v":1,"api":{"auth":"required","examples":{"codes":[{"language":"json","code":""}]},"method":"get","params":[{"name":"X-MOCA-Account-Id","ref":"","required":true,"type":"string","_id":"55accc9618eefd0d0071d5a5","default":"","desc":"Header: The campaign's Account Id","in":"query"},{"_id":"55ad11b7fb7b3c1900373a6d","default":"","desc":"Header: The campaign's App Key","in":"query","name":"X-MOCA-App-Key","ref":"","required":true,"type":"string"},{"type":"string","_id":"55ad163efb7b3c1900373a74","default":"","desc":"Campaign Id","in":"path","name":"id","ref":"","required":true}],"results":{"codes":[{"status":200,"language":"json","code":"[\n  {\n    \"createdAt\": 1437405834339,\n    \"campaignId\": \"nqPHJYnkxMwIHKksZHuQ7e\",\n    \"config\": {\n      \"name\": \"Summer Party 2015\",\n      \"description\": \"Campaign for summer 2015\",\n      \"group\": null,\n      \"updatedAt\": 1437405834339,\n      \"startAt\": 1437405300000,\n      \"endAt\": 1439503800000,\n      \"segmentId\": null,\n      \"displayCap\": 5,\n      \"displayWaitMs\": 3600000\n    },\n    \"status\": \"Active\",\n    \"statusAt\": 1437405339834,\n    \"updatedAt\": 1437405339834,\n    \"appId\": \"ojvcFIS3kiAyIzcmvN1SvS\",\n    \"numExperiences\": 4\n  }\n]","name":""},{"status":400,"language":"json","code":"{\n  \"ok\": false,\n  \"request_id\": \"fcf52425-5ade-4d9a-80de-0bc4d910ea32\",\n  \"error\": \"invalid-app-key\"\n}","name":""},{"status":403,"language":"text","code":""}]},"settings":"","url":"/campaigns/:id"},"editedParams":true,"hidden":false,"isReference":true,"updates":[],"user":"55a54dde9c32760d00ca78a8","sync_unique":"","type":"get","body":"","category":"55afb294f202b12100cd9e95","excerpt":"Retrieves the details of an existing campaign.","parentDoc":null,"githubsync":"","link_external":false,"order":5,"title":"/campaigns/:id","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

get/campaigns/:id

Retrieves the details of an existing campaign.

Path Params

id:
required
string
Campaign Id

Query Params

X-MOCA-Account-Id:
required
string
Header: The campaign's Account Id
X-MOCA-App-Key:
required
string
Header: The campaign's App Key

User Information

Try It Out

get
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Result Format



{"_id":"55ad184f18eefd0d0071d677","api":{"settings":"","url":"/campaigns/:id","auth":"required","examples":{"codes":[{"language":"json","code":"{\n  \"name\": \"Summer Party 2015\",\n  \"description\": \"Campaign for summer 2015\",\n  \"group\": null,\n  \"startAt\": 1437405300000,\n  \"endAt\": 1439503800000,\n  \"segmentId\": null,\n  \"displayCap\": 5,\n  \"displayWaitMs\": null\n}"}]},"method":"put","params":[{"ref":"","required":true,"type":"string","_id":"55accc9618eefd0d0071d5a5","default":"","desc":"Header: The campaign's Account Id","in":"body","name":"X-MOCA-Account-Id"},{"ref":"","required":true,"type":"string","_id":"55ad11b7fb7b3c1900373a6d","default":"","desc":"Header: The campaign's App Key","in":"body","name":"X-MOCA-App-Key"},{"ref":"","required":true,"type":"string","_id":"55ad163efb7b3c1900373a74","default":"","desc":"Campaign Id","in":"path","name":"id"}],"results":{"codes":[{"status":200,"language":"json","code":"[\n  {\n    \"createdAt\": 1437405834339,\n    \"campaignId\": \"nqPHJYnkxMwIHKksZHuQ7e\",\n    \"config\": {\n      \"name\": \"Summer Party 2015\",\n      \"description\": \"Campaign for summer 2015\",\n      \"group\": null,\n      \"updatedAt\": 1437405834339,\n      \"startAt\": 1437405300000,\n      \"endAt\": 1439503800000,\n      \"segmentId\": null,\n      \"displayCap\": 5\n    },\n    \"status\": \"Active\",\n    \"statusAt\": 1437405339834,\n    \"updatedAt\": 1437405339834,\n    \"appId\": \"ojvcFIS3kiAyIzcmvN1SvS\",\n    \"numExperiences\": 4\n  }\n]","name":""},{"status":400,"language":"json","code":"{\n  \"ok\": false,\n  \"request_id\": \"fcf52425-5ade-4d9a-80de-0bc4d910ea32\",\n  \"error\": \"invalid-campaign\"\n}","name":""},{"status":403,"language":"text","code":""}]}},"editedParams2":true,"hidden":false,"type":"put","editedParams":true,"excerpt":"Updates the specified campaign.","githubsync":"","parentDoc":null,"body":"","link_external":false,"project":"559a61d2dbcfd20d00710b39","sync_unique":"","version":"559a61d2dbcfd20d00710b3c","__v":1,"category":"55afb294f202b12100cd9e95","createdAt":"2015-07-20T15:48:31.832Z","isReference":true,"link_url":"","next":{"pages":[],"description":""},"order":6,"slug":"campaignsid-1","title":"/campaigns/:id","updates":[],"user":"55a54dde9c32760d00ca78a8","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

put/campaigns/:id

Updates the specified campaign.

Path Params

id:
required
string
Campaign Id

Body Params

X-MOCA-Account-Id:
required
string
Header: The campaign's Account Id
X-MOCA-App-Key:
required
string
Header: The campaign's App Key

User Information

Try It Out

put
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"_id":"55ad18b618eefd0d0071d678","link_url":"","project":"559a61d2dbcfd20d00710b39","sync_unique":"","type":"delete","updates":[],"category":"55afb294f202b12100cd9e95","createdAt":"2015-07-20T15:50:14.966Z","githubsync":"","version":"559a61d2dbcfd20d00710b3c","body":"","editedParams":true,"isReference":true,"slug":"campaignsid-2","__v":0,"api":{"settings":"","url":"/campaigns/:id","auth":"required","examples":{"codes":[{"language":"json","code":""}]},"method":"delete","params":[{"default":"","type":"string","name":"X-MOCA-Account-Id","in":"body","_id":"55accc9618eefd0d0071d5a5","required":true,"desc":"Header: The campaign's Account Id"},{"required":true,"desc":"Header: The campaign's App Key","default":"","type":"string","name":"X-MOCA-App-Key","in":"body","_id":"55ad11b7fb7b3c1900373a6d"},{"desc":"Campaign Id","name":"id","required":true,"type":"string","in":"path","_id":"55ad163efb7b3c1900373a74","default":""}],"results":{"codes":[{"code":"","language":"json","status":200,"name":""},{"name":"","code":"{\n  \"ok\": false,\n  \"request_id\": \"fcf52425-5ade-4d9a-80de-0bc4d910ea32\",\n  \"error\": \"invalid-campaign\"\n}","language":"json","status":400},{"code":"","language":"text","status":403},{"code":"","language":"text","status":404}]}},"user":"55a54dde9c32760d00ca78a8","excerpt":"Deletes the specified campaign.","order":7,"parentDoc":null,"title":"/campaigns/:id","editedParams2":true,"hidden":false,"link_external":false,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

delete/campaigns/:id

Deletes the specified campaign.

Path Params

id:
required
string
Campaign Id

Body Params

X-MOCA-Account-Id:
required
string
Header: The campaign's Account Id
X-MOCA-App-Key:
required
string
Header: The campaign's App Key

User Information

Try It Out

delete
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}


{"_id":"55ad194618eefd0d0071d67a","editedParams":true,"parentDoc":null,"project":"559a61d2dbcfd20d00710b39","__v":0,"body":"","isReference":true,"link_external":false,"slug":"campaignsidstart","sync_unique":"","title":"/campaigns/:id/start","type":"put","category":"55afb294f202b12100cd9e95","excerpt":"Starts a campaign.","githubsync":"","hidden":false,"updates":[],"user":"55a54dde9c32760d00ca78a8","createdAt":"2015-07-20T15:52:38.787Z","editedParams2":true,"order":8,"version":"559a61d2dbcfd20d00710b3c","api":{"params":[{"in":"body","_id":"55accc9618eefd0d0071d5a5","required":true,"desc":"Header: The campaign's Account Id","default":"","type":"string","name":"X-MOCA-Account-Id"},{"type":"string","name":"X-MOCA-App-Key","in":"body","_id":"55ad11b7fb7b3c1900373a6d","required":true,"desc":"Header: The campaign's App Key","default":""},{"_id":"55ad163efb7b3c1900373a74","default":"","desc":"Campaign Id","name":"id","required":true,"type":"string","in":"path"}],"results":{"codes":[{"status":200,"language":"json","code":"","name":""},{"status":400,"language":"json","code":"{\n  \"ok\": false,\n  \"request_id\": \"fcf52425-5ade-4d9a-80de-0bc4d910ea32\",\n  \"error\": \"invalid-campaign\"\n}","name":""},{"status":403,"language":"text","code":""},{"status":404,"language":"text","code":""}]},"settings":"","url":"/campaigns/:id/start","auth":"required","examples":{"codes":[{"code":"","language":"json"}]},"method":"put"},"link_url":"","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

put/campaigns/:id/start

Starts a campaign.

Path Params

id:
required
string
Campaign Id

Body Params

X-MOCA-Account-Id:
required
string
Header: The campaign's Account Id
X-MOCA-App-Key:
required
string
Header: The campaign's App Key

User Information

Try It Out

put
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}


{"_id":"55ad19a5fb7b3c1900373a7a","link_external":false,"order":9,"parentDoc":null,"slug":"campaignsidstop","__v":0,"body":"","createdAt":"2015-07-20T15:54:13.843Z","excerpt":"Stops a campaign.","title":"/campaigns/:id/stop","updates":[],"user":"55a54dde9c32760d00ca78a8","api":{"results":{"codes":[{"status":200,"language":"json","code":"","name":""},{"status":400,"language":"json","code":"{\n  \"ok\": false,\n  \"request_id\": \"fcf52425-5ade-4d9a-80de-0bc4d910ea32\",\n  \"error\": \"invalid-campaign\"\n}","name":""},{"status":403,"language":"text","code":""},{"status":404,"language":"text","code":""}]},"settings":"","url":"/campaigns/:id/stop","auth":"required","examples":{"codes":[{"language":"json","code":""}]},"method":"put","params":[{"type":"string","name":"X-MOCA-Account-Id","in":"body","_id":"55accc9618eefd0d0071d5a5","required":true,"desc":"Header: The campaign's Account Id","default":""},{"_id":"55ad11b7fb7b3c1900373a6d","required":true,"desc":"Header: The campaign's App Key","default":"","type":"string","name":"X-MOCA-App-Key","in":"body"},{"default":"","desc":"Campaign Id","name":"id","required":true,"type":"string","in":"path","_id":"55ad163efb7b3c1900373a74"}]},"editedParams":true,"editedParams2":true,"project":"559a61d2dbcfd20d00710b39","link_url":"","version":"559a61d2dbcfd20d00710b3c","category":"55afb294f202b12100cd9e95","githubsync":"","hidden":false,"isReference":true,"sync_unique":"","type":"put","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

put/campaigns/:id/stop

Stops a campaign.

Path Params

id:
required
string
Campaign Id

Body Params

X-MOCA-Account-Id:
required
string
Header: The campaign's Account Id
X-MOCA-App-Key:
required
string
Header: The campaign's App Key

User Information

Try It Out

put
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}


{"_id":"55adfa692723e51900898eeb","type":"post","__v":0,"excerpt":"Creates a new experience.","githubsync":"","hidden":false,"isReference":true,"body":"","createdAt":"2015-07-21T07:53:13.664Z","project":"559a61d2dbcfd20d00710b39","slug":"campaignsidexperiences","updates":[],"user":"55a54dde9c32760d00ca78a8","version":"559a61d2dbcfd20d00710b3c","category":"55afb294f202b12100cd9e95","order":10,"parentDoc":null,"title":"/campaigns/:id/experiences","sync_unique":"","api":{"settings":"","url":"/campaigns/:id/experiences","auth":"required","examples":{"codes":[{"language":"json","code":"{\n  \"config\": {\n    \"category\": null,\n    \"description\": null,\n    \"name\": \"Enter Place Demo\",\n    \"repeat\": \"NextDay\",\n    \"updatedAt\": 1424351489582,\n    \"enabled\": true,\n    \"exactlyOnce\": false\n  },\n  \"action\": {\n    \"@type\": \"SendLocalMessageAction\",\n    \"contentType\": \"text/plain\",\n    \"content\": {\n      \"default\": \"Welcome to our Office!\"\n    },\n    \"bgAlert\": {}\n  },\n  \"trigger\": {\n    \"@type\": \"EnterPlaceTrigger\",\n    \"placeId\": \"8Q9mI6TyKhGXIMvlz1jr7g\"\n  }\n}"}]},"method":"post","params":[{"_id":"55accc9618eefd0d0071d5a5","required":true,"desc":"Header: The campaign's Account Id","default":"","type":"string","name":"X-MOCA-Account-Id","in":"body"},{"required":true,"desc":"Header: The campaign's App Key","default":"","type":"string","name":"X-MOCA-App-Key","in":"body","_id":"55ad11b7fb7b3c1900373a6d"},{"type":"string","in":"path","_id":"55adfa692723e51900898eec","default":"","desc":"Campaign Id","name":"id","required":true}],"results":{"codes":[{"name":"","status":201,"language":"json","code":"{\n  \"createdAt\": 1424351489581,\n  \"experienceId\": \"PT7Swn6QcTw0dY6-sMAgJQ\",\n  \"appKey\": \"AeZQ_Wm9iW2v7QgvdTtmx1\",\n  \"config\": {\n    \"category\": null,\n    \"description\": null,\n    \"name\": \"Enter Place Demo\",\n    \"repeat\": \"NextDay\",\n    \"updatedAt\": 1424351489582,\n    \"enabled\": true,\n    \"exactlyOnce\": false\n  },\n  \"campaignId\": \"klyRDN-RPe7wcaAsNJ5LLQ\",\n  \"segmentId\": null,\n  \"action\": {\n    \"@type\": \"SendLocalMessageAction\",\n    \"contentType\": \"text/plain\",\n    \"content\": {\n      \"default\": \"Welcome to our Office!\"\n    },\n    \"bgAlert\": {}\n  },\n  \"trigger\": {\n    \"@type\": \"EnterPlaceTrigger\",\n    \"placeId\": \"8Q9mI6TyKhGXIMvlz1jr7g\"\n  }\n}"},{"language":"json","code":"{\n  \"ok\": false,\n  \"request_id\": \"fcf52425-5ade-4d9a-80de-0bc4d910ea32\",\n  \"error\": \"invalid-message\"\n}","name":"","status":400},{"status":403,"language":"text","code":""},{"status":404,"language":"text","code":""}]}},"editedParams":true,"editedParams2":true,"link_external":false,"link_url":"","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

post/campaigns/:id/experiences

Creates a new experience.

Path Params

id:
required
string
Campaign Id

Body Params

X-MOCA-Account-Id:
required
string
Header: The campaign's Account Id
X-MOCA-App-Key:
required
string
Header: The campaign's App Key

User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"_id":"55adfcbaf302af23000ac041","category":"55afb294f202b12100cd9e95","createdAt":"2015-07-21T08:03:06.522Z","githubsync":"","isReference":true,"link_url":"","order":11,"body":"","editedParams":true,"parentDoc":null,"type":"get","version":"559a61d2dbcfd20d00710b3c","api":{"params":[{"required":true,"desc":"Header: The campaign's Account Id","default":"","type":"string","name":"X-MOCA-Account-Id","in":"query","_id":"55accc9618eefd0d0071d5a5"},{"name":"X-MOCA-App-Key","in":"query","_id":"55ad11b7fb7b3c1900373a6d","required":true,"desc":"Header: The campaign's App Key","default":"","type":"string"},{"name":"id","in":"path","_id":"55adfa692723e51900898eec","required":true,"desc":"Campaign Id","default":"","type":"string"}],"results":{"codes":[{"code":"[\n  {\n    \"createdAt\": 1424351489581,\n    \"experienceId\": \"PT7Swn6QcTw0dY6-sMAgJQ\",\n    \"appKey\": \"AeZQ_Wm9iW2v7QgvdTtmx1\",\n    \"config\": {\n      \"category\": null,\n      \"description\": null,\n      \"name\": \"Enter Place Demo\",\n      \"repeat\": \"NextDay\",\n      \"updatedAt\": 1424351489582,\n      \"enabled\": true,\n      \"exactlyOnce\": false\n    },\n    \"campaignId\": \"klyRDN-RPe7wcaAsNJ5LLQ\",\n    \"segmentId\": null,\n    \"action\": {\n      \"@type\": \"SendLocalMessageAction\",\n      \"contentType\": \"text/plain\",\n      \"content\": {\n        \"default\": \"Welcome to our Office!\"\n      },\n      \"bgAlert\": {}\n    },\n    \"trigger\": {\n      \"@type\": \"EnterPlaceTrigger\",\n      \"placeId\": \"8Q9mI6TyKhGXIMvlz1jr7g\"\n    }\n  },\n  {\n    \"createdAt\": 1424345135218,\n    \"experienceId\": \"AVvfRnfqDSS0MvAK_c8QhA\",\n    \"appKey\": \"AeZQ_Wm9iW2v7QgvdTtmx1\",\n    \"config\": {\n      \"category\": null,\n      \"description\": null,\n      \"name\": \"URL Beacon\",\n      \"repeat\": \"After1Min\",\n      \"updatedAt\": 1424346307659,\n      \"enabled\": true,\n      \"exactlyOnce\": false\n    },\n    \"campaignId\": \"klyRDN-RPe7wcaAsNJ5LLQ\",\n    \"segmentId\": null,\n    \"action\": {\n      \"@type\": \"OpenUrlAction\",\n      \"contentType\": \"text/x-url\",\n      \"content\": {\n        \"default\": \"http://mocaplatform.com\"\n      },\n      \"bgAlert\": {\n        \"default\": \"Hey!, check out our website!\"\n      }\n    },\n    \"trigger\": {\n      \"@type\": \"BeaconProximityTrigger\",\n      \"beaconId\": \"TFa6DzRsY8Ub-DdbVP8-nQ\",\n      \"proximity\": \"Near\"\n    }\n  }\n]","name":"","status":200,"language":"json"},{"status":400,"language":"json","code":"{\n  \"ok\": false,\n  \"request_id\": \"fcf52425-5ade-4d9a-80de-0bc4d910ea32\",\n  \"error\": \"invalid-campaign-key\"\n}","name":""},{"status":403,"language":"text","code":""}]},"settings":"","url":"/campaigns/:id/experiences","auth":"required","examples":{"codes":[{"language":"json","code":""}]},"method":"get"},"project":"559a61d2dbcfd20d00710b39","title":"/campaigns/:id/experiences","user":"55a54dde9c32760d00ca78a8","__v":0,"editedParams2":true,"excerpt":"Retrieves the list of active campaigns for a specific app.","hidden":false,"link_external":false,"slug":"campaignsidexperiences-1","sync_unique":"","updates":[],"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

get/campaigns/:id/experiences

Retrieves the list of active campaigns for a specific app.

Path Params

id:
required
string
Campaign Id

Query Params

X-MOCA-Account-Id:
required
string
Header: The campaign's Account Id
X-MOCA-App-Key:
required
string
Header: The campaign's App Key

User Information

Try It Out

get
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Result Format



{"_id":"55adfda82723e51900898ef5","parentDoc":null,"sync_unique":"","editedParams":true,"editedParams2":true,"link_url":"","user":"55a54dde9c32760d00ca78a8","version":"559a61d2dbcfd20d00710b3c","category":"55afb294f202b12100cd9e95","githubsync":"","hidden":false,"excerpt":"Updates the specified experience.","isReference":true,"link_external":false,"project":"559a61d2dbcfd20d00710b39","slug":"campaignsidexperiences-2","__v":0,"body":"","createdAt":"2015-07-21T08:07:04.591Z","type":"put","title":"/campaigns/:id/experiences","updates":[],"api":{"url":"/campaigns/:id/experiences","auth":"required","examples":{"codes":[{"code":"{\n  \"config\": {\n    \"category\": null,\n    \"description\": null,\n    \"name\": \"Enter Place Demo\",\n    \"repeat\": \"NextDay\",\n    \"updatedAt\": 1424351489582,\n    \"enabled\": true,\n    \"exactlyOnce\": false\n  },\n  \"action\": {\n    \"@type\": \"SendLocalMessageAction\",\n    \"contentType\": \"text/plain\",\n    \"content\": {\n      \"default\": \"Welcome to our Office!\"\n    },\n    \"bgAlert\": {}\n  },\n  \"trigger\": {\n    \"@type\": \"EnterPlaceTrigger\",\n    \"placeId\": \"8Q9mI6TyKhGXIMvlz1jr7g\"\n  }\n}","language":"json"}]},"method":"put","params":[{"name":"X-MOCA-Account-Id","in":"body","_id":"55accc9618eefd0d0071d5a5","required":true,"desc":"Header: The campaign's Account Id","default":"","type":"string"},{"name":"X-MOCA-App-Key","in":"body","_id":"55ad11b7fb7b3c1900373a6d","required":true,"desc":"Header: The campaign's App Key","default":"","type":"string"},{"name":"id","in":"path","_id":"55adfa692723e51900898eec","required":true,"desc":"Campaign Id","default":"","type":"string"}],"results":{"codes":[{"status":200,"language":"json","code":"{\n  \"createdAt\": 1424351489581,\n  \"experienceId\": \"PT7Swn6QcTw0dY6-sMAgJQ\",\n  \"appKey\": \"AeZQ_Wm9iW2v7QgvdTtmx1\",\n  \"config\": {\n    \"category\": null,\n    \"description\": null,\n    \"name\": \"Enter Place Demo\",\n    \"repeat\": \"NextDay\",\n    \"updatedAt\": 1424351489582,\n    \"enabled\": true,\n    \"exactlyOnce\": false\n  },\n  \"campaignId\": \"klyRDN-RPe7wcaAsNJ5LLQ\",\n  \"segmentId\": null,\n  \"action\": {\n    \"@type\": \"SendLocalMessageAction\",\n    \"contentType\": \"text/plain\",\n    \"content\": {\n      \"default\": \"Welcome to our Office!\"\n    },\n    \"bgAlert\": {}\n  },\n  \"trigger\": {\n    \"@type\": \"EnterPlaceTrigger\",\n    \"placeId\": \"8Q9mI6TyKhGXIMvlz1jr7g\"\n  }\n}","name":""},{"code":"{\n  \"ok\": false,\n  \"request_id\": \"fcf52425-5ade-4d9a-80de-0bc4d910ea32\",\n  \"error\": \"invalid-message\"\n}","name":"","status":400,"language":"json"},{"status":403,"language":"text","code":""},{"status":404,"language":"text","code":""}]},"settings":""},"order":12,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

put/campaigns/:id/experiences

Updates the specified experience.

Path Params

id:
required
string
Campaign Id

Body Params

X-MOCA-Account-Id:
required
string
Header: The campaign's Account Id
X-MOCA-App-Key:
required
string
Header: The campaign's App Key

User Information

Try It Out

put
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"_id":"55a5902880c8a30d00b323f8","hidden":false,"isReference":true,"order":0,"project":"559a61d2dbcfd20d00710b39","sync_unique":"","githubsync":"","title":"Experiences","version":"559a61d2dbcfd20d00710b3c","api":{"auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"link_url":"","parentDoc":null,"link_external":false,"slug":"experiences","type":"basic","__v":10,"body":"An Experience is composed of two components: The `trigger`and the `action`. The trigger defines when the experience is executed, based on defined conditions. The action is what is executed when the experience is triggered.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"The Experience Object\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Obligatory?\",\n    \"h-3\": \"Description\",\n    \"0-0\": \"createdAt\",\n    \"0-1\": \"long\",\n    \"0-2\": \"Autogenerated\",\n    \"0-3\": \"Creation date (timestamp UTC).\",\n    \"1-0\": \"experienceId\",\n    \"1-1\": \"string\",\n    \"1-2\": \"Autogenerated\",\n    \"1-3\": \"Experience identifier.\",\n    \"2-0\": \"appKey\",\n    \"2-1\": \"string\",\n    \"2-2\": \"Yes\",\n    \"2-3\": \"Application key.\",\n    \"3-0\": \"config.name\",\n    \"3-1\": \"string\",\n    \"3-2\": \"Yes\",\n    \"3-3\": \"Name of the experience.\",\n    \"4-0\": \"config.description\",\n    \"4-1\": \"string\",\n    \"4-2\": \"No\",\n    \"4-3\": \"Description of the experience.\",\n    \"5-0\": \"config.repeat\",\n    \"5-1\": \"string\",\n    \"5-2\": \"Yes\",\n    \"5-3\": \"Repeat interval. The experience cannot be triggered twice in this lapse of time.\",\n    \"6-0\": \"config.updatedAt\",\n    \"6-1\": \"long\",\n    \"6-2\": \"Autogenerated\",\n    \"6-3\": \"Last updated time (timestamp UTC).\",\n    \"7-0\": \"config.enabled\",\n    \"7-1\": \"boolean\",\n    \"7-2\": \"Yes\",\n    \"7-3\": \"Indicates whether the experience is active or not.\",\n    \"8-0\": \"config.exactlyOnce\",\n    \"8-1\": \"boolean\",\n    \"8-2\": \"Yes\",\n    \"8-3\": \"Indicates whether the experience can only be triggered once.\",\n    \"9-0\": \"campaignId\",\n    \"9-1\": \"string\",\n    \"9-2\": \"Yes\",\n    \"9-3\": \"The campaign id this experience belongs to.\",\n    \"10-0\": \"segmentId\",\n    \"10-1\": \"string\",\n    \"10-2\": \"No\",\n    \"10-3\": \"Segment Id, if the experience is targeted to a segment.\",\n    \"11-0\": \"action\",\n    \"11-1\": \"Action*\",\n    \"11-2\": \"No\",\n    \"11-3\": \"Action object that defines  what happens when the experience is triggered.\",\n    \"12-0\": \"trigger\",\n    \"12-1\": \"Trigger*\",\n    \"12-2\": \"No\",\n    \"12-3\": \"Trigger object that defines when the experience is triggered.\"\n  },\n  \"cols\": 4,\n  \"rows\": 13\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Repeat\",\n  \"body\": \"Accepted values for the `config.repeat` field:\\n`Immediately`, `Never`, `After1Min`, `After3Min`, `After5Min`, `After15Min`, `After30Min`, `After1Hour`, `After2Hours`, `After4Hours`, `After8Hours`, `After12Hours`, `After24Hours`, `NextDay`, `After2Days`, `After3Days`, `After5Days`, `NextWeek`, `After2Weeks`, `NextMonth`, `After2Months`\",\n  \"sidebar\": true\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Sample Experience Object\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"createdAt\\\": 1424351489581,\\n    \\\"experienceId\\\": \\\"PT7Swn6QcTw0dY6-sMAgJQ\\\",\\n    \\\"appKey\\\": \\\"AeZQ_Wm9iW2v7QgvdTtmx1\\\",\\n    \\\"config\\\": {\\n      \\\"category\\\": null,\\n      \\\"description\\\": null,\\n      \\\"name\\\": \\\"Enter Place Demo\\\",\\n      \\\"repeat\\\": \\\"NextDay\\\",\\n      \\\"updatedAt\\\": 1424351489582,\\n      \\\"enabled\\\": true,\\n      \\\"exactlyOnce\\\": false\\n    },\\n    \\\"campaignId\\\": \\\"klyRDN-RPe7wcaAsNJ5LLQ\\\",\\n    \\\"segmentId\\\": null,\\n    \\\"action\\\": {\\n      \\\"@type\\\": \\\"SendLocalMessageAction\\\",\\n      \\\"contentType\\\": \\\"text/plain\\\",\\n      \\\"content\\\": {\\n        \\\"default\\\": \\\"Welcome to our Office!\\\"\\n      },\\n      \\\"bgAlert\\\": {}\\n    },\\n    \\\"trigger\\\": {\\n      \\\"@type\\\": \\\"EnterPlaceTrigger\\\",\\n      \\\"placeId\\\": \\\"8Q9mI6TyKhGXIMvlz1jr7g\\\"\\n    }\\n  }\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]","category":"55afb28ec8a85321007a5462","createdAt":"2015-07-14T22:41:44.313Z","excerpt":"Represents an event triggered by segment, time and proximity (such as beacons) conditions.","updates":[],"user":"55a575ebaaf9cf1900114d73","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Experiences

Represents an event triggered by segment, time and proximity (such as beacons) conditions.

An Experience is composed of two components: The `trigger`and the `action`. The trigger defines when the experience is executed, based on defined conditions. The action is what is executed when the experience is triggered. [block:api-header] { "type": "basic", "title": "The Experience Object" } [/block] [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Obligatory?", "h-3": "Description", "0-0": "createdAt", "0-1": "long", "0-2": "Autogenerated", "0-3": "Creation date (timestamp UTC).", "1-0": "experienceId", "1-1": "string", "1-2": "Autogenerated", "1-3": "Experience identifier.", "2-0": "appKey", "2-1": "string", "2-2": "Yes", "2-3": "Application key.", "3-0": "config.name", "3-1": "string", "3-2": "Yes", "3-3": "Name of the experience.", "4-0": "config.description", "4-1": "string", "4-2": "No", "4-3": "Description of the experience.", "5-0": "config.repeat", "5-1": "string", "5-2": "Yes", "5-3": "Repeat interval. The experience cannot be triggered twice in this lapse of time.", "6-0": "config.updatedAt", "6-1": "long", "6-2": "Autogenerated", "6-3": "Last updated time (timestamp UTC).", "7-0": "config.enabled", "7-1": "boolean", "7-2": "Yes", "7-3": "Indicates whether the experience is active or not.", "8-0": "config.exactlyOnce", "8-1": "boolean", "8-2": "Yes", "8-3": "Indicates whether the experience can only be triggered once.", "9-0": "campaignId", "9-1": "string", "9-2": "Yes", "9-3": "The campaign id this experience belongs to.", "10-0": "segmentId", "10-1": "string", "10-2": "No", "10-3": "Segment Id, if the experience is targeted to a segment.", "11-0": "action", "11-1": "Action*", "11-2": "No", "11-3": "Action object that defines what happens when the experience is triggered.", "12-0": "trigger", "12-1": "Trigger*", "12-2": "No", "12-3": "Trigger object that defines when the experience is triggered." }, "cols": 4, "rows": 13 } [/block] [block:callout] { "type": "info", "title": "Repeat", "body": "Accepted values for the `config.repeat` field:\n`Immediately`, `Never`, `After1Min`, `After3Min`, `After5Min`, `After15Min`, `After30Min`, `After1Hour`, `After2Hours`, `After4Hours`, `After8Hours`, `After12Hours`, `After24Hours`, `NextDay`, `After2Days`, `After3Days`, `After5Days`, `NextWeek`, `After2Weeks`, `NextMonth`, `After2Months`", "sidebar": true } [/block] [block:api-header] { "type": "basic", "title": "Sample Experience Object" } [/block] [block:code] { "codes": [ { "code": "{\n \"createdAt\": 1424351489581,\n \"experienceId\": \"PT7Swn6QcTw0dY6-sMAgJQ\",\n \"appKey\": \"AeZQ_Wm9iW2v7QgvdTtmx1\",\n \"config\": {\n \"category\": null,\n \"description\": null,\n \"name\": \"Enter Place Demo\",\n \"repeat\": \"NextDay\",\n \"updatedAt\": 1424351489582,\n \"enabled\": true,\n \"exactlyOnce\": false\n },\n \"campaignId\": \"klyRDN-RPe7wcaAsNJ5LLQ\",\n \"segmentId\": null,\n \"action\": {\n \"@type\": \"SendLocalMessageAction\",\n \"contentType\": \"text/plain\",\n \"content\": {\n \"default\": \"Welcome to our Office!\"\n },\n \"bgAlert\": {}\n },\n \"trigger\": {\n \"@type\": \"EnterPlaceTrigger\",\n \"placeId\": \"8Q9mI6TyKhGXIMvlz1jr7g\"\n }\n }", "language": "json" } ] } [/block]
An Experience is composed of two components: The `trigger`and the `action`. The trigger defines when the experience is executed, based on defined conditions. The action is what is executed when the experience is triggered. [block:api-header] { "type": "basic", "title": "The Experience Object" } [/block] [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Obligatory?", "h-3": "Description", "0-0": "createdAt", "0-1": "long", "0-2": "Autogenerated", "0-3": "Creation date (timestamp UTC).", "1-0": "experienceId", "1-1": "string", "1-2": "Autogenerated", "1-3": "Experience identifier.", "2-0": "appKey", "2-1": "string", "2-2": "Yes", "2-3": "Application key.", "3-0": "config.name", "3-1": "string", "3-2": "Yes", "3-3": "Name of the experience.", "4-0": "config.description", "4-1": "string", "4-2": "No", "4-3": "Description of the experience.", "5-0": "config.repeat", "5-1": "string", "5-2": "Yes", "5-3": "Repeat interval. The experience cannot be triggered twice in this lapse of time.", "6-0": "config.updatedAt", "6-1": "long", "6-2": "Autogenerated", "6-3": "Last updated time (timestamp UTC).", "7-0": "config.enabled", "7-1": "boolean", "7-2": "Yes", "7-3": "Indicates whether the experience is active or not.", "8-0": "config.exactlyOnce", "8-1": "boolean", "8-2": "Yes", "8-3": "Indicates whether the experience can only be triggered once.", "9-0": "campaignId", "9-1": "string", "9-2": "Yes", "9-3": "The campaign id this experience belongs to.", "10-0": "segmentId", "10-1": "string", "10-2": "No", "10-3": "Segment Id, if the experience is targeted to a segment.", "11-0": "action", "11-1": "Action*", "11-2": "No", "11-3": "Action object that defines what happens when the experience is triggered.", "12-0": "trigger", "12-1": "Trigger*", "12-2": "No", "12-3": "Trigger object that defines when the experience is triggered." }, "cols": 4, "rows": 13 } [/block] [block:callout] { "type": "info", "title": "Repeat", "body": "Accepted values for the `config.repeat` field:\n`Immediately`, `Never`, `After1Min`, `After3Min`, `After5Min`, `After15Min`, `After30Min`, `After1Hour`, `After2Hours`, `After4Hours`, `After8Hours`, `After12Hours`, `After24Hours`, `NextDay`, `After2Days`, `After3Days`, `After5Days`, `NextWeek`, `After2Weeks`, `NextMonth`, `After2Months`", "sidebar": true } [/block] [block:api-header] { "type": "basic", "title": "Sample Experience Object" } [/block] [block:code] { "codes": [ { "code": "{\n \"createdAt\": 1424351489581,\n \"experienceId\": \"PT7Swn6QcTw0dY6-sMAgJQ\",\n \"appKey\": \"AeZQ_Wm9iW2v7QgvdTtmx1\",\n \"config\": {\n \"category\": null,\n \"description\": null,\n \"name\": \"Enter Place Demo\",\n \"repeat\": \"NextDay\",\n \"updatedAt\": 1424351489582,\n \"enabled\": true,\n \"exactlyOnce\": false\n },\n \"campaignId\": \"klyRDN-RPe7wcaAsNJ5LLQ\",\n \"segmentId\": null,\n \"action\": {\n \"@type\": \"SendLocalMessageAction\",\n \"contentType\": \"text/plain\",\n \"content\": {\n \"default\": \"Welcome to our Office!\"\n },\n \"bgAlert\": {}\n },\n \"trigger\": {\n \"@type\": \"EnterPlaceTrigger\",\n \"placeId\": \"8Q9mI6TyKhGXIMvlz1jr7g\"\n }\n }", "language": "json" } ] } [/block]
{"_id":"55b0cf51f202b12100cda2ff","api":{"auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"status":400,"language":"json","code":"{}","name":""}]},"settings":"","url":""},"category":"55afb28ec8a85321007a5462","excerpt":"Defines what action is executed when an experience is triggered.","githubsync":"","project":"559a61d2dbcfd20d00710b39","slug":"actions","__v":11,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"SendLocalMessageAction\"\n}\n[/block]\nShows a local push message with plain text.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"SendLocalMessageAction\\\",\\n  \\\"contentType\\\": \\\"text/plain\\\",\\n  \\\"content\\\": {\\n    \\\"default\\\": \\\"Come in and check out our new products!\\\"\\n  },\\n  \\\"bgAlert\\\": {}\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"ShowHtmlAction\"\n}\n[/block]\nShows a local push message with HTML code.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"ShowHtmlAction\\\",\\n  \\\"contentType\\\": \\\"text/html\\\",\\n  \\\"content\\\": {\\n    \\\"default\\\": \\\"<style>\\\\\\\\\\\\nbody {\\\\\\\\\\\\n\\\\\\\\tbackground-color: #dddddd;\\\\\\\\\\\\n\\\\\\\\ttext-align: center;\\\\\\\\\\\\n\\\\\\\\tfont-family: \\\\\\\"futura\\\\\\\";\\\\\\\\\\\\n\\\\\\\\tfont-size: 20px;\\\\\\\\\\\\n}\\\\\\\\\\\\n.logo {\\\\\\\\\\\\n\\\\\\\\twidth: 100%;\\\\\\\\\\\\n}\\\\\\\\\\\\n.title {\\\\\\\\\\\\n\\\\\\\\tfont-size: 1.25em;\\\\\\\\\\\\n\\\\\\\\tcolor: black;\\\\\\\\\\\\n}\\\\\\\\\\\\n.wrapper {\\\\\\\\\\\\n\\\\\\\\tmargin: 10% 5%;\\\\\\\\\\\\n}\\\\\\\\\\\\n.button {\\\\\\\\\\\\n\\\\\\\\tmargin: 0 2.5%;\\\\\\\\\\\\n\\\\\\\\tpadding: 10px 0;\\\\\\\\\\\\n\\\\\\\\twidth: 45%;\\\\\\\\\\\\n\\\\\\\\tbackground: #bf0d3f;\\\\\\\\\\\\n\\\\\\\\tborder-radius: 5px;\\\\\\\\\\\\n\\\\\\\\tfloat: left;\\\\\\\\\\\\n}\\\\\\\\\\\\na {\\\\\\\\\\\\n\\\\\\\\tcolor: white;\\\\\\\\\\\\n}\\\\\\\\\\\\n</style>\\\\\\\\\\\\n<div>\\\\\\\\\\\\n\\\\\\\\t<img class=\\\\\\\"logo\\\\\\\" src=\\\\\\\"https://d1ejjz5qg15st4.cloudfront.net/avatars/orgs/345q3bzte0fqamqn2uatixvkq.png\\\\\\\"/>\\\\\\\\\\\\n</div>\\\\\\\\\\\\n<div class=\\\\\\\"title\\\\\\\">\\\\\\\\\\\\n\\\\\\\\t<B>WELCOME TO MOCA PLATFORM</B>\\\\\\\\\\\\n</div>\\\\\\\\\\\\n<div class=\\\\\\\"wrapper\\\\\\\">\\\\\\\\\\\\n\\\\\\\\t<a href=\\\\\\\"http://mocaplatform.com/\\\\\\\">\\\\\\\\\\\\n\\\\\\\\t\\\\\\\\t<div class=\\\\\\\"button\\\\\\\">Go to web</div>\\\\\\\\\\\\n\\\\\\\\t</a>\\\\\\\\\\\\n\\\\\\\\t<a href=\\\\\\\"mocasdk://closeme\\\\\\\">\\\\\\\\\\\\n\\\\\\\\t\\\\\\\\t<div class=\\\\\\\"button\\\\\\\">Dismiss</div>\\\\\\\\\\\\n\\\\\\\\t</a>\\\\\\\\\\\\n</div>\\\\\\\\\\\\n\\\"\\n  },\\n  \\\"bgAlert\\\": {\\n    \\\"default\\\": \\\"Welcome to MOCA!\\\"\\n  }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Background Alert\",\n  \"body\": \"If the App is not in foreground, the message in `bgAlert` will be shown as a notification. When the user opens it, the HTML message will be shown.\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Content length\",\n  \"body\": \"The maximum allowed size for a message is 50kb\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"ShowImageAction\"\n}\n[/block]\nShows a local push message with an image.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"ShowImageAction\\\",\\n  \\\"contentType\\\": \\\"text/x-url\\\",\\n  \\\"content\\\": {\\n    \\\"default\\\": \\\"https://d1ejjz5qg15st4.cloudfront.net/avatars/orgs/345q3bzte0fqamqn2uatixvkq.png\\\"\\n  },\\n  \\\"bgAlert\\\": {\\n    \\\"default\\\": \\\"Image!\\\"\\n  }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"ShowVideoAction\"\n}\n[/block]\nShows a local push message with video.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"ShowVideoAction\\\",\\n  \\\"contentType\\\": \\\"text/x-url\\\",\\n  \\\"content\\\": {\\n    \\\"default\\\": \\\"http://www.your-site.com/your-video-url\\\"\\n  },\\n  \\\"bgAlert\\\": {}\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"PlaySoundAction\"\n}\n[/block]\nPlays a sound file from the application package.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"PlaySoundAction\\\",\\n  \\\"contentType\\\": \\\"text/plain\\\",\\n  \\\"content\\\": {\\n    \\\"default\\\": \\\"my-sound.wav\\\"\\n  },\\n  \\\"bgAlert\\\": {}\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"OpenUrlAction\"\n}\n[/block]\nOpens a URL.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"OpenUrlAction\\\",\\n  \\\"contentType\\\": \\\"text/x-url\\\",\\n  \\\"content\\\": {\\n    \\\"default\\\": \\\"http://www.mocaplatform.com\\\"\\n  },\\n  \\\"bgAlert\\\": {\\n    \\\"default\\\": \\\"Check our website!\\\"\\n  }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"ShowCardAction\"\n}\n[/block]\nThis action enables you to deliver loyalty cards, event tickets, discount coupons or custom cards to your users from Passbook, Google Wallet and similar.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"ShowCardAction\\\",\\n  \\\"contentType\\\": \\\"text/x-url\\\",\\n  \\\"content\\\": {\\n    \\\"default\\\": \\\"http://www.your-site.com/your-passcard-url.pkpass\\\"\\n  },\\n  \\\"bgAlert\\\": {\\n    \\\"default\\\": \\\"You have a new card available. Open it now?\\\"\\n  },\\n  \\\"cardProvider\\\": \\\"apple-passbook\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"TagAction\"\n}\n[/block]\nAdds a tag to the user. You can optionally add a value for the tag (Accepted values are numbers preceded by a plus sign, a minus sign, or none)\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"TagAction\\\",\\n  \\\"tagName\\\": \\\"EntranceTag\\\",\\n  \\\"actionValue\\\": \\\"+2\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"CustomAction\"\n}\n[/block]\nWhen fired, this action invokes an app-developer provided custom callback. The callback is invoked with a provided string attribute.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"CustomAction\\\",\\n  \\\"customArgument\\\": \\\"CustomActionCallback\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"CompositeAction\"\n}\n[/block]\nA collection of actions. All children actions are executed when the experience is triggered.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"CompositeAction\\\",\\n  \\\"list\\\": [\\n    {\\n      \\\"@type\\\": \\\"OpenUrlAction\\\",\\n      \\\"contentType\\\": \\\"text/x-url\\\",\\n      \\\"content\\\": {\\n        \\\"default\\\": \\\"http://www.mocaplatform.com\\\"\\n      },\\n      \\\"bgAlert\\\": {\\n        \\\"default\\\": \\\"Check our website!\\\"\\n      }\\n    },\\n    {\\n      \\\"@type\\\": \\\"PlaySoundAction\\\",\\n      \\\"contentType\\\": \\\"text/plain\\\",\\n      \\\"content\\\": {\\n        \\\"default\\\": \\\"my-sound.wav\\\"\\n      },\\n      \\\"bgAlert\\\": {}\\n    }\\n  ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]","createdAt":"2015-07-23T11:26:09.169Z","link_external":false,"sync_unique":"","hidden":false,"order":1,"title":"Actions","updates":[],"version":"559a61d2dbcfd20d00710b3c","isReference":true,"link_url":"","next":{"description":"","pages":[]},"parentDoc":null,"type":"basic","user":"55a54dde9c32760d00ca78a8","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Actions

Defines what action is executed when an experience is triggered.

[block:api-header] { "type": "basic", "title": "SendLocalMessageAction" } [/block] Shows a local push message with plain text. [block:code] { "codes": [ { "code": "{\n \"@type\": \"SendLocalMessageAction\",\n \"contentType\": \"text/plain\",\n \"content\": {\n \"default\": \"Come in and check out our new products!\"\n },\n \"bgAlert\": {}\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "ShowHtmlAction" } [/block] Shows a local push message with HTML code. [block:code] { "codes": [ { "code": "{\n \"@type\": \"ShowHtmlAction\",\n \"contentType\": \"text/html\",\n \"content\": {\n \"default\": \"<style>\\\\\\nbody {\\\\\\n\\\\tbackground-color: #dddddd;\\\\\\n\\\\ttext-align: center;\\\\\\n\\\\tfont-family: \\\"futura\\\";\\\\\\n\\\\tfont-size: 20px;\\\\\\n}\\\\\\n.logo {\\\\\\n\\\\twidth: 100%;\\\\\\n}\\\\\\n.title {\\\\\\n\\\\tfont-size: 1.25em;\\\\\\n\\\\tcolor: black;\\\\\\n}\\\\\\n.wrapper {\\\\\\n\\\\tmargin: 10% 5%;\\\\\\n}\\\\\\n.button {\\\\\\n\\\\tmargin: 0 2.5%;\\\\\\n\\\\tpadding: 10px 0;\\\\\\n\\\\twidth: 45%;\\\\\\n\\\\tbackground: #bf0d3f;\\\\\\n\\\\tborder-radius: 5px;\\\\\\n\\\\tfloat: left;\\\\\\n}\\\\\\na {\\\\\\n\\\\tcolor: white;\\\\\\n}\\\\\\n</style>\\\\\\n<div>\\\\\\n\\\\t<img class=\\\"logo\\\" src=\\\"https://d1ejjz5qg15st4.cloudfront.net/avatars/orgs/345q3bzte0fqamqn2uatixvkq.png\\\"/>\\\\\\n</div>\\\\\\n<div class=\\\"title\\\">\\\\\\n\\\\t<B>WELCOME TO MOCA PLATFORM</B>\\\\\\n</div>\\\\\\n<div class=\\\"wrapper\\\">\\\\\\n\\\\t<a href=\\\"http://mocaplatform.com/\\\">\\\\\\n\\\\t\\\\t<div class=\\\"button\\\">Go to web</div>\\\\\\n\\\\t</a>\\\\\\n\\\\t<a href=\\\"mocasdk://closeme\\\">\\\\\\n\\\\t\\\\t<div class=\\\"button\\\">Dismiss</div>\\\\\\n\\\\t</a>\\\\\\n</div>\\\\\\n\"\n },\n \"bgAlert\": {\n \"default\": \"Welcome to MOCA!\"\n }\n}", "language": "json" } ] } [/block] [block:callout] { "type": "warning", "title": "Background Alert", "body": "If the App is not in foreground, the message in `bgAlert` will be shown as a notification. When the user opens it, the HTML message will be shown." } [/block] [block:callout] { "type": "danger", "title": "Content length", "body": "The maximum allowed size for a message is 50kb" } [/block] [block:api-header] { "type": "basic", "title": "ShowImageAction" } [/block] Shows a local push message with an image. [block:code] { "codes": [ { "code": "{\n \"@type\": \"ShowImageAction\",\n \"contentType\": \"text/x-url\",\n \"content\": {\n \"default\": \"https://d1ejjz5qg15st4.cloudfront.net/avatars/orgs/345q3bzte0fqamqn2uatixvkq.png\"\n },\n \"bgAlert\": {\n \"default\": \"Image!\"\n }\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "ShowVideoAction" } [/block] Shows a local push message with video. [block:code] { "codes": [ { "code": "{\n \"@type\": \"ShowVideoAction\",\n \"contentType\": \"text/x-url\",\n \"content\": {\n \"default\": \"http://www.your-site.com/your-video-url\"\n },\n \"bgAlert\": {}\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "PlaySoundAction" } [/block] Plays a sound file from the application package. [block:code] { "codes": [ { "code": "{\n \"@type\": \"PlaySoundAction\",\n \"contentType\": \"text/plain\",\n \"content\": {\n \"default\": \"my-sound.wav\"\n },\n \"bgAlert\": {}\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "OpenUrlAction" } [/block] Opens a URL. [block:code] { "codes": [ { "code": "{\n \"@type\": \"OpenUrlAction\",\n \"contentType\": \"text/x-url\",\n \"content\": {\n \"default\": \"http://www.mocaplatform.com\"\n },\n \"bgAlert\": {\n \"default\": \"Check our website!\"\n }\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "ShowCardAction" } [/block] This action enables you to deliver loyalty cards, event tickets, discount coupons or custom cards to your users from Passbook, Google Wallet and similar. [block:code] { "codes": [ { "code": "{\n \"@type\": \"ShowCardAction\",\n \"contentType\": \"text/x-url\",\n \"content\": {\n \"default\": \"http://www.your-site.com/your-passcard-url.pkpass\"\n },\n \"bgAlert\": {\n \"default\": \"You have a new card available. Open it now?\"\n },\n \"cardProvider\": \"apple-passbook\"\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "TagAction" } [/block] Adds a tag to the user. You can optionally add a value for the tag (Accepted values are numbers preceded by a plus sign, a minus sign, or none) [block:code] { "codes": [ { "code": "{\n \"@type\": \"TagAction\",\n \"tagName\": \"EntranceTag\",\n \"actionValue\": \"+2\"\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "CustomAction" } [/block] When fired, this action invokes an app-developer provided custom callback. The callback is invoked with a provided string attribute. [block:code] { "codes": [ { "code": "{\n \"@type\": \"CustomAction\",\n \"customArgument\": \"CustomActionCallback\"\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "CompositeAction" } [/block] A collection of actions. All children actions are executed when the experience is triggered. [block:code] { "codes": [ { "code": "{\n \"@type\": \"CompositeAction\",\n \"list\": [\n {\n \"@type\": \"OpenUrlAction\",\n \"contentType\": \"text/x-url\",\n \"content\": {\n \"default\": \"http://www.mocaplatform.com\"\n },\n \"bgAlert\": {\n \"default\": \"Check our website!\"\n }\n },\n {\n \"@type\": \"PlaySoundAction\",\n \"contentType\": \"text/plain\",\n \"content\": {\n \"default\": \"my-sound.wav\"\n },\n \"bgAlert\": {}\n }\n ]\n}", "language": "json" } ] } [/block]
[block:api-header] { "type": "basic", "title": "SendLocalMessageAction" } [/block] Shows a local push message with plain text. [block:code] { "codes": [ { "code": "{\n \"@type\": \"SendLocalMessageAction\",\n \"contentType\": \"text/plain\",\n \"content\": {\n \"default\": \"Come in and check out our new products!\"\n },\n \"bgAlert\": {}\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "ShowHtmlAction" } [/block] Shows a local push message with HTML code. [block:code] { "codes": [ { "code": "{\n \"@type\": \"ShowHtmlAction\",\n \"contentType\": \"text/html\",\n \"content\": {\n \"default\": \"<style>\\\\\\nbody {\\\\\\n\\\\tbackground-color: #dddddd;\\\\\\n\\\\ttext-align: center;\\\\\\n\\\\tfont-family: \\\"futura\\\";\\\\\\n\\\\tfont-size: 20px;\\\\\\n}\\\\\\n.logo {\\\\\\n\\\\twidth: 100%;\\\\\\n}\\\\\\n.title {\\\\\\n\\\\tfont-size: 1.25em;\\\\\\n\\\\tcolor: black;\\\\\\n}\\\\\\n.wrapper {\\\\\\n\\\\tmargin: 10% 5%;\\\\\\n}\\\\\\n.button {\\\\\\n\\\\tmargin: 0 2.5%;\\\\\\n\\\\tpadding: 10px 0;\\\\\\n\\\\twidth: 45%;\\\\\\n\\\\tbackground: #bf0d3f;\\\\\\n\\\\tborder-radius: 5px;\\\\\\n\\\\tfloat: left;\\\\\\n}\\\\\\na {\\\\\\n\\\\tcolor: white;\\\\\\n}\\\\\\n</style>\\\\\\n<div>\\\\\\n\\\\t<img class=\\\"logo\\\" src=\\\"https://d1ejjz5qg15st4.cloudfront.net/avatars/orgs/345q3bzte0fqamqn2uatixvkq.png\\\"/>\\\\\\n</div>\\\\\\n<div class=\\\"title\\\">\\\\\\n\\\\t<B>WELCOME TO MOCA PLATFORM</B>\\\\\\n</div>\\\\\\n<div class=\\\"wrapper\\\">\\\\\\n\\\\t<a href=\\\"http://mocaplatform.com/\\\">\\\\\\n\\\\t\\\\t<div class=\\\"button\\\">Go to web</div>\\\\\\n\\\\t</a>\\\\\\n\\\\t<a href=\\\"mocasdk://closeme\\\">\\\\\\n\\\\t\\\\t<div class=\\\"button\\\">Dismiss</div>\\\\\\n\\\\t</a>\\\\\\n</div>\\\\\\n\"\n },\n \"bgAlert\": {\n \"default\": \"Welcome to MOCA!\"\n }\n}", "language": "json" } ] } [/block] [block:callout] { "type": "warning", "title": "Background Alert", "body": "If the App is not in foreground, the message in `bgAlert` will be shown as a notification. When the user opens it, the HTML message will be shown." } [/block] [block:callout] { "type": "danger", "title": "Content length", "body": "The maximum allowed size for a message is 50kb" } [/block] [block:api-header] { "type": "basic", "title": "ShowImageAction" } [/block] Shows a local push message with an image. [block:code] { "codes": [ { "code": "{\n \"@type\": \"ShowImageAction\",\n \"contentType\": \"text/x-url\",\n \"content\": {\n \"default\": \"https://d1ejjz5qg15st4.cloudfront.net/avatars/orgs/345q3bzte0fqamqn2uatixvkq.png\"\n },\n \"bgAlert\": {\n \"default\": \"Image!\"\n }\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "ShowVideoAction" } [/block] Shows a local push message with video. [block:code] { "codes": [ { "code": "{\n \"@type\": \"ShowVideoAction\",\n \"contentType\": \"text/x-url\",\n \"content\": {\n \"default\": \"http://www.your-site.com/your-video-url\"\n },\n \"bgAlert\": {}\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "PlaySoundAction" } [/block] Plays a sound file from the application package. [block:code] { "codes": [ { "code": "{\n \"@type\": \"PlaySoundAction\",\n \"contentType\": \"text/plain\",\n \"content\": {\n \"default\": \"my-sound.wav\"\n },\n \"bgAlert\": {}\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "OpenUrlAction" } [/block] Opens a URL. [block:code] { "codes": [ { "code": "{\n \"@type\": \"OpenUrlAction\",\n \"contentType\": \"text/x-url\",\n \"content\": {\n \"default\": \"http://www.mocaplatform.com\"\n },\n \"bgAlert\": {\n \"default\": \"Check our website!\"\n }\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "ShowCardAction" } [/block] This action enables you to deliver loyalty cards, event tickets, discount coupons or custom cards to your users from Passbook, Google Wallet and similar. [block:code] { "codes": [ { "code": "{\n \"@type\": \"ShowCardAction\",\n \"contentType\": \"text/x-url\",\n \"content\": {\n \"default\": \"http://www.your-site.com/your-passcard-url.pkpass\"\n },\n \"bgAlert\": {\n \"default\": \"You have a new card available. Open it now?\"\n },\n \"cardProvider\": \"apple-passbook\"\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "TagAction" } [/block] Adds a tag to the user. You can optionally add a value for the tag (Accepted values are numbers preceded by a plus sign, a minus sign, or none) [block:code] { "codes": [ { "code": "{\n \"@type\": \"TagAction\",\n \"tagName\": \"EntranceTag\",\n \"actionValue\": \"+2\"\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "CustomAction" } [/block] When fired, this action invokes an app-developer provided custom callback. The callback is invoked with a provided string attribute. [block:code] { "codes": [ { "code": "{\n \"@type\": \"CustomAction\",\n \"customArgument\": \"CustomActionCallback\"\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "CompositeAction" } [/block] A collection of actions. All children actions are executed when the experience is triggered. [block:code] { "codes": [ { "code": "{\n \"@type\": \"CompositeAction\",\n \"list\": [\n {\n \"@type\": \"OpenUrlAction\",\n \"contentType\": \"text/x-url\",\n \"content\": {\n \"default\": \"http://www.mocaplatform.com\"\n },\n \"bgAlert\": {\n \"default\": \"Check our website!\"\n }\n },\n {\n \"@type\": \"PlaySoundAction\",\n \"contentType\": \"text/plain\",\n \"content\": {\n \"default\": \"my-sound.wav\"\n },\n \"bgAlert\": {}\n }\n ]\n}", "language": "json" } ] } [/block]
{"_id":"55b0cf69b3171b3700b15404","slug":"triggers","updates":[],"user":"55a54dde9c32760d00ca78a8","githubsync":"","hidden":false,"isReference":true,"link_external":false,"order":2,"type":"basic","__v":8,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"EnterPlaceTrigger\"\n}\n[/block]\nTriggered when a user has not previously entered the place, and the first beacon from any zone that compose the place is detected.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"EnterPlaceTrigger\\\",\\n  \\\"placeId\\\": \\\"8Q9mI6TyKhGXIMvlz1jr7g\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"PlaceProximityTrigger\"\n}\n[/block]\nTriggered when a user gets in range of any beacon that belongs to the place and its proximity value changes to the indicated `proximity` for the first time.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"PlaceProximityTrigger\\\",\\n  \\\"placeId\\\": \\\"8Q9mI6TyKhGXIMvlz1jr7g\\\",\\n  \\\"proximity\\\": \\\"Near\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Proximity\",\n  \"body\": \"Valid proximity values are `Far`, `Near` and `Inmediate`, in descending order of distance to the beacon.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"ExitPlaceTrigger\"\n}\n[/block]\nTriggered when the user has entered a place and then left. The place is considered as left when all the beacons within it are out of reach.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"ExitPlaceTrigger\\\",\\n  \\\"placeId\\\": \\\"8Q9mI6TyKhGXIMvlz1jr7g\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"EnterZoneTrigger\"\n}\n[/block]\nTriggered when a user has not previously entered the zone, and the first beacon that compose the zone is detected.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"EnterZoneTrigger\\\",\\n  \\\"zoneId\\\": \\\"8Q9mI6TyKhGXIMvlz1jr7g\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"ZoneProximityTrigger\"\n}\n[/block]\nTriggered when a user gets in range of any beacon that belongs to the zone and its proximity value changes to the indicated ´proximity´ for the first time.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"ZoneProximityTrigger\\\",\\n  \\\"zoneId\\\": \\\"8Q9mI6TyKhGXIMvlz1jr7g\\\",\\n  \\\"proximity\\\": \\\"Near\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"ExitZoneTrigger\"\n}\n[/block]\nTriggered when the user has entered a zone and then left. The zone is considered as left when all the beacons within it are out of reach.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"ExitZoneTrigger\\\",\\n  \\\"zoneId\\\": \\\"8Q9mI6TyKhGXIMvlz1jr7g\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"EnterBeaconTrigger\"\n}\n[/block]\nTriggered when a user has not previously entered the beacon range, and the beacon is detected.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"EnterBeaconTrigger\\\",\\n  \\\"beaconId\\\": \\\"8Q9mI6TyKhGXIMvlz1jr7g\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"BeaconProximityTrigger\"\n}\n[/block]\nTriggered when a user gets in range of a beacon and its proximity value changes to the indicated ´proximity´ for the first time.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"BeaconProximityTrigger\\\",\\n  \\\"zoneId\\\": \\\"8Q9mI6TyKhGXIMvlz1jr7g\\\",\\n  \\\"proximity\\\": \\\"Near\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"ExitBeaconTrigger\"\n}\n[/block]\nTriggered when the user has entered a beacon's range and then left.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"ExitBeaconTrigger\\\",\\n  \\\"beaconId\\\": \\\"8Q9mI6TyKhGXIMvlz1jr7g\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"CustomTrigger\"\n}\n[/block]\nWhen checked, this trigger invokes an app-provided custom callback. The callback is invoked with a provided string attribute and returns a boolean value of whether the trigger has been activated or not.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"CustomTrigger\\\",\\n  \\\"customArgument\\\": \\\"CustomTriggerCallback\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"CompositeTrigger\"\n}\n[/block]\nA collection of triggers, fired when ALL children triggers are active.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"@type\\\": \\\"CompositeTrigger\\\",\\n  \\\"list\\\": [\\n    {\\n      \\\"@type\\\": \\\"ZoneProximityTrigger\\\",\\n      \\\"zoneId\\\": \\\"8Q9mI6TyKhGXIMvlz1jr7g\\\",\\n      \\\"proximity\\\": \\\"Near\\\"\\n    },\\n    {\\n      \\\"@type\\\": \\\"CustomTrigger\\\",\\n      \\\"customArgument\\\": \\\"CustomTriggerCallback\\\"\\n    }\\n  ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]","link_url":"","parentDoc":null,"sync_unique":"","version":"559a61d2dbcfd20d00710b3c","project":"559a61d2dbcfd20d00710b39","title":"Triggers","api":{"params":[],"results":{"codes":[{"name":"","status":200,"language":"json","code":"{}"},{"language":"json","code":"{}","name":"","status":400}]},"settings":"","url":"","auth":"required"},"category":"55afb28ec8a85321007a5462","createdAt":"2015-07-23T11:26:33.575Z","excerpt":"Defines when an experience is activated based on proximity.","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Triggers

Defines when an experience is activated based on proximity.

[block:api-header] { "type": "basic", "title": "EnterPlaceTrigger" } [/block] Triggered when a user has not previously entered the place, and the first beacon from any zone that compose the place is detected. [block:code] { "codes": [ { "code": "{\n \"@type\": \"EnterPlaceTrigger\",\n \"placeId\": \"8Q9mI6TyKhGXIMvlz1jr7g\"\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "PlaceProximityTrigger" } [/block] Triggered when a user gets in range of any beacon that belongs to the place and its proximity value changes to the indicated `proximity` for the first time. [block:code] { "codes": [ { "code": "{\n \"@type\": \"PlaceProximityTrigger\",\n \"placeId\": \"8Q9mI6TyKhGXIMvlz1jr7g\",\n \"proximity\": \"Near\"\n}", "language": "json" } ] } [/block] [block:callout] { "type": "info", "title": "Proximity", "body": "Valid proximity values are `Far`, `Near` and `Inmediate`, in descending order of distance to the beacon." } [/block] [block:api-header] { "type": "basic", "title": "ExitPlaceTrigger" } [/block] Triggered when the user has entered a place and then left. The place is considered as left when all the beacons within it are out of reach. [block:code] { "codes": [ { "code": "{\n \"@type\": \"ExitPlaceTrigger\",\n \"placeId\": \"8Q9mI6TyKhGXIMvlz1jr7g\"\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "EnterZoneTrigger" } [/block] Triggered when a user has not previously entered the zone, and the first beacon that compose the zone is detected. [block:code] { "codes": [ { "code": "{\n \"@type\": \"EnterZoneTrigger\",\n \"zoneId\": \"8Q9mI6TyKhGXIMvlz1jr7g\"\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "ZoneProximityTrigger" } [/block] Triggered when a user gets in range of any beacon that belongs to the zone and its proximity value changes to the indicated ´proximity´ for the first time. [block:code] { "codes": [ { "code": "{\n \"@type\": \"ZoneProximityTrigger\",\n \"zoneId\": \"8Q9mI6TyKhGXIMvlz1jr7g\",\n \"proximity\": \"Near\"\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "ExitZoneTrigger" } [/block] Triggered when the user has entered a zone and then left. The zone is considered as left when all the beacons within it are out of reach. [block:code] { "codes": [ { "code": "{\n \"@type\": \"ExitZoneTrigger\",\n \"zoneId\": \"8Q9mI6TyKhGXIMvlz1jr7g\"\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "EnterBeaconTrigger" } [/block] Triggered when a user has not previously entered the beacon range, and the beacon is detected. [block:code] { "codes": [ { "code": "{\n \"@type\": \"EnterBeaconTrigger\",\n \"beaconId\": \"8Q9mI6TyKhGXIMvlz1jr7g\"\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "BeaconProximityTrigger" } [/block] Triggered when a user gets in range of a beacon and its proximity value changes to the indicated ´proximity´ for th