Skip to content

Module: notifications

Table of contents

Functions

Functions

cancelAllAsync

cancelAllAsync(label?): Promise<boolean>

Cancels all scheduled notifications.

Example

Wortal.notifications.cancelAllAsync();

Parameters

Name Type Description
label? string Optional label of the notification category to cancel. If this is used then only notifications with the specified label will be cancelled.

Returns

Promise<boolean>

Promise that resolves true if all notifications were cancelled successfully, false otherwise.

Throws

  • NOT_SUPPORTED
  • OPERATION_FAILED

cancelAsync

cancelAsync(id): Promise<boolean>

Cancels a scheduled notification.

Example

Wortal.notifications.cancelAsync("1234567890");

Parameters

Name Type Description
id string ID of the notification to cancel.

Returns

Promise<boolean>

Promise that resolves true if the notification was cancelled successfully, false otherwise.

Throws

  • NOT_SUPPORTED
  • INVALID_PARAM
  • OPERATION_FAILED

getHistoryAsync

getHistoryAsync(): Promise<ScheduledNotification[]>

Gets the history of scheduled notifications for the past 30 days.

Example

Wortal.notifications.getHistoryAsync().then((notifications) => {
    notifications.forEach((notification) => {
        console.log(notification.id);
        console.log(notification.status);
    });
});

Returns

Promise<ScheduledNotification[]>

Promise that contains an array of notifications scheduled.

Throws

  • NOT_SUPPORTED
  • OPERATION_FAILED

scheduleAsync

scheduleAsync(payload): Promise<NotificationScheduleResult>

Schedule a notification to be delivered to the player at a later time. Limit of 5 pending scheduled notifications per recipient.

Example

Wortal.notifications.scheduleAsync({
   title: "Your energy is full!",
   body: "Come back and play again.",
   mediaURL: "https://example.com/image.png",
   label: "resources-full",
   scheduleInterval: 300 // 5 minutes
}).then((result) => {
  console.log(result.id);
});

Parameters

Name Type Description
payload NotificationPayload Object defining the notification to be scheduled.

Returns

Promise<NotificationScheduleResult>

Throws

  • NOT_SUPPORTED
  • INVALID_PARAM