Manual Startup Instructions
Initialising the modules manually.
The SDK uses Android App Startup to automatically initialize and start the SDK. If you have disabled App Startup for your application, please follow the below steps. The SDK must be started before attempting to use any of its features. Startup must occur from your Application.onCreate
method, if your app does not have an Application class you must create one.
Step 1: Disable Automatic Initialization
To prevent the SDK modules from initializing automatically via App Startup, add the following to your AndroidManifest.XML file.
Note
Disable the modules only if they are integrated into your app; otherwise, there's no need to disable them.
<application
android:name="MyDemoApplication"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<!-- Disable automatic initialization of core module -->
<meta-data
android:name="com.webex.connect.core.startup.CoreModuleInitializer"
tools:node="remove" />
<!-- Disable automatic initialization of push module -->
<meta-data
android:name="com.webex.connect.push.PushModuleInitializer"
tools:node="remove" />
<!-- Disable automatic initialization of fcm push module -->
<meta-data
android:name="com.webex.connect.push.fcm.FcmPushModuleInitializer"
tools:node="remove" />
<!-- Disable automatic initialization of hms push module -->
<meta-data
android:name="com.webex.connect.push.hms.HmsPushModuleInitializer"
tools:node="remove" />
<!-- Disable automatic initialization of in-app messaging module -->
<meta-data
android:name="com.webex.connect.inapp.InAppModuleInitializer"
tools:node="remove" />
</provider>
</application>
For more details, refer to the Disable automatic initialization for an individual component section in the Android developer documentation.
Step 2: Manually Start the SDK
In your Application class (or create one if not already present), call the SDK initialization methods explicitly:
// Application class to initialize the WebexConnect SDK
class MyDemoApplication: Application() {
override fun onCreate() {
super.onCreate()
// Set the application context
WebexConnect.applicationContext = this
// Get the instance of WebexConnect
val webexConnect: WebexConnect = WebexConnect.instance
// Initialize the WebexConnect SDK
webexConnect.startup { exception ->
if (exception == null) {
Log.d("DemoApplication", "WebexConnect SDK started successfully")
} else {
Log.e("DemoApplication", "WebexConnect SDK failed to start", exception)
}
}
// Register additional modules. Register only those you plan to use.
// Get the PushMessaging instance
val pushMessaging: PushMessaging = PushMessaging.instance
// Create the PushProvider instance (If using FCM)
val pushProvider = FcmPushProvider.create(this)
// Create the PushProvider instance (If using HMS)
// HmsPushProvider pushProvider = HmsPushProvider.create(this);
// Assign the provider.
pushMessaging.provider = pushProvider
// Register the PushMessaging module with WebexConnect
webexConnect.registerModule(pushMessaging)
// Get the InAppMessaging instance
val inAppMessaging: InAppMessaging = InAppMessaging.instance
// Register the InAppMessaging module with WebexConnect
webexConnect.registerModule(inAppMessaging)
}
}
// Application class to initialize the WebexConnect SDK
public class MyDemoApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Set the application context
WebexConnect.setApplicationContext(this);
// Get the instance of WebexConnect
WebexConnect webexConnect = WebexConnect.getInstance();
// Initialize the WebexConnect SDK
webexConnect.startup(exception - > {
if (exception == null) {
Log.d("DemoApplication", "WebexConnect SDK started successfully");
} else {
Log.e("DemoApplication", "WebexConnect SDK failed to start", exception);
}
return null;
});
// Register additional modules. Register only those you plan to use.
// Get the PushMessaging instance
PushMessaging pushMessaging = PushMessaging.getInstance();
// Create the PushProvider instance (If using FCM)
FcmPushProvider pushProvider = FcmPushProvider.create(this);
// Create the PushProvider instance (If using HMS)
// HmsPushProvider pushProvider = HmsPushProvider.create(this);
// Assign the provider.
pushMessaging.setProvider(pushProvider);
// Register the PushMessaging module with WebexConnect
webexConnect.registerModule(pushMessaging);
// Get the InAppMessaging instance.
InAppMessaging inAppMessaging = InAppMessaging.getInstance();
// Register the InAppMessaging module with WebexConnect.
webexConnect.registerModule(inAppMessaging);
}
}
Updated 9 days ago