This document is a brief guide on how to use Local Notifications in GeneXus Native Mobile apps.
There are two objects in the GeneXus Core module that are used to enable Local Notifications.
Read about them in the LocalNotifications external object article.
The LocalNotifications external object includes a method called CreateAlerts that expects a variable based on the LocalNotificationsInfo SDT as an input parameter.
When this action is executed, the app will schedule all the local notifications passed in the LocalNotifications SDT variable.
Step 2: Programming the Local Notifications
To make them work, just create the following Procedure object (e.g.: named "SendLocalNotificationsServer").
In this example, this Procedure is created to load the LocalNotificationsInfo SDT. Bear in mind that this can be done differently, as it is not compulsory to do it with a Procedure.
&MySdtLocalNotificationsItems.DateTime = ymdhmstot(2012,06,07,16,56,00)
&MySdtLocalNotificationsItems.Text = "My Local Test"
MySdtLocalNotifications -> SDTLocalNotifications
MySdtLocalNotificationsItems -> SDTLocalNotifications.Item
Next, create a Panel object:
&MySdtLocalNotifications = SendLocalNotificationsServer()
Run your application.
First, press the Panel button to start scheduling Local Notifications.
After that, the Notifications will be scheduled and they will appear on your device at the time specified.
When the local notification is added:
When the local notification is triggered:
A working example of this method can be downloaded from: WorkingWithLocalNotifications.
The Create method of the external object returns a numeric value. If the returned value is 0, it means that there was no error in the execution. Otherwise, if the numeric value is different than 0, an execution error occurred.
This feature has been added to GeneXus in:
Apple since GeneXus Evolution 2 Upgrade 1
Android since GeneXus Evolution 2 Upgrade 3
- Since iOS 8, local notifications require authorization from the user. The user will be automatically asked for this authorization the first time you use this API. If you want to do it manually, it can be done by using the Permissions external object for Apple applications (e.g. when the app is in the background).
- If the DateTime field of the LocalNotification SDT is empty, the notification will be triggered instantly.
LocalNotifications external object