PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Principle
  • Managing the notifications in the Mobile application
  • Managing the notifications in the application server
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
A mobile device can receive push notifications. A notification is a message that is displayed (and stored) on the device, in the notification center of device. A notification can be used to start a process for example.
A notification is sent from a remote application, usually found on a server.
The application for sending notifications can be developed in WINDEV or WEBDEV, or via external tools.
Principle
Four elements are required to create a push notification system:
  • A mobile application (iOS or Android) run on the appropriate device.
  • A notification service that is used to distribute the push messages to the phones or tablets. This service is supplied:
    • by Google: Firebase
      Note: the application created before version 22 are using the Google Cloud Messaging mechanism (GCM). This mechanism will be made obsolete by Google from April 2019.
    • by Apple (APM).
  • An application server (or provider) that decides to send the messages and that establishes the communication with the business database (this server can be a webservice or a WEBDEV or WINDEV application).
  • A database, used to store the identifiers of the different devices receiving the push messages as well as business data.
The global operating mode of push messages is as follows :
  1. The application registers toward the Apple or Google service by using the "device id" and the "application id".
  2. If the registration is successful, the Apple or Google service returns a token (or "registration id") to the application.
  3. The application transmits the token to the application server (provider).
  4. The server stores the token in its database.
A push message is send according to the following method:
a. The application server sends a message (by using an SSL socket (iOS) or an HTTPS socket (Android)) containing the token to the Apple or Google service.
Note: this sending can be done by an external application, as long as this one can access the business database and the certificate used for the communication with the notification service.
b. The Apple or Google service transmits the message to the relevant device.
Managing the notifications in the Mobile application
Several functions can be used to manage the notifications in the Mobile application:
Versions 19 and later
NotifPushDisable
New in version 19
NotifPushDisable
NotifPushDisable
Disables the management of push notifications for a WINDEV Mobile application (Android or IOS).
Versions 19 and later
NotifPushEnable
New in version 19
NotifPushEnable
NotifPushEnable
Enables the management of push notifications in a WINDEV Mobile application (Android or iOS).
Versions 19 and later
NotifPushProcedure
New in version 19
NotifPushProcedure
NotifPushProcedure
Specifies the WLanguage procedure called when a push notification is received by a WINDEV Mobile application (Android or iOS).
Caution: a specific configuration is required in order for the mobile applications to operate:
The behavior when receiving a notification is as follows:
  1. If the application is closed, the system displays the notification in the notification bar. The user can choose to validate the notification. If he does, the application is started.
    Android If no message is specified in the notification, the application is started and the notification is not displayed.
    Two cases may occur once the application is started:
    • If NotifPushProcedure was called in the initialization code of project, the global procedure passed in parameter to this function is called and the first application window is not opened.
      Note: OpenMobileWindow must be called in the procedure.
    • If NotifPushProcedure was not called, the first application window is opened.
  2. If the application is already started:
    • Android If a message or a title is specified in the notification, the system displays the notification in the notification bar. If the user clicks the notification, the procedure specified in NotifPushProcedure is called (nothing happens if it is not specified).
      If no message and no title is specified in the notification, the notification is not displayed and the procedure is called directly.
    • iPhone/iPad Two cases may occur:
      • If the application is in the foreground, the procedure of NotifPushProcedure is called directly. If no procedure is specified, only an "ok" button is displayed.
      • If the application is in the background, the system displays the notification. If the user validates the notification, the application goes back to the foreground and the procedure of NotifPushProcedure is called.
Managing the notifications in the application server
The application server is the WINDEV application or the WEBDEV site that sends the Push notifications.
This application server sends the notifications via NotifPushSend.
Caution: NotifPushSend must know the identifiers (tokens) of the phones affected by the notification. This information must be returned by the mobile application.
WINDEV Mobile is supplied with:
  • an example used to manage the sending of Push notifications in Android.
  • an example used to manage the sending of Push notifications in iOS.
  • a WINDEV example used to send notifications onto Android or iOS mobile devices.
  • a WINDEV example corresponding to the Webservice used to manage the dialog and the retrieval of identifiers.
Related Examples:
Android Push Cross-platform examples (WINDEV Mobile): Android Push
[ + ] This example explains how to receive Push notifications on Android.

It calls the PushNotifActive function and returns the identifier to the WINDEV "WD Push Server" example that stores it.

Then, this identifier is read by the WINDEV "WD Send Push" example that sends the Push notifications to this Android example.
iOS Push Cross-platform examples (WINDEV Mobile): iOS Push
[ + ] This example explains how to receive Push notifications on iOS.

It calls the PushNotifActive function and returns the identifier to the WINDEV "WD Push Server" example that stores it.

Then, this identifier is read by the WINDEV "WD Sending Push" example that sends the Push notifications to this iOS example.
WD Send Push Cross-platform examples (WINDEV Mobile): WD Send Push
[ + ] This example is used to send push notifications on Android and iOS devices.

It retrieves the identifiers of the mobile devices in the HFSQL database of the "WD Push Server" example then it sends the notifications via NotifPushSend.
WD Push Server Cross-platform examples (WINDEV Mobile): WD Push Server
[ + ] This example is a webservice used to store the identifier required by Push on mobile devices.

The WINDEV Mobile "Android Push" and "iOS Push" applications store their Push identifiers in the database of this example.

Then, these identifiers are read by the "WD Send Push" example in order for notifications to be sent.
Minimum required version
  • Version 19
Comments
Tutorial completo do recurso de PUSH (GCM) com Windev Mobile v.20
Wx - Tutorial completo do recurso de PUSH (GCM) com Windev Mobile v.20 desenvolvido pelo sr Tom Silva e Adriano Boller para a comunidade Wx Brasil.

http://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/1113-tutorial-completo-recurso-push-gcm-com-windev-mobile/read.awp
adrianoboller
Mar. 20 2016