Local Notification Feature
1. Add a Local Notification
Function
java
gamedreamerAddLocalNotification(Context context, GDNotificationInfo info, GDAddLocalNotificationListener listener)Parameters
GDNotificationInfo
| Property Name | Property Type | Required | Details |
|---|---|---|---|
| notifyId | int | Yes | The identifier ID for the local notification. If the notiID of an added notification is the same, the later notification overwrites the previous one. This can be used to update notifications of the same type. |
| title | String | Yes | Local notification title |
| content | String | Yes | Local notification content |
| isRepeating | boolean | Yes | Whether this notification is a fixed-cycle repeating notification. Code judgment priority is higher than repeatType. |
| repeatType | GDRepeatType | Yes | Periodic notification repeat type. Four repeat types are currently supported: ; GDRepeatType.NONE: no repeat ; GDRepeatType.DAILY: repeat every day at the specified time ; GDRepeatType.WEEKLY: weekly ; GDRepeatType.MONTHLY: monthly |
| triggerTimeMillis | long | Yes | Notification display time (timestamp, milliseconds) |
Code Example
java
GDNotificationInfo info = new GDNotificationInfo(
notiId,// Notification ID
"Local notification title, id:" + notiId,// Notification title
"Local notification content",// Notification content
System.currentTimeMillis() + 5 * 1000,// Display after 5 seconds
false, // Do not repeat
GDRepeatType.NONE);
GDSDK.gamedreamerAddLocalNotification(context, info, new GDAddLocalNotificationListener() {
@Override
public void onResult(boolean isSuccess, String message, GDNotificationInfo info) {
simpleToast(message);
}
});2. Get the Added Notification List
Function
java
List<GDNotificationInfo> gamedreamerGetLocalNotificationsList()Code Example
java
List<GDNotificationInfo> infoList = GDSDK.gamedreamerGetLocalNotificationsList();
simpleToast("Current local notification count: " + infoList.size());
Log.i(TAG, "Current local notifications: \n" + infoList);3. Cancel a Specified Notification
Function
java
gamedreamerCancelLocalNotification(Context context, int notifyId, GDCancelLocalNotificationListener listener)| Parameter Name | Parameter Type | Parameter Description |
|---|---|---|
| notifyId | int | Identifier ID of the target notification to delete |
Example Code
java
GDSDK.gamedreamerCancelLocalNotification(context, notifyId, new GDCancelLocalNotificationListener() {
@Override
public void onResult(boolean isSuccess, String msg, int notifyId) {
simpleToast(msg);
}
});