Rokt Demo application is a sample app built to showcase Rokt mobile SDK functionality. The purpose of this app is to showcase the functionality that Rokt provides in-app. The app features multiple pages with different placement examples to demonstrate the functionality of the Rokt mobile SDK.
- Thomson Thomas - thomson.thomas@rokt.com
- James Newman - james.newman@rokt.com
Environment | Build |
---|---|
release |
The latest version of Android Studio is required. Follow these instructions to install or alternatively on Mac using brew:
brew install --cask android-studio
The project is configured to run on Android API 21 and above and compiled against API 31.
- Open Android Studio
- Open the project by selecting the project folder
- Wait for Gradle sync to finish (this could take a while the first time)
- Select a physical device or virtual device from the dropdown
- Click the green run button
To run all tests, select the rokt-demo-android [test]
run configuration and click the green run button.
If you can't find this configuration then you can run all the tests via the command line using
./gradlew test
.
To preview Rokt layouts on an Android emulator:
- In OnePlatform, use the layout preview option for mobile layouts to generate a QR code
- The demo app can process this QR code data through a deeplink
- To trigger the preview, use the following adb command format:
Where
adb shell am start -a android.intent.action.VIEW -d "rokt://demo/preview?config=<URL_ENCODED_JSON>"
<URL_ENCODED_JSON>
is a placeholder that should be replaced with the actual URL-encoded JSON data extracted from the QR code. The JSON data typically includes the following fields:tagId
: A unique identifier for the tag.previewId
: The ID of the preview layout.versionId
: The version of the layout.creativeIds
: A list of creative IDs associated with the layout.language
: The language code (e.g., "en").layoutVariantIds
: A list of layout variant IDs.
Example command:
adb shell am start -a android.intent.action.VIEW -d "rokt://demo/preview?config=%7B%22tagId%22%3A%222754655826098840951%22%2C%22previewId%22%3A%223435870199391584257%22%2C%22versionId%22%3A%221746660670465%22%2C%22creativeIds%22%3A%5B%223335250570341581807%22%2C%223341268103002062853%22%2C%223334226469759813591%22%2C%223334285963646863068%22%5D%2C%22language%22%3A%22en%22%2C%22layoutVariantIds%22%3A%5B%223435870199391584258%22%5D%7D"
Note: The deeplink URL is constructed by combining the prefix rokt://demo/preview?config=
with the URL-encoded JSON data from the QR code. Ref: #82
GitHub Actions is used as the CI system.
Workflows and actions are defined in the .github
directory.
- Update build
versionCode
andversionNumber
in build.gradle file - Commit & push
- Dispatch the workflow
Distribute to Firebase
from the Actions tab on GitHub
This project is implemented based on the MVVM and repository patterns.
MVVM (Model-View-ViewModel) is an architectural pattern that serves to separate user interface logic from business/program logic.
- The Model layer provides the business logic of the application. In this case, it consists of multiple repositories that expose data sources to the ViewModel.
- The View layer consists of the UI elements that the user interacts with, which are represented by composable elements in this project.
- The ViewModel layer connects the Model and View layers. It transforms data from the Model layer and stores the UI state that is accessed by the View layer.
For example, when the user interacts with the View layer via the UI elements, events are sent to the ViewModel layer. Based on these events, the ViewModel can then access data from the Model layer through the repositories. Using this data, the ViewModel can update the UI state. As the View is observing this UI state, it can then automatically update the UI elements once the ViewModel changes the state.
This separation of responsibility between the three layers ultimately simplifies the project architecture and improves testability by reducing coupling.
This project contains data, di, model, ui, and utils packages.
data: contains repositories that expose data from network operations performed by RoktDemoService.
di: for dependency injection.
model: contains data classes that model data.
ui: contains the View and ViewModels
utils: contains shared utility functions used throughout the application
MainActivityViewModel contains an observable selectedTagId which is set from other pages in the application. The selectedTagId is observed in the MainActivity, where Rokt.Init() is called every time the tagId value is changed. This is because our application is a single Activity application, and Rokt.init requires an Activity to be passed in. All other Rokt SDK related calls happen in RoktExecutor.
In the ApplicationModule, change provideDemoRepository to return DemoLibraryRepositoryMockImpl and provideAboutRoktRepository to return AboutRoktRepositoryMockImpl.
They are defined under buildSrc/dependencies. For more information on kotlin_dsl visit: https://docs.gradle.org/current/userguide/kotlin_dsl.html
Copyright 2020 Rokt Pte Ltd
Licensed under the Rokt Software Development Kit (SDK) Terms of Use
Version 2.0 (the "License");
You may not use this file except in compliance with the License.
You may obtain a copy of the License at https://rokt.com/sdk-license-2-0/