Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace doc with shared doc link #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 2 additions & 187 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,193 +4,8 @@

Mobile framework for Appbooster platform.

## Installation
* [Docs](https://platform.appbooster.com/ab/docs)

1. On project level `build.gradle` add `jcenter` repository to all projects section
```
allprojects {
// ...
repositories {
jcenter()
// ...
}
}
```

2. Add the library to `app` level `build.gradle` dependencies section
```
dependencies {
// ...
implementation "com.appbooster.appboostersdk:appboostersdk:${appbostersdk_version}"
// ...
}
```

## Usage


### Initialization:

Kotlin:
```
val sdk = AppboosterSdk.Builder(context) // you can initiate sdk using either application or activity context
.appId("${YOUR_APP_ID}")
.sdkToken("${YOUR_SDK_TOKEN}")
.deviceId("${YOUR_DEVICE_ID}") // optional, UUID generated by default
.usingShake(false) // true by default for debug mode, turn it off if you are already using shake motion in your app for other purposes
.defaults(
mapOf(
"${TEST_1_KEY}" to "${TEST_1_DEFAULT_VALUE}",
"${TEST_2_KEY}" to "${TEST_2_DEFAULT_VALUE}"
)
)
.build()
```

Java:
```
Map<String, String> defaults = new HashMap<>();
defaults.put("${TEST_1_KEY}", "${TEST_1_DEFAULT_VALUE}");
defaults.put("${TEST_2_KEY}", "${TEST_2_DEFAULT_VALUE}");

AppboosterSdk sdk = new AppboosterSdk.Builder(this)
.appId("${YOUR_APP_ID}")
.sdkToken("${YOUR_SDK_TOKEN}")
.deviceId("${YOUR_DEVICE_ID}") // optional, UUID generated by default
.usingShake(true) // true by default for debug mode, turn it off if you are already using shake motion in your app for other purposes
.defaults(defaults)
.build();
```

### How to fetch known test values that associated with your device?

Kotlin:
```
sdk.fetch(onSuccessListener = object: AppboosterSdk.OnSuccessListener{
override fun onSuccess() {
}
},
onErrorListener = object: AppboosterSdk.OnErrorListener{
override fun onError(throwable: Throwable) {
}
})
```

Java:
```
sdk.fetch(new AppboosterSdk.OnSuccessListener() {
@Override
public void onSuccess() {
...
}
},
new AppboosterSdk.OnErrorListener() {
@Override
public void onError(Throwable throwable) {
...
}
});
```

### How to get the value for a specific test?

Kotlin:
```
val value = sdk["${TEST_KEY}"]
```

Java:
```
String value = sdk.getValue("${TEST_KEY}");
```

In case of problems with no internet connection or another, the values obtained in the previous session will be used, or if they are missing, the default values specified during initialization will be used.

### How to get user tests for analytics?

Kotlin:
```
val experiments = sdk.experiments
```

Java:
```
Map<String, String> experiments = sdk.getExperiments();
```

Appsflyer users can integrate Appbooster sdk with analytics as shown below:

Kotlin:
```
val experiments = sdk.experiments
AppsFlyerLib.getInstance().setAdditionalData(experiments)
```

Java:
```
Map<String, String> experiments = sdk.getExperiments();
AppsFlyerLib.getInstance().setAdditionalData(experiments);
```

Amplitude users can integrate Appbooster sdk with analytics as shown below:

Kotlin:
```
val experiments = sdk.experiments
val userProperties = JSONObject(experiments)
Amplitude.getInstance().setUserProperties(userProperties)
```

Java:
```
Map<String, String> experiments = sdk.getExperiments();
JSONObject userProperties = new JSONObject(experiments);
AppsFlyerLib.getInstance().setAdditionalData(userProperties);
```

### How to debug?

Before debug make sure that debug-mode for your App is turned-on on [settings page](https://platform.appbooster.com/ab/settings)

![](https://imgproxy.appbooster.com/9ACImnEbmsO822dynjTjcC_B8aXzbbpPQsOgop2PlBs//aHR0cHM6Ly9hcHBib29zdGVyLWNsb3VkLnMzLmV1LWNlbnRyYWwtMS5hbWF6b25hd3MuY29tLzk0N2M5NzdmLTAwY2EtNDA1Yi04OGQ4LTAzOTM4ZjY4OTAzYi5wbmc.png)

Kotlin:
```
AppboosterSdk.Builder(context)
//...
.showLogs(true) false by default, to print all debugging info in the console
//...


val duration = sdk.lastOperationDurationMillis // the duration of the last operation in milliseconds
```

Java:
```
AppboosterSdk.Builder(context)
//...
.showLogs(true) false by default, to print all debugging info in the console
//...

long duration = sdk.getLastOperationDurationMillis();
```

In debug mode you can see all actual tests and check how the user will see each option of the test.
To show the debug activity you just need to turn it on in your personal cabinet and call

Kotlin:
```
sdk.launchDebugMode(context: Context) // you can use either application or activity context
```

Java:
```
sdk.launchDebugMode(Context context); // you can use either application or activity context
```

By default debug activity will be shown by performing shake motion on your device.


==================================================
---

You can see the example of usage in `ExampleAppKotlin` and `ExampleAppJava` modules in this project.