Android
Android Push Notifications
Last updated
Android Push Notifications
Last updated
Push Notifications on Android are sent with the help of the FCM service.
How to create a project in Firebase and integrate Firebase Services into your application, you can find in Firebase documentation.
Next, you need to specify the FCM Server key in the push notifications integration settings panel in the application settings section in devtodev service (App → Settings → Push notifications → Push notifications panel)
To get the FCM Server key, go to the Project Settings of your Android project in the Firebase Console and copy the Server key from the Cloud Messaging tab.
The Messaging module is available as an AAR (recommended) and JAR library. The library is available in the MavenCentral and GitHub repository.
1. If you use Gradle for the applications build, add mavenCentral()
into gradle.build file of your application and specify the following relationship in dependencies block:
2. To the app manifest add the following:
3. To add a user icon to your push notification and change its color, add the following strings to the manifest file code:
To add a large user icon to your push notifications, add:
Example:
4. After the DTDAnalytics
initializer, add the DTDMessaging
initializer.
Example:
5. Subscribe a DTDPushListener
to receive information about the DTDMessaging
functioning.
Example:
6. Call the DTDMessaging.startPushService()
method to activate the Messaging module.
DTDMessaging
moduleObject | Description |
| The main object for push notification initialization. |
| The push notification initialization method. |
| The push notification activation method. It passes the |
| A property responsible for the activation/deactivation of push notifications. Functions as a getter (describes the current state) and a setter (sets the current state). When the state transitions, it sends a pt with The |
| A method of passing a user intent to the SDK using PushMessage. |
Written in the manifest file
| Sets a small custom user icon. |
Written in the manifest file
| Sets a color of the small custom user icon. |
Written in the manifest file
| Sets a large custom user icon. |
| Returns a push notification registration token ( |
| Used to pass the push notification to the FirebaseMessagingService if it was implemented by the client but not by the SDK. |
| ( |
DTDPushListener
Interface MethodsDTDPushListener Interface Methods | Description |
| Returns a push notification registration token ( |
onPushServiceRegistrationFailed(String error) | Returns errors during push notification registration. |
| Returns a directory with data for improving your push notifications. |
| Returns |
DTDPushMessage
).Property | Type | Description |
| Map<String, String> | Complete information sent with the use of a remote push notification. |
| Int | The notification ID used in the devtodev system. |
| String? | Returns the selected message title or app name if the former is unavailable. |
| String? | The text body. |
| String? | A group of messages. |
| Uri? | Returns the storage path of an audio file. |
| String? | The notification sound name. |
| String? | The notification tag. |
| String? | The notification color. |
| String? | The notification banner if specified. |
| DTDActionType | The property that returns an enum’s DTDActionType value. Possible values:
|
| String? | The property that returns an optional action ID. |
| Int | The icon resource identifier specified by the user (if specified). |
| String? | The large notification icon name. |
| List<DTDActionButton> | The list of action buttons used in the push notification. |
| Boolean | Specifies whether the push notification was sent using the devtodev API. |
DTDActionButton
)Property | Type | Description |
| String? | The property that returns the tapped button ID. |
| String? | The property that returns the optional action ID. |
| DTDActionType | The property that returns an enum’s Possible values:
|
| String? | The property that returns the button’s icon name. |
| Boolean | The button-click app open mode. |
| String? | The property that returns the text of the tapped button. |