MobileNotifications.Send

From Xojo Documentation

Method

MobileNotifications.Send(content as NotificationContent)

New in 2020r2

Supported for all project types and targets.

Send the notification to the OS for immediate delivery.


Method

MobileNotifications.Send(interval as DateInterval, content as NotificationContent, shouldRepeat as Boolean = False) As String

New in 2020r2

Supported for all project types and targets.

Sends the notification to the OS for delivery once the interval has been reached.


Method

MobileNotifications.Send(secondsFromNow as Double, content as NotificationContent, shouldRepeat as Boolean = False) As String

New in 2020r2

Supported for all project types and targets.

Sends the notification to the OS for delivery in secondsFromNow seconds.


Method

MobileNotifications.Send(scheduledDate as DateTime, content as NotificationContent, shouldRepeat as Boolean = False) As String

New in 2020r2

Supported for all project types and targets.

Sends the notification to the OS for delivery at the date and time specified by the scheduleDate.


Method

MobileNotifications.Send(Latitude as Double, Longitude as Double, Radius as Double, identifier as String, mode as LocationNotification.Modes, content as NotificationContent, shouldRepeat as Boolean = False) As String

New in 2020r2

Supported for all project types and targets.

Sends the notification to the OS for delivery when the device enters or exists a region as specified by radius meters around a specific latitude and longitude.

Notes

In cases where the notification won't be immediately displayed, Send returns a UUID which your app should store if you wish to be able to remove the notification before it is displayed.

Repeating Notifications

There are times when you may wish a notification to repeat. To do this, set the shouldRepeat parameter to True. The interval at which it repeats is based upon the method signature you used. For example, if you want the notification to repeat hourly, set the interval to 1 hour. To repeat every year on the same day, set the DateTime and to repeat every time the user enters or exits a region, set the latitude, longitude and radius.

Creating a repeating notification is no guarantee the notification will in fact repeat. If the user has turned off notifications for your app, if their device is in Do Not Disturb mode or Low Power mode, notifications may not be delivered.

Sample Code

Send a notification right now:

NotificationCenter.Send(New NotificationContent("The connection has been lost."))

Send a notification every hour:

Var id As String
Var interval As New DateInterval(0, 0, 0, 1)
id = NotificationCenter.Send(interval, New NotificationContent("Are we there yet?"), True)

Send a notification in 30 seconds:

Var id As String
id = NotificationCenter.Send(30, New NotificationContent("Your access code has expired."))

Send a notification on a specific date every year:

Var id As String
Var birthday As DateTime(2890, 9, 22)
id = NotificationCenter.Send(birthday, New NotificationContent("Happy Birthday, Bilbo!"), True)

Send a notification to remind the user to visit the President of the United States when they are in town:

Var id As String
id = NotificationCenter.Send(38.897957, -77.036560, 1000, New NotificationContent("Visit the POTUS."), True)

See Also

NotificationContent, DateInterval and DateTime classes.