Skip to content

Local Notification Feature ​

1. Add a Local Notification ​

Function ​

java
gamedreamerAddLocalNotification(Context context, GDNotificationInfo info, GDAddLocalNotificationListener listener)

Parameters ​

GDNotificationInfo ​

Property NameProperty TypeRequiredDetails
notifyIdintYesThe 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.
titleStringYesLocal notification title
contentStringYesLocal notification content
isRepeatingbooleanYesWhether this notification is a fixed-cycle repeating notification. Code judgment priority is higher than repeatType.
repeatTypeGDRepeatTypeYesPeriodic 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
triggerTimeMillislongYesNotification 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 NameParameter TypeParameter Description
notifyIdintIdentifier 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);
                                }
                            });