Extend the A3LMessagingService class
TheA3LMessagingService class is part of the A3L Messaging SDK. You must extend from this class to allow your app to receive messages. The following table describes the methods you must override in your implementation.
| Method | Description |
|---|---|
onMessageReceived() | Called when a message is delivered to your app instance. |
onNewToken() | Called when a new device ID for the app instance is ready. |
MyA3LMessagingService.
Update your app manifest
You must update your app’s AndroidManifest.xml file to receive messages. The following examples useMyA3LMessagingService as a placeholder for your implementation of the A3LMessagingService class.
-
Declare your implementation of the
A3LMessagingServiceclass as a receiver. This allows you to handleREGISTRATIONandMESSAGEintents. -
Add details about your implementation of
A3LMessagingServiceas metadata. This allows proper initialization of A3L Messaging.
Retrieve the registration token
On initial startup of your app, the A3L Messaging library generates a registration token for the client app instance. This token is delivered in your overriddenonNewToken() method of the A3LMessagingService class.
To get the current registration token, call A3LMessaging.getToken(), as shown in the following example.
Optional - Create an escape hatch
If you have a special use case and want to create a custom method, you can create an escape hatch for that scenario. TheA3LMessaging class provides you with an instance of an ADM object and a FirebaseMessaging object that you can make calls from.
-
Use
A3LMessaging.getCurrentPlatform()to get the current messaging solution as aString.- If
FCM_PLATFORMis returned, useA3LMessaging.getFCMInstance()to get the instance. - If
ADM_PLATFORMis returned, useA3LMessaging.getADMInstance().
- If
-
Now you can make calls directly with the
FirebaseMessagingandADMobjects. See the following example. -
If you need to override methods which are unsupported by the
A3LMessagingService, you can create your own custom class. To do this, inherit from the solution-specific API and override the method you need access to. For example, if your app needs access to theonDeletedMessages()method fromFirebaseMessagingService, you could create a class like the one in the following example.You must also set up your app to listen for the events of this API. The setup required might vary based on the messaging solution and API.

