Official Content

The LocalNotifications external object enables your app to alert users of scheduled events or alarms in the background, with no servers required.

LocalNotificationsexternalobject-Location_GeneXus18u3  

Scope

Generators:  Apple, Android

Properties

It does not have any.

Methods

CreateAlerts method

Creates a set of local notifications (or alerts) by indicating when each of them will be triggered and the text that will be displayed. It returns 0 if the operation ends successfully.

Return value  Numeric(5.0)
Parameters alerts:LocalNotificationsInfo


ListAlerts method

Lists every local notification (or alert) previously created.

Return value  LocalNotificationsInfo
Parameters None


RemoveAlerts method

Removes a set of local notifications (or alerts), each of them identified by its triggered timestamp and its text. It returns 0 if the operation ends successfully.

Return value  Numeric(5.0)
Parameters alerts:LocalNotificationsInfo


RemoveAllAlerts method

Removes every local notification (or alert) from the device. It returns 0 if the operation ends successfully.

Return value  Numeric(5.0)
Parameters None


Events

It does not have any.
 

LocalNotificationsInfo Structured Data Type

In addition to the LocalNotifications external object, the LocalNotificationsInfo Structured Data Type (SDT) is used to define the configuration of the Local Notification.

image_2023428214851_1_png

It is a collection of items, each one containing the following:

  • DateTime:DateTime data type
    Indicates when the local notification will be triggered. If you do not set this field (you leave it empty), the notification will be triggered instantly.
     
  • Text:VarChar(128)
    Contains the text to be shown to the user as a local notification.
     
  • Event:

    It allows defining an event to be executed when the user interacts with a local notification.

    • Name: VarChar(40)
      Name of the event that you want to execute.
       
    • Parameters:

      Allows you to define parameters in case the event needs them.

You can define as many Local Notifications as you want. A single item on the LocalNotificationsInfo collection is equivalent to one Local Notification.

Sample

Consider a Panel object with its Main program property = True. 

The Panel Layout contains a button that is associated with the 'NotificationEvent' event:

Event 'NotificationEvent'
 Composite
   &AlertDateTime = Now()
   &AlertDateTime = &AlertDateTime.AddSeconds(10)        
   &LocalNotItem = New() //The notification is created
   &LocalNotItem.DateTime = &AlertDateTime
   &LocalNotItem.Text = !'You have a new notification'
   &LocalNotItem.Event.Name = "EventCallType"   //Name of the event to be called. It must be defined in the Panel.
   &localNotEventsParameters.Name = "callParam" //Variable name defined in the Panel and used in the event to be called.
   &localNotEventsParameters.Value = "PopUp"    //Value assigned to the previous variable name.
   &LocalNotItem.Event.Parameters.Add(&LocalNotEventsParameters)
   &LocalNotInfo.Add(&LocalNotItem)
 EndComposite
Endevent
Event "EventCallType"
 Composite 
    InfoPanel.CallOptions.Type = &callParam //The &callParam value is "Popup"
    InfoPanel.Call(&callParam)              //The Panel is called with the chosen CallOptions Type as a parameter
 EndComposite
EndEvent

When tapping on the Panel button, the 'NotificationEvent' event is executed. This event loads a variable based on the LocalNotificationsInfo SDT. So, the EventCallType event will be executed when indicated (&AlertDateTime was assigned). In this example, the EventCallType event calls a Panel (InfoPanel) with the PopUp mode.

Note: Read about CallOptions and CallOptions Type.

See Also

HowTo: Use LocalNotifications external object in Native Mobile apps
Push Notifications in Native Mobile Applications (servers required)

Last update: November 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant