Warning: As Apple deprecated (November, 2020) and removed (March 31, 2021) the legacy binary protocol of the Push Notification Service, Notification Provider is the only method available to integrate Push Notifications in a GeneXus-generated Apple application.
This is a step by step guide to set up push notifications for an Apple Application. If you need general information on how to use push notifications please see Push Notifications in Native Mobile Applications.
Push Notifications in GeneXus applications are only available in compiled applications. This means that in the Mobile generator preferences, you have to set the Execution Type property (in the Apple Specific group) with a value different from "Knowledge Base Navigator (Device)" and insert the connection information of the MAC OS computer where the application will be built.
Also, some actions are required when developing an Apple application that uses the Apple Push Notifications Service.
You need to:
- Createa SSL Certificate to be able to use the service.
- Export it from the Keychain Access in the MAC.
- Create an appropriate Provisioning Profile for the application.
Notifications can be enabled for Menu, Panel and Work With objects with the Main program property set to True. This can be done by setting the Enable Notifications property to True, in the Main object properties group. When doing this, a new group of properties is available called Notifications with the following properties:
In these properties, you have to indicate the file name and password of the SSL Certificate that was previously generated and exported in order to work with the Apple Push Notifications Service. This file has to be located in the private directory under the Web directory of the environment folder.
The best way to do this is by selecting the p12 file from the property's file selector (...). In this way, the file will be imported into the Knowledge Base and will automatically deploy to the private directory in the next build process.
If a Notification Provider is used, there is no need to set these two properties.
Apple Push Notification Service has two different working environments, which require a different SSL Certificate for each of them, Sandbox environment (or development, using for testing purposes) and Production environment (or distribution). In this property, you have to indicate which environment we are going to work with in the Apple Push Notifications Service.
If a Notification Provider is used, there is no need to set this property either.
Finally, you need to consider the iOS Bundle Identifier property value, which is very important here. The default value will be com.artech.<MainObjectName>, but you need to change it (if necessary) for the Bundle Identifier configured in the App ID associated with the SSL Certificate used.
Check if the ports indicated in this document are open: https://support.apple.com/en-is/HT203609
From now on, every time you execute a GeneXus application that has Push Notifications enabled in a Mobile Device, the Devices Registration Service is executed in order to register and store the device information to be used in the future to send messages (Push Notifications) to the device.
Notifications are sent as shown in this Sample: Notification Provider API
Like any iOS applications which use the Apple Push Notifications Service, the first time you execute the GeneXus-generated iOS application, a message is shown asking if you want to enable the notifications. Regardless of the option that you select in this message, the application notifications will be available to be configured later in the iOS Notifications Center.
Note: Notifications don't work if the client application does not give permission.