The SDK currently supports the following kits/APIs:
- Analytics
- Location
- Maps
- Messaging
- Sign in
To use HMS services in the first place, integration of the HMS core SDK is needed. Follow the steps mentioned in How to set up the HMS core sdk.
As for the firebase integration just follow the official guide: https://firebase.google.com/docs/android/setup
The following plugins are required by the core of the SDK and need to be declared in your app.
Project
gradle:
buildscript{
repositories {
maven { url 'http://developer.huawei.com/repo/' }
}
dependencies {
// GMS
classpath 'com.google.gms:google-services:4.3.3'
// HMS
classpath 'com.huawei.agconnect:agcp:1.4.1.300'
}
}
allprojects {
repositories {
maven {url 'http://developer.huawei.com/repo/'}
}
}
App
gradle:
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.huawei.agconnect'
Add the following dependencies as required to your app. GMS, Firebase and HMS dependencies are included, so they do not need to be declared in your app.
dependencies {
implementation 'at.bluesource.choicesdk:choicesdk-analytics:0.1.0'
implementation 'at.bluesource.choicesdk:choicesdk-location:0.1.0'
implementation 'at.bluesource.choicesdk:choicesdk-maps:0.1.0'
implementation 'at.bluesource.choicesdk:choicesdk-messaging:0.1.0'
implementation 'at.bluesource.choicesdk:choicesdk-signin:0.1.0'
}
The Choice SDK needs the application context at start. You can provide the needed context by calling ChoiceSdk.init(this)
in your application class:
class YourApp : Application() {
override fun onCreate() {
super.onCreate()
ChoiceSdk.init(this)
}
}
Usually instances of SDK classes can be created by using their corresponding factory, for example AnalyticsFactory.getAnalytics(this)
. These calls can throw an UnsupportedOperationException
if neither GMS nor HMS services are available, so make sure to check beforehand.
The SDK might need some additional permissions, so add them if you see any Lint errors in your IDE.
Important note: The provided examples do not check for permissions! Add permission checks where needed.
Examples for each part are described in the documentation below.