@regantis-sdk/push-android
v0.1.1
Published
Native Android SDK distribution for Regantis Push with Firebase FCM and Huawei HMS support.
Maintainers
Readme
@regantis-sdk/push-android
Native Android SDK for Regantis Push. Supports Firebase Cloud Messaging (FCM) and Huawei Push Kit (HMS) through one Regantis registration API and synchronizes Regantis-managed Android notification channels.
This is a native Android library distributed through npm. It does not require JavaScript at runtime.
Requirements
- Android minSdk 23
- Android compileSdk 34+
- Java 17
- Regantis Push application configured for Android
- FCM apps:
google-services.jsonand Google Services plugin - HMS apps:
agconnect-services.jsonand Huawei AGConnect plugin
Install
From the Android project root:
npm install @regantis-sdk/push-androidIn settings.gradle, expose the native module from node_modules:
include ':regantis-push'
project(':regantis-push').projectDir = new File(
rootDir,
'node_modules/@regantis-sdk/push-android/regantis-push'
)In app/build.gradle:
dependencies {
implementation project(':regantis-push')
}The project repositories must include Huawei if HMS is used:
maven { url 'https://developer.huawei.com/repo/' }FCM configuration
Keep the normal Firebase setup in the consuming application and place google-services.json in the app/ module.
HMS configuration
Keep the normal Huawei AGConnect setup in the consuming application, enable Push Kit in AppGallery Connect, and place agconnect-services.json in the app/ module.
Initialize
Call once from Application.onCreate() or before registration:
RegantisPush.initialize(
this,
new RegantisPushConfig("YOUR_REGANTIS_APP_ID")
);Optional configuration:
RegantisPush.initialize(
this,
new RegantisPushConfig(
"https://push.regantis.technology",
"YOUR_REGANTIS_APP_ID",
RegantisPushConfig.ProviderPreference.AUTO,
R.drawable.ic_notification
)
);Register
RegantisPush.register(this, (success, value) -> {
// success: value is the Regantis subscription ID
// failure: value is the error message
});AUTO tries FCM first and falls back to HMS. You can force ProviderPreference.FCM or ProviderPreference.HMS.
Android 13+ notification permission must be requested by the consuming application before visible notifications are expected.
Channel synchronization
Registration automatically attempts channel synchronization. It can also be refreshed explicitly:
RegantisPush.syncChannels(this, null);Existing FCM/HMS message services
The library manifest registers Regantis FCM/HMS services. If the consuming application already declares its own FirebaseMessagingService or HmsMessageService, override/remove the Regantis service entry and forward token/message events to the Regantis SDK as appropriate.
Direct package fallback
The same SDK is also downloadable from the Regantis Push application SDK page.
Unregister / opt out
RegantisPush.unregister(this, (success, value) -> {
// The Regantis subscription is disabled immediately.
});The SDK keeps notification-provider registration intact; unregister disables delivery from Regantis and a later register() reactivates the device.
