{"__v":1,"_id":"55f1bbbb7dccfc0d00986b7d","category":{"__v":4,"_id":"55f1970d229b772300779a1f","pages":["55f1baf839e3e8190068b306","55f1bbbb7dccfc0d00986b7d","55f1bc693936d52d00fb3cd2","55f1bcd039e3e8190068b30c"],"project":"55de06fa57f7b20d0097636b","version":"55de06fa57f7b20d0097636e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-10T14:43:25.537Z","from_sync":false,"order":3,"slug":"unity-sdk","title":"Unity SDK"},"parentDoc":null,"project":"55de06fa57f7b20d0097636b","user":"55de06e19db51a0d0064947d","version":{"__v":13,"_id":"55de06fa57f7b20d0097636e","project":"55de06fa57f7b20d0097636b","createdAt":"2015-08-26T18:35:38.642Z","releaseDate":"2015-08-26T18:35:38.642Z","categories":["55de06fb57f7b20d0097636f","55f1962e3936d52d00fb3c8f","55f1970339e3e8190068b2b8","55f1970d229b772300779a1f","55f1971cfd98c42300acc605","55f1d5c7fd98c42300acc69f","563cbfe4260dde0d00c5e9d4","5644cf437f1fff210078e690","57dc1bbd3ed3450e00dc9ea7","58a600a2243dd30f00fd8773","58ed1bdc068f780f00f64602","58f13b3a4f0ee50f00e24e81","58f173f792f9020f009cad16"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-09-10T17:19:55.140Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"Integrating the PushSpring SDK into your app is straightforward, with a basic integration taking around 15 minutes.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"1. Request SDK Binary\"\n}\n[/block]\nEmail <support:::at:::pushspring.com> for the binary.\n\nInside the Unity SDK, you'll find a folder called **UnitySDK/Assets/Plugins**.  If you haven't used plugins in your project then copy the **Assets/Plugins** folder to your **Assets** folder otherwise merge the files in the **Assets/Plugins** folder into the same locations in your app's **Assets/Plugins** folder.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Android Builds\"\n}\n[/block]\nRe-export your Android project from Unity so that the new plugin files are copied over.\n\nFollow the instructions in our Android [Getting Started](doc:getting-started-2) section but take note of the following differences:\n\n* Unity marks the main activity as singleTask so ensure that you have implemented an onNewIntent method in the relevant Activities.\n\n* Your **AndroidManifest.xml** file will be overwritten when you export the project again from Unity. The easiest way of ensuring this does not happen is to copy the finished AndroidManifest.xml file to your Unity project's **Assets/Plugins/Android** folder. You should be aware that if you change any Unity settings that would change anything in the **AndroidManifest.xml** file, you will need to manually make the change to the copy in the plugins directory.\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Configuring your API Key\"\n}\n[/block]\nBefore getting started, get your app's API key from the PushSpring Audience Console. You'll use this API key when initializing the SDK in the following steps.  You can share API keys between Android and iOS versions of the same app if you like, but each separate app that you integrate the PushSpring SDK into should be given its own API key so the audiences are tracked independently by PushSpring.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/f0d3035-32fAEmN0SxiAlMuaslkv_Screen_Shot_2015-12-01_at_8.33.25_PM.png\",\n        \"32fAEmN0SxiAlMuaslkv_Screen Shot 2015-12-01 at 8.33.25 PM.png\",\n        2550,\n        1162,\n        \"#949495\"\n      ]\n    }\n  ]\n}\n[/block]\nThe final integration step in your Unity project will be to call the **PushSpringSDK.Init** method from the Start method of a script that runs when your game starts. Pass it the API key you got from the PushSpring dashboard.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"function Start () {\\n    PushSpringSDK.Init(\\\"YOUR-API-KEY\\\");\\n}\\n\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"Initial Integration with Unity SDK","slug":"getting-started-on-android","type":"basic","title":"Getting Started on Android"}

Getting Started on Android

Initial Integration with Unity SDK

Integrating the PushSpring SDK into your app is straightforward, with a basic integration taking around 15 minutes. [block:api-header] { "type": "basic", "title": "1. Request SDK Binary" } [/block] Email <support@pushspring.com> for the binary. Inside the Unity SDK, you'll find a folder called **UnitySDK/Assets/Plugins**. If you haven't used plugins in your project then copy the **Assets/Plugins** folder to your **Assets** folder otherwise merge the files in the **Assets/Plugins** folder into the same locations in your app's **Assets/Plugins** folder. [block:api-header] { "type": "basic", "title": "2. Android Builds" } [/block] Re-export your Android project from Unity so that the new plugin files are copied over. Follow the instructions in our Android [Getting Started](doc:getting-started-2) section but take note of the following differences: * Unity marks the main activity as singleTask so ensure that you have implemented an onNewIntent method in the relevant Activities. * Your **AndroidManifest.xml** file will be overwritten when you export the project again from Unity. The easiest way of ensuring this does not happen is to copy the finished AndroidManifest.xml file to your Unity project's **Assets/Plugins/Android** folder. You should be aware that if you change any Unity settings that would change anything in the **AndroidManifest.xml** file, you will need to manually make the change to the copy in the plugins directory. [block:api-header] { "type": "basic", "title": "3. Configuring your API Key" } [/block] Before getting started, get your app's API key from the PushSpring Audience Console. You'll use this API key when initializing the SDK in the following steps. You can share API keys between Android and iOS versions of the same app if you like, but each separate app that you integrate the PushSpring SDK into should be given its own API key so the audiences are tracked independently by PushSpring. [block:image] { "images": [ { "image": [ "https://files.readme.io/f0d3035-32fAEmN0SxiAlMuaslkv_Screen_Shot_2015-12-01_at_8.33.25_PM.png", "32fAEmN0SxiAlMuaslkv_Screen Shot 2015-12-01 at 8.33.25 PM.png", 2550, 1162, "#949495" ] } ] } [/block] The final integration step in your Unity project will be to call the **PushSpringSDK.Init** method from the Start method of a script that runs when your game starts. Pass it the API key you got from the PushSpring dashboard. [block:code] { "codes": [ { "code": "function Start () {\n PushSpringSDK.Init(\"YOUR-API-KEY\");\n}\n", "language": "javascript" } ] } [/block]