ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Mobile specific functions / Phone functions
  • WLanguage procedure called
  • Special cases
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Enables the management of push notifications in a WINDEV Mobile application (Android or iOS).
iPhone/iPad We advise you to call this function in the initialization process of the project because it must be run whenever the application is started.
Example
// Activation des notifications push
NotifPushEnable(EnregistreNotifPush)
// Gestion de l'enregistrement
PROCÉDURE EnregistreNotifPush(Token is Buffer, ErreurNotif is string)
IF Length(Token) > 0 THEN
// Informe le serveur d'application du nouvel identifiant
EnvoieIDSurServeur(Token)
ELSE
// Remonte l'erreur
Info("Erreur d'enregistrement: " + ErreurNotif)
END
Syntax
NotifPushEnable(<WLanguage procedure> [, <Options>])
<WLanguage procedure>: Procedure name
Name of WLanguage procedure called when the application receives the registration identifier from the notification service.
<Options>: Combination of optional Integer constants
Recording options. Can correspond to one or more of the following constants:
notifPushAlertTypeThe mobile application will accept the push notifications in alert format.
Android Constant not available.
notifPushAllNotif
(Default value)
The mobile application will accept all types of push notifications.
notifPushBadgeTypeThe mobile application will accept the push notifications in badge format.
Android Constant not available.
notifPushSoundTypeThe mobile application will accept the sound push notifications.
Android Constant not available.

Caution: These options are taken into account during the first application setup. Then, the user can modify the notifications accepted in the Notification Center of device.
Remarks

WLanguage procedure called

The Procedure WLanguage called by the NotifPushEnable function must be of the form:
PROCEDURE EnregistreNotifPush(<Identifiant> est un Buffer, <Erreur> est une chaîne)
This procedure is called when the registration toward the notification service is ended.
The parameters of this procedure are as follows:
  • <Identifier>: "Token" buffer corresponding to the registration identifier returned by the notification service. This buffer must be transmitted to the application server so that push notifications can be sent to the application.
    Caution: This buffer must be transmitted to the application server:
    • when its value changed in relation to the previous execution of the application. To do so, its value must be stored in a data file of the application or in a buffer on disk created by fSaveBuffer or SaveParameter.
    • if the application is started by the user (and not by the arrival of a push notification). The ExeInfo function allows to know if the application is launched by the arrival of an Notification.
    This buffer can be empty if a registration error occurred during the registration request. In this case, the <Error> parameter will be filled with the error message.
    • iPhone/iPad To transmit the buffer to an external application (that will send the notifications), this buffer will have to be converted in order to use the hexadecimal notation via BufferToHexa. Example:
      BufferToHexa(bufToken, 4, BigEndian)
  • <Error>: Character string describing a registration error. This parameter is filled only if an error occurred during the registration request.

Special cases

  • iPhone/iPad This function can be called only if the application includes a certificate for the push notifications.
  • iPhone/iPad If the function is called several times during the same execution of the application, only the first call is taken into account.
  • Android The device communicates with the Google Cloud Messaging (GCM) notification service by using the following ports: 5228, 5229 and 5230. Make sure that your firewall is configured accordingly.
  • Android If the Google Cloud Messaging notification service could not be contacted at the time the NotifPushEnable function was called (e.g. network connectivity problem), the Record request will be automatically repeated with an interval of increasing time (1 hour maximum) until the request is successful or an error is cleared. Therefore, a long time can exist between the call to NotifPushEnable and the call to the procedure passed as parameter.
  • The NotifPushEnable function is asynchronous because it makes a request on the Apple server (or Google in the case of Android).
Related Examples:
WM Push Cross-platform examples: WM Push
[ + ] This example shows how to receive Push notifications.
It calls the PushNotifActive function and returns the identifier to "WD Push Server", which stores it.
Then, the "Send Push" example reads this identifier and sends Push notifications to this example.
Business / UI classification: Business Logic
Component: wd270android.jar
Minimum version required
  • Version 19
Comments
Click [Add] to post a comment

Last update: 06/23/2023

Send a report | Local help