Skip to content

Commit 984d723

Browse files
Alexey MuryshkinAlexey Muryshkin
authored andcommitted
feat: AdaptivePlusSDK v2.1.1
1 parent f41a75b commit 984d723

File tree

9 files changed

+279
-41
lines changed

9 files changed

+279
-41
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ obj/
164164
.idea/dynamic.xml
165165
.idea/uiDesigner.xml
166166
.idea/jarRepositories.xml
167+
.idea/runConfigurations.xml
167168

168169
# OS-specific files
169170
.DS_Store

README.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
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)*

app/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ android {
3333
}
3434

3535
dependencies {
36-
3736
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
3837
implementation 'androidx.core:core-ktx:1.3.2'
3938
implementation 'androidx.appcompat:appcompat:1.2.0'
4039
implementation 'com.google.android.material:material:1.3.0'
4140
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
42-
testImplementation 'junit:junit:4.+'
41+
42+
implementation 'plus.adaptive:android-sdk:2.1.0'
43+
44+
testImplementation 'junit:junit:4.13.2'
4345
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
4446
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
4547
}

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,21 @@
44
package="plus.adaptive.example">
55

66
<application
7+
android:name=".MyApp"
78
android:allowBackup="true"
89
android:icon="@mipmap/ic_launcher"
910
android:label="@string/app_name"
1011
android:roundIcon="@mipmap/ic_launcher_round"
1112
android:supportsRtl="true"
1213
android:theme="@style/Theme.AdaptivePlusExample">
1314

14-
<activity android:name=".MainActivity">
15+
<activity android:name=".SplashActivity">
1516
<intent-filter>
1617
<action android:name="android.intent.action.MAIN" />
1718
<category android:name="android.intent.category.LAUNCHER" />
1819
</intent-filter>
1920
</activity>
2021

21-
<meta-data
22-
android:name="adaptivePlusApiKey"
23-
android:value="your api key"
24-
/>
2522
</application>
2623

2724
</manifest>

app/src/main/java/plus/adaptive/example/MainActivity.kt

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package plus.adaptive.example
2+
3+
import android.app.Application
4+
import plus.adaptive.sdk.AdaptivePlusSDK
5+
6+
7+
class MyApp : Application() {
8+
9+
override fun onCreate() {
10+
super.onCreate()
11+
12+
AdaptivePlusSDK.init(
13+
apiKey = "your api key")
14+
}
15+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package plus.adaptive.example
2+
3+
import androidx.appcompat.app.AppCompatActivity
4+
import android.os.Bundle
5+
import plus.adaptive.sdk.AdaptivePlusSDK
6+
import plus.adaptive.sdk.data.listeners.APSplashScreenListener
7+
import plus.adaptive.sdk.data.models.APLocation
8+
9+
10+
class SplashActivity : AppCompatActivity() {
11+
12+
override fun onCreate(savedInstanceState: Bundle?) {
13+
super.onCreate(savedInstanceState)
14+
setContentView(R.layout.activity_splash)
15+
16+
// Default Use Case
17+
AdaptivePlusSDK
18+
.newInstance(this)
19+
.showSplashScreen()
20+
21+
// User-Centric Use Case
22+
AdaptivePlusSDK
23+
.newInstance(this)
24+
.setUserId("app_user_id")
25+
.setUserProperties(
26+
mapOf("age" to "25", "gender" to "male")
27+
)
28+
.setLocation(
29+
APLocation(
30+
latitude = 37.7749,
31+
longitude = 122.4194
32+
)
33+
)
34+
.showSplashScreen()
35+
36+
// Drafts Enabled Mode Use Case
37+
AdaptivePlusSDK
38+
.newInstance(this)
39+
.showSplashScreen(hasDrafts = true)
40+
41+
// Splash Screen Listener Use Case
42+
AdaptivePlusSDK
43+
.newInstance(this)
44+
.setSplashScreenListener(
45+
object: APSplashScreenListener {
46+
override fun onFinish() {
47+
// TODO: actions to do on the splash screen finish
48+
}
49+
50+
override fun onRunAPCustomAction(params: HashMap<String, Any>) {
51+
// TODO: your implementation of Adaptive Plus Custom Action
52+
}
53+
}
54+
)
55+
.showSplashScreen()
56+
57+
// All-in Use Case
58+
AdaptivePlusSDK
59+
.newInstance(this)
60+
.setUserId("app_user_id")
61+
.setUserProperties(
62+
mapOf("age" to "25", "gender" to "male")
63+
)
64+
.setLocation(
65+
APLocation(
66+
latitude = 37.7749,
67+
longitude = 122.4194
68+
)
69+
)
70+
.setSplashScreenListener(
71+
object: APSplashScreenListener {
72+
override fun onFinish() {
73+
// TODO: actions to do on the splash screen finish
74+
}
75+
76+
override fun onRunAPCustomAction(params: HashMap<String, Any>) {
77+
// TODO: your implementation of Adaptive Plus Custom Actions
78+
}
79+
}
80+
)
81+
.showSplashScreen(hasDrafts = true)
82+
}
83+
84+
}

app/src/main/res/layout/activity_main.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
5+
xmlns:tools="http://schemas.android.com/tools"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
tools:context=".SplashActivity">
9+
10+
<TextView
11+
android:id="@+id/textView"
12+
android:layout_width="0dp"
13+
android:layout_height="wrap_content"
14+
android:layout_marginStart="16dp"
15+
android:layout_marginEnd="16dp"
16+
android:gravity="center"
17+
android:text="Main Activity"
18+
android:textColor="@android:color/black"
19+
android:textSize="24sp"
20+
app:layout_constraintTop_toTopOf="parent"
21+
app:layout_constraintStart_toStartOf="parent"
22+
app:layout_constraintEnd_toEndOf="parent"
23+
app:layout_constraintBottom_toBottomOf="parent"
24+
/>
25+
26+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)