|
| 1 | +# [AdaptivePlus Android SDK](https://adaptive.plus/) |
| 2 | + |
| 3 | +[**AdaptivePlus**](https://adaptive.plus/) is the control center for marketing campaigns in mobile applications |
| 4 | + |
| 5 | +### Requirements |
| 6 | +- minSdkVersion 16 |
| 7 | + |
| 8 | +*Examples provided in Kotlin programming language* |
| 9 | + |
| 10 | +## Guide for integration of AdaptivePlus SDK |
| 11 | + |
| 12 | +### Step 1 |
| 13 | +Include AdaptivePlus SDK dependency into app module **build.gradle**: |
| 14 | + |
| 15 | +```groovy |
| 16 | +dependencies { |
| 17 | + implementation 'plus.adaptive:android-sdk:2.1.1' |
| 18 | +} |
| 19 | +``` |
| 20 | + |
| 21 | +Do not forget to sync project with gradle files afterwards |
| 22 | + |
| 23 | +### Step 2 |
| 24 | +Register an account in the admin panel of [AdaptivePlus](https://adaptive.plus/) |
| 25 | + |
| 26 | +Initialize AdaptivePlusSDK on app startup and pass the **API key** that you received upon account registration |
| 27 | + |
| 28 | +```kotlin |
| 29 | +// App StartUp |
| 30 | +class YourApp: Application() { |
| 31 | + override fun onCreate() { |
| 32 | + super.onCreate() |
| 33 | + |
| 34 | + AdaptivePlusSDK |
| 35 | + .init(apiKey = "your api key") |
| 36 | + } |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +### Step 3 |
| 41 | +Show AdaptivePlus Splash Screen on app startup or after user logs in (or at any suitable moment) |
| 42 | + |
| 43 | +```kotlin |
| 44 | +class MainActivity: Activity() { |
| 45 | + override fun onCreate(savedInstanceState: Bundle?) { |
| 46 | + super.onCreate(savedInstanceState) |
| 47 | + setContentView(R.layout.activity_main) |
| 48 | + |
| 49 | + AdaptivePlusSDK |
| 50 | + .newInstance(context) |
| 51 | + .showSplashScreen() |
| 52 | + } |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +Now, you can visit the admin panel and create some content. Do not forget to change the status of the content to **active**. |
| 57 | +On the first `showSplashScreen` method call (first app launch), the SDK preloads the splash screen contents to your device, and will have a loading delay before displaying it. On the subsequent method calls, probably, the splash screen contents are already preloaded, and the splash screen will be displayed on the screen instantly |
| 58 | + |
| 59 | +If you are not able to observe the created content - probable reasons are: |
| 60 | +- You forgot to activate the content in the AdaptivePlus admin panel |
| 61 | +- Check again the integration guide, maybe you missed something out |
| 62 | +- The SDK couldn't preload the contents on the previous `showSplashScreen` method calls due to network issues or internal sdk issues |
| 63 | + |
| 64 | +## More information on the features of AdaptivePlus SDK |
| 65 | + |
| 66 | +### SDK Permissions |
| 67 | +Be aware that AdaptivePlus SDK requires internet to work properly, therefore |
| 68 | +```xml |
| 69 | +<uses-permission android:name="android.permission.INTERNET" /> |
| 70 | +``` |
| 71 | +will be added to the manifest file during the app build process |
| 72 | + |
| 73 | +### Initialization Exception |
| 74 | +SDK throws `APInitializationException` on `newInstance` method call if **adaptivePlusApiKey** is not provided beforehand via `init` method |
| 75 | + |
| 76 | +### AdaptivePlus Personalized Experience |
| 77 | +In order to make SDK experience more personalized, you can provide following user data: |
| 78 | +```kotlin |
| 79 | +AdaptivePlusSDK |
| 80 | + .newInstance(context) |
| 81 | + .setUserId(userId) |
| 82 | + .setUserProperties(userProperties) |
| 83 | + .setLocation(userLocation) |
| 84 | + .showSplashScreen() |
| 85 | +``` |
| 86 | +`userId: String` - id assigned to the user by your own system/service, useful for identifying the same user across multiple devices\ |
| 87 | +`userProperties: Map<String, String>` - user properties, e.g. - age, gender, etc. User properties help SDK to select and show content relevant to the user. Ex: |
| 88 | +```kotlin |
| 89 | +val userProperties = mapOf("age" to "25", "gender" to "male") |
| 90 | +``` |
| 91 | +`userLocation: APLocation` - user location (latitude & longitude). Required to display geo-oriented content to the user |
| 92 | +```kotlin |
| 93 | +data class APLocation( |
| 94 | + val latitude: Double, |
| 95 | + val longitude: Double |
| 96 | +) : Serializable |
| 97 | +``` |
| 98 | + |
| 99 | +### Splash Screen Draft Campaigns |
| 100 | +To take a look at splash screen campaigns that are on moderation (not active) state pass `hasDrafts` parameter as `true` to `showSplashScreen` method: |
| 101 | +```kotlin |
| 102 | +AdaptivePlusSDK |
| 103 | + .newInstance(context) |
| 104 | + .showSplashScreen(hasDrafts = true) |
| 105 | +``` |
| 106 | + |
| 107 | +### Splash Screen Listener |
| 108 | +```kotlin |
| 109 | +interface APSplashScreenListener { |
| 110 | + fun onFinish() {} |
| 111 | + fun onRunAPCustomAction(params: HashMap<String, Any>) {} |
| 112 | +} |
| 113 | +``` |
| 114 | +For listening of the splash screen events - you should provide your implementation of `APSplashScreenListener`: |
| 115 | +```kotlin |
| 116 | +AdaptivePlusSDK |
| 117 | + .newInstance(context) |
| 118 | + .setSplashScreenListener( |
| 119 | + object: APSplashScreenListener { |
| 120 | + override fun onFinish() { |
| 121 | + // TODO: actions to do on the splash screen finish |
| 122 | + } |
| 123 | + |
| 124 | + override fun onRunAPCustomAction(params: HashMap<String, Any>) { |
| 125 | + // TODO: your implementation of Adaptive Plus Custom Actions |
| 126 | + } |
| 127 | + } |
| 128 | + ) |
| 129 | + .showSplashScreen() |
| 130 | +``` |
| 131 | + |
| 132 | +### AdaptivePlus Debug Mode |
| 133 | +To observe network logs of the SDK - pass `true` to `setIsDebuggable` method: |
| 134 | +```kotlin |
| 135 | +AdaptivePlusSDK |
| 136 | + .newInstance(context) |
| 137 | + .setIsDebuggable(true) |
| 138 | +``` |
| 139 | +Do not forget to switch *Debug Mode* off for the release build of your app. |
| 140 | + |
| 141 | +## Android SDK version - 2.1.0 |
| 142 | +1) Shows SDK generated Splash Screen with countdown timer: able to display Images & GIFs & Texts, execute simplest set of actions on click |
| 143 | +2) Action list contains:\ |
| 144 | +(1) *Web URL Opening in WebView dialog window*,\ |
| 145 | +(2) *DeepLink call to Android Operating System*,\ |
| 146 | +(3) *Send SMS & Call Phone*,\ |
| 147 | +(4) *Custom Action (you should implement it, nothing will happen otherwise)* |
0 commit comments