A SDK that aims to wrap similar functionalities from HMS and GMS services to one common interface. This is the launchpad for app providers expanding from GMS (Google Mobile Services) to HMS (Huawei Mobile Services) without having another codebranch to be setup, published and maintained. Choice SDK is already in use in multiple commercial, public and privat operated apps. The goal is to save development, maintainance and security issues now and in future.
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.3'
implementation 'at.bluesource.choicesdk:choicesdk-location:0.1.3'
implementation 'at.bluesource.choicesdk:choicesdk-maps:0.1.3'
implementation 'at.bluesource.choicesdk:choicesdk-messaging:0.1.3'
implementation 'at.bluesource.choicesdk:choicesdk-signin:0.1.3'
}
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.
How to set up the HMS core SDK
If you would like to use our demo app, you have to follow some steps to be able to build and run the project:
- Create a GMS and HMS project and download
google-services.json
andagconnect-services.json
files intoChoiceSDK/choicesdk-app
. - In the app's
build.gradle
file replacehmsProperties['HMS_APP_ID']
with your HMS app id, or create aChoiceSDK/choicesdk-app/hms.properties
file in with the following content and your HMS app id:HMS_APP_ID=xxx
- Change the
applicationId
of the app to the ID which you used to create the GMS/HMS projects. - To build a release version replace our release signing config with your keystore properties.