https://github.com/batchlabs/batch-android-sdk-sample
Sample app for Batch's Android SDK
https://github.com/batchlabs/batch-android-sdk-sample
Last synced: 8 months ago
JSON representation
Sample app for Batch's Android SDK
- Host: GitHub
- URL: https://github.com/batchlabs/batch-android-sdk-sample
- Owner: BatchLabs
- License: mit
- Created: 2018-09-26T12:20:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-06-09T12:00:57.000Z (about 1 year ago)
- Last Synced: 2025-09-29T23:55:35.479Z (9 months ago)
- Language: Kotlin
- Homepage:
- Size: 1.79 MB
- Stars: 4
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Batch store
Sample mCommerce (Batch Store) for sales.
This sample is a full fledged example meant to show both basic and advanced integrations of the Batch SDK with a real-world use case.
# How run it
* Clone this repository
* Follow this instructions about prerequisites [https://batch.com/doc/android/prerequisites](https://batch.com/doc/android/prerequisites.html). You will need to associate the project to a Firebase Project to continue.
* Batch SDK is already installed, you have to setup Batch with your API KEY in build.gradle : `buildConfigField "String", "API_KEY", '""'` Make sure you keep `'"` before your API Key and `"'` after, they are needed to make a working string constant.
* Build gradle
* Run your app, open the Logcat tab of Android Studio. You should see the following logs :
```
Batch () is running in dev mode (your API key is a dev one)
Installation ID:
```
More information : [https://batch.com/doc/android/sdk-integration](https://batch.com/doc/android/sdk-integration.html#_your-first-start)
# In App Messaging
Well, installation's over you can setup your first In App campaign.
### How sample work
In-App campaigns will appear on your users’ screen according to a specific trigger.
For example, you can choose to display an In-App promoting a discount when a user add one article to cart.
Sample app contains 3 triggers
```kotlin
// Track when the user select an article
fun trackArticleVisit(article: Article){
Batch.Profile.trackEvent("ARTICLE_VIEW", BatchEventAttributes().apply {
put(BatchEventAttributes.LABEL_KEY, article.name)
put("name", article.name)
})
}
// Track when the user add article to cart
fun trackAddArticleToCart(article: Article){
Batch.Profile.trackEvent("ADD_TO_CART", BatchEventAttributes().apply {
put(BatchEventAttributes.LABEL_KEY, article.name)
put("name", article.name)
})
}
// Track when the user proceed to checkout
fun trackCheckout(amount: Double){
Batch.Profile.trackEvent("CHECKOUT", BatchEventAttributes().apply {
put("amount", amount)
})
}
```
This triggers can be use in the Batch dashboard with labels.
More details here : https://batch.com/doc/dashboard/in-app-messaging/campaign-edition.html#_trigger-condition
**Example :**
- Create campaign
- Set trigger **display event** : `add_to_cart`
- Set **label** : `Patek Philippe` (If you don’t select any labels, Batch will trigger the message on every trigger of the selected event)

- Setup message edition on the interface
In app, if you select Patek Philippe in your cart, you will see In App messaging.
## Resources
* [Full Batch documentation](https://dashboard.batch.com/doc)
* [support@batch.com](support@batch.com)