Add or clear local notifications (AddLocalNotification/ClearLocalNotifications)
caution
For Android platform, you need to enable the ANDROID_LOCAL_NOTIFICATION_ENABLE configuration in INTLConfig.ini.
Local notifications are set by the user, stored locally, and triggered by time.
If the set time is less than the current device time, the notification will pop up immediately.
info
Android and iOS message structures are different.
Function definition
// Add Local Notification for Android
UFUNCTION(BlueprintCallable, Category = "INTLSDKAPI")
static bool AddLocalNotification(const FString Channel, const FINTLLocalNotification LocalNotification);
// Add Local Notification for iOS
UFUNCTION(BlueprintCallable, Category = "INTLSDKAPI")
static bool AddLocalNotificationIOS(const FString Channel, const FINTLLocalNotificationIOS localNotification);
// Clear Local Notifications
UFUNCTION(BlueprintCallable, Category = "INTLSDKAPI")
static bool ClearLocalNotifications(const FString Channel);
Parameter description
AddLocalNotification
| Parameters | Type | Explanation |
|---|---|---|
| Channel | FString | Channel definition e.g., "Firebase" |
| LocalNotification | FINTLLocalNotification | Local message structure |
AddLocalNotificationIOS
| Name | Parameter Type | Explanation |
|---|---|---|
| Channel | FString | Channel definition e.g., "Firebase" |
| LocalNotification | FINTLLocalNotificationIOS | Local message structure |
Callback Handling
The callback handling interface is PushResultObserver.The callback data structure is PushResult.
The callback ID is kMethodIDPushAddLocalNotification, kMethodIDPushClearLocalNotifications.
Code Example
FINTL Local Notification message;
UINTLSDKAPI::AddLocalNotification("Firebase", message);
FINTL Local Notification iOS message;
UINTLSDKAPI::AddLocalNotificationIOS("Firebase", message);
Data Structure
Android
FINTLLocalNotification
| Member Variable Name | Type | Explanation |
|---|---|---|
| ActionType | int | Set action type: 1: Open activity or the app itself 2: Open the browser 3: Open Intent 4: Open application via package name |
| NotificationID | int | Specify the notification ID; notifications with the same ID that have already been displayed will be overwritten by subsequent ones. |
| Title | String | Set message title |
| Content | string | Set message content |
| TickerText | String | Set ticker text content |
| ActionParameter | String | When ActionType=1, ActionParameter can be the class name of an Activity within the app.e.g., com.intl.TestActivity. When ActionType=2, ActionParameter is a URL that will be opened directly in the browser upon notification click. When ActionType=3, ActionParameter is a serialized Intent. When ActionType=4, ActionParameter is the application's package name. |
| FireTime | long | Set the time to trigger the notification, of type long (UTC timestamp, unit: seconds). |
| SoundEnabled | int | Enable sound playback 0: No, 1: Yes Default: 1 |
| RingRaw | String | Specify the sound in the application (raw/ring.mp3), e.g.: android.resource://intlgame.demo/raw/ring |
| SmallIcon | String | Specify the small icon for the status bar (test.png) e.g.: test |
| Lights | int | Enable breathing light 0: No, 1: Yes Default: 0 |
| Vibrate | int | Enable vibration 0: No, 1: Yes Default: 0 |
iOS
FINTLLocalNotificationIOS
| Member Variables | Type | Explanation |
|---|---|---|
| NotificationID | String | [Required] Specify the notification ID Notifications with the same displayed ID will be overridden by the latter. |
| RepeatType | int | Push repeat interval 1: Minute 2: Hour 3: Day 4: Week 5: Month 6: Year Default: 0, meaning no repeat |
| FireTime | long | Time to trigger the local notification |
| Badge | int | Badge |
| AlertBody | String | Content of the push |
| AlertAction | String | Replace the button text in the popup Default: Launch |
| UserInfo | List<Dictionary<string,string>> | Custom parameters, can be used to identify the push and add additional information |
| AlertTitle | String | Short description of the push |