{"_id":"5772bc74da551f0e00be5b61","initVersion":{"_id":"56cacb1cc675f50b00a4b61c","version":"1"},"project":"56cacb1bc675f50b00a4b619","__v":0,"user":{"_id":"56caca84245b841300806def","username":"","name":"Shoaib"},"hidden":false,"createdAt":"2016-06-28T18:05:40.574Z","fullscreen":false,"htmlmode":false,"html":"","body":"Android SDK wraps a light version of Codemojo services including Referral, Wallet, Gamification & Loyalty that can be directly integrated into your app.\n\nDownload the latest SDK from [here](https://github.com/codemojo-dr/startkit-android-sdk)\n\nCheck out the [sample app screens](page:sample-app-screens) or download it from the [Google Playstore](http://play.google.com/store/apps/details?id=io.codemojo.sample)\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Setting up\"\n}\n[/block]\nInclude the repository in your **gradle.build** file\n[block:html]\n{\n  \"html\": \"<a target=\\\"_blank\\\" href='https://bintray.com/codemojo/maven/sdk/_latestVersion'><img src='https://api.bintray.com/packages/codemojo/maven/sdk/images/download.svg'></a>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"dependencies {\\n  compile 'io.codemojo.sdk:sdk:1.0.58+'\\n}\",\n      \"language\": \"groovy\",\n      \"name\": \"build.gradle\"\n    }\n  ]\n}\n[/block]\nAdd the following to your main **AndroidManifest.xml** file\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<!--Internet Permissions-->\\n\\n<!--Your app needs to have internet permissions in order to communicate with the Branch service. Make sure you set -->\\n\\n<uses-permission android:name=\\\"android.permission.INTERNET\\\" />\\n\\n<activity android:name=\\\"io.codemojo.sdk.ui.ReferralActivity\\\"/>\\n<activity android:name=\\\"io.codemojo.sdk.ui.GamificationTransactions\\\"/>\\n\\n<receiver android:name=\\\"io.codemojo.sdk.receiver.InstallReceiver\\\" android:exported=\\\"true\\\">\\n  <intent-filter>\\n    <action android:name=\\\"com.android.vending.INSTALL_REFERRER\\\" />\\n  </intent-filter>\\n</receiver>\",\n      \"language\": \"xml\",\n      \"name\": \"AndroidManifest.xml\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Initializing\"\n}\n[/block]\nInitialize a Instance of Codemojo object with the app token obtained from your [Codemojo Dashboard](https://dashboard.codemojo.io)\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Get\\nCodemojo mojo = new Codemojo(context, \\\"xxxx_your_app_token\\\", \\\"encrypted_user_id\\\", true);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Param\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"context\",\n    \"0-1\": \"Context\",\n    \"0-2\": \"App Context\",\n    \"1-0\": \"app_token\",\n    \"1-1\": \"String\",\n    \"1-2\": \"App token from Codemojo dashboard\",\n    \"2-0\": \"encrypted_user_id\",\n    \"2-1\": \"String\",\n    \"2-2\": \"Server side encrypted user identifier\",\n    \"3-0\": \"isTesting\",\n    \"3-1\": \"bool\",\n    \"3-2\": \"Determines which server to connect to. Defaults to **false** i.e. connects to Production\"\n  },\n  \"cols\": 3,\n  \"rows\": 4\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Please use Encrypted User ID\",\n  \"body\": \"It is important to use a server side hashed / encrypted version of the customer id in the SDK. This helps mitigate any random brute force requests spoofing to be other customers\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Accessing Services\"\n}\n[/block]\nThe **Codemojo** object lets you access individual services that include. All the services are **Asynchronous** in nature and hence use [Callbacks](page:android-response-callback) to notify when the data is available.\n\n* [Referral Service](page:android-referral-service)\n* [Gamification Service](page:android-gamification-service)\n* [Wallet Service](page:android-wallet-service)\n* Loyalty Service\n\nEach of the services can be accessed via a **getter method** \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Gets the Respective Services\\nReferralService referral = mojo.getReferralService();\\nWalletService wallet = mojo.getWalletService();\\nGamificationService gamification = mojo.getGamificationService();\\nRewardsService rewards = mojo.getRewardsService();\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Codemojo Object\"\n}\n[/block]\nThe main object lets you access the following methods\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Method Name\",\n    \"h-1\": \"Parameters\",\n    \"0-0\": \"launchReferralScreen\",\n    \"0-1\": \"[ReferralScreenSettings](page:android-referral-settings)\",\n    \"h-2\": \"Description\",\n    \"0-2\": \"Lets you launch a pre-built referral ui with sharing options\",\n    \"2-0\": \"setLoyaltyEventListener\",\n    \"2-1\": \"[LoyaltyEvent](page:android-loyalty-events)\",\n    \"3-0\": \"setGamificationEarnedEventListener\",\n    \"3-1\": \"[GamificationEarnedEvent](page:android-gamification-event)\",\n    \"2-2\": \"Lets you listen to loyalty events like Tier upgrades etc.\",\n    \"3-2\": \"Lets you listen to gamification events like Achievements unlocked, Badge upgrade etc.\",\n    \"1-0\": \"launchRewardsScreen\",\n    \"1-1\": \"[Android Rewards Screen Settings](page:android-rewards-screen-settings)\",\n    \"1-2\": \"Lets you launch a pre-build rewards fulfilment UI\"\n  },\n  \"cols\": 3,\n  \"rows\": 4\n}\n[/block]","slug":"android-sdk","title":"Android SDK"}

Android SDK


Android SDK wraps a light version of Codemojo services including Referral, Wallet, Gamification & Loyalty that can be directly integrated into your app. Download the latest SDK from [here](https://github.com/codemojo-dr/startkit-android-sdk) Check out the [sample app screens](page:sample-app-screens) or download it from the [Google Playstore](http://play.google.com/store/apps/details?id=io.codemojo.sample) [block:api-header] { "type": "basic", "title": "Setting up" } [/block] Include the repository in your **gradle.build** file [block:html] { "html": "<a target=\"_blank\" href='https://bintray.com/codemojo/maven/sdk/_latestVersion'><img src='https://api.bintray.com/packages/codemojo/maven/sdk/images/download.svg'></a>" } [/block] [block:code] { "codes": [ { "code": "dependencies {\n compile 'io.codemojo.sdk:sdk:1.0.58+'\n}", "language": "groovy", "name": "build.gradle" } ] } [/block] Add the following to your main **AndroidManifest.xml** file [block:code] { "codes": [ { "code": "<!--Internet Permissions-->\n\n<!--Your app needs to have internet permissions in order to communicate with the Branch service. Make sure you set -->\n\n<uses-permission android:name=\"android.permission.INTERNET\" />\n\n<activity android:name=\"io.codemojo.sdk.ui.ReferralActivity\"/>\n<activity android:name=\"io.codemojo.sdk.ui.GamificationTransactions\"/>\n\n<receiver android:name=\"io.codemojo.sdk.receiver.InstallReceiver\" android:exported=\"true\">\n <intent-filter>\n <action android:name=\"com.android.vending.INSTALL_REFERRER\" />\n </intent-filter>\n</receiver>", "language": "xml", "name": "AndroidManifest.xml" } ] } [/block] [block:api-header] { "type": "basic", "title": "Initializing" } [/block] Initialize a Instance of Codemojo object with the app token obtained from your [Codemojo Dashboard](https://dashboard.codemojo.io) [block:code] { "codes": [ { "code": "// Get\nCodemojo mojo = new Codemojo(context, \"xxxx_your_app_token\", \"encrypted_user_id\", true);", "language": "java" } ] } [/block] [block:parameters] { "data": { "h-0": "Param", "h-1": "Type", "h-2": "Description", "0-0": "context", "0-1": "Context", "0-2": "App Context", "1-0": "app_token", "1-1": "String", "1-2": "App token from Codemojo dashboard", "2-0": "encrypted_user_id", "2-1": "String", "2-2": "Server side encrypted user identifier", "3-0": "isTesting", "3-1": "bool", "3-2": "Determines which server to connect to. Defaults to **false** i.e. connects to Production" }, "cols": 3, "rows": 4 } [/block] [block:callout] { "type": "danger", "title": "Please use Encrypted User ID", "body": "It is important to use a server side hashed / encrypted version of the customer id in the SDK. This helps mitigate any random brute force requests spoofing to be other customers" } [/block] [block:api-header] { "type": "basic", "title": "Accessing Services" } [/block] The **Codemojo** object lets you access individual services that include. All the services are **Asynchronous** in nature and hence use [Callbacks](page:android-response-callback) to notify when the data is available. * [Referral Service](page:android-referral-service) * [Gamification Service](page:android-gamification-service) * [Wallet Service](page:android-wallet-service) * Loyalty Service Each of the services can be accessed via a **getter method** [block:code] { "codes": [ { "code": "// Gets the Respective Services\nReferralService referral = mojo.getReferralService();\nWalletService wallet = mojo.getWalletService();\nGamificationService gamification = mojo.getGamificationService();\nRewardsService rewards = mojo.getRewardsService();", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "Codemojo Object" } [/block] The main object lets you access the following methods [block:parameters] { "data": { "h-0": "Method Name", "h-1": "Parameters", "0-0": "launchReferralScreen", "0-1": "[ReferralScreenSettings](page:android-referral-settings)", "h-2": "Description", "0-2": "Lets you launch a pre-built referral ui with sharing options", "2-0": "setLoyaltyEventListener", "2-1": "[LoyaltyEvent](page:android-loyalty-events)", "3-0": "setGamificationEarnedEventListener", "3-1": "[GamificationEarnedEvent](page:android-gamification-event)", "2-2": "Lets you listen to loyalty events like Tier upgrades etc.", "3-2": "Lets you listen to gamification events like Achievements unlocked, Badge upgrade etc.", "1-0": "launchRewardsScreen", "1-1": "[Android Rewards Screen Settings](page:android-rewards-screen-settings)", "1-2": "Lets you launch a pre-build rewards fulfilment UI" }, "cols": 3, "rows": 4 } [/block]