Self-built notification statistics reporting APIs (3.x)
This topic applies to Android SDK 3.x. The description for each API specifies the minimum required SDK version. In this topic, references to "and later versions" apply only to the 3.x series. For applications that use SDK 4.x, see Self-built notification statistics reporting APIs (4.x).
Introduction
You may need to create your own UI elements, such as notifications or pop-up windows, to interact with users after receiving push data in the following scenarios:
-
You receive a passthrough message from Mobile Push and process its data in an
onMessagecallback. -
You intercept a notification message from Mobile Push and handle its data yourself.
If you handle push data yourself, you must also handle the corresponding click and dismissal events. Otherwise, your push notification statistics will be inaccurate.
Mobile Push provides a reporting API that you must call at the appropriate points in your code. For guidance, see Mobile Push Android SDK: Best practices for passthrough messages and self-built notifications.
-
If you do not handle push data yourself, you do not need to use the reporting API.
-
These APIs require Android SDK version 3.0.6 or later.
API for self-built notification clicks
This API reports the click event for a self-built notification. Ensure that you report the event only once for each message.
clickMessage
API definition
void clickMessage(CPushMessage message)
Class
CloudPushService
Parameters
|
Parameter |
Type |
Required |
Description |
|
message |
CPushMessage |
Yes |
The |
Code example
PushServiceFactory.getCloudPushService().clickMessage(cPushMessage);PushServiceFactory.getCloudPushService().clickMessage(cPushMessage);API for self-built notification dismissals
This API reports the dismissal event for a self-built notification. Ensure that you report the event only once for each message.
dismissMessage
API definition
void dismissMessage(CPushMessage message)
Class
CloudPushService
Parameters
|
Parameter |
Type |
Required |
Description |
|
message |
CPushMessage |
Yes |
The |
Code example
PushServiceFactory.getCloudPushService().dismissMessage(cPushMessage);PushServiceFactory.getCloudPushService().dismissMessage(cPushMessage);