Official Content

This document explains how to use a device's registration service for push notifications and provides a brief overview about it.

Every time an end user executes a GeneXus application that has the Enable Notifications property enabled, the service configured in the Registration Handler property is automatically executed in order to register and store the device information to be used later when sending messages to that device.

A Procedure object called NotificationsRegistrationHandler is included as a sample of this service. You can find it in the KB Explorer under Root Module >  GeneXus > SD > Notifications with a typical implementation.

Rules:
   parm(in:&DeviceType, in:&DeviceId, in:&DeviceToken, in:&DeviceName);

Code: 
   for each
      where DeviceType = &DeviceType
      where DeviceId  = &DeviceId   
      DeviceToken = &DeviceToken    
      DeviceName = &DeviceName      
   when none
      new
         DeviceType  = &DeviceType
         DeviceId = &DeviceId
         DeviceToken = &DeviceToken
         DeviceName = &DeviceName
      endnew
   endfor

The Parm rule must have these four parameters in order to retrieve the device information.

  • &DeviceType: SmartDeviceType
  • &DeviceId: Character(128)
  • &DeviceToken: Character(1000)
  • &DeviceName: Character(128)

After the service executes, information such as the following is registered:

  • DeviceType:
        Apple or Android
  • DeviceId:
       8bb3ud27c7cce885b1c41a3cf5f5bd3m4b22w96d
  • DeviceToken:
    When the Notifications Provider property is set to a value other than "None", this token contains information about the device in JSON format.
    The following example shows this data when using OneSignal as the Notification Provider:

  {
       "DeviceToken": "PJy0nafLvZiXvbGlmYuidCpA7JY5ryuW30KoQmpOs=",
       "DeviceId": "8bb3ud27c7cce885b1c41a3cf5f5bd3m4b22w96d",
       "DeviceType": 1,
       "NotificationPlatform": "OneSignal",
       "NotificationPlatformId": fb508412-2f91-46b1-90e1-f052247d1f8c
   }

*If the DBMS is MySql, DeviceToken must be defined as VarChar(1000) instead of Char(1000); otherwise, the entire token will not be recorded.

If no Notification Provider is used, the token should look as follows:
    PJy0nafLvZiXvbGlmYuidCpA7JY5ryuW30KoQmpOs=

  • DeviceName :
       iPhone Mary

With this information, you can start sending messages to registered devices (those that use your application).

Notes: 

  • If you have a completely offline application, and you need this Registration Handler procedure to be generated exclusively offline, set Main property = False and Connectivity Support property = Offline.
  • Device registration does not work when prototyping with KBN (Knowledge Base Navigator) or simulators.
  • The Registration Handler service is called when the application is opened.

Troubleshooting

1. Android devices are not being registered

  • The Android Sender Id and/or Android Sender API Key properties in the main object are not set.
  • Simulators without Google Play Services do not support Firebase, so they cannot be registered. Use devices instead.

See Also

HowTo: Configure Push Notifications in Apple Applications
HowTo: Configure Push Notifications in Android Applications

  

Last update: December 2025 | © GeneXus. All rights reserved. GeneXus Powered by Globant