PushBots Android SDK setup guide.
PushBots is a push notification service that help you manage notifications on all platforms (Android, iOS, Web, react-native, cordova) efficiently and easily.
-
A PushBots account
-
You will find APP_ID while integrating your project with dashboard
-
-
An APP-ID and CLIENT-ID from HWS (HUAWEI Service)
allprojects {
repositories {
maven { url 'http://developer.huawei.com/repo/' }
}
}
implementation 'com.pushbots:pushbots-lib:3.3.0@aar'
implementation 'com.huawei.hms:push:4.0.0.300'
implementation 'com.google.android.gms:play-services-location:17.0.0' // optional
Add to defaultConfig section, then replace PUSHBOTS_APP_ID and HUAWEI_CLIENT_ID
defaultConfig {
// Add PushBots integration data
manifestPlaceholders = [
pushbots_app_id : "YOUR_APP_ID",
pushbots_loglevel : "DEBUG",
google_sender_id : "YOUR_CLIENT_ID"
]
}
Set your app-id that you get from HMS console in your manifest:
<meta-data
android:name="com.huawei.hms.client.appid"
android:value="appid=YOUR_HMS_APP_ID" />
PushBots should be initialized when app just started, one of the existing ways is to initialize it in our application.
import android.app.Application
import com.pushbots.push.Pushbots
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize Pushbots Library
Pushbots.sharedInstance().init(this)
}
}
Now add your Application to Manifest.xml
<application
android:name=".MyApplication">
</application>
Now you have initialized PushBots successfully, BUT there is one more step to be able to receive notifications.
You need to register for it (You may register for it inside you MyApplication.class or MainActivity.class):
//Register for Push Notifications
Pushbots.sharedInstance().registerForRemoteNotifications()
-
Using the plugins DSL
plugins {
id "com.pushbots.android.plugin.pushbots-gradle-plugin" version "1.0-SNAPSHOT"
}
-
Using legacy plugin application:
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
// Inside your app.build.gradle
dependencies {
classpath "gradle.plugin.com.pushbots:pushbots-gradle-plugin:1.0-SNAPSHOT"
}
}
apply plugin: "com.pushbots.android.plugin.pushbots-gradle-plugin"