HowTo: Configure Push Notifications in iOS Applications

Official Content
This documentation is valid for:

This is a step by step guide to set up push notifications for an iOS Application. If you need general information on how to use push notifications please see Push Notifications in Native Mobile Applications.

Requirements

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 iOS 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 iOS application which uses the Apple Push Notifications Service.

You need to:

  1. Create a SSL Certificate to be able to use the service.
  2. Export it from the Keychain Access in the MAC.
  3. Create an appropriate Provisioning Profile for the application.

Sender configuration

Notifications can be enabled for Native Mobile objects (Menu, WorkWith, Panel) 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 (...). By this way the file will be importing in 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.

Since GeneXus X Evolution 3 this configuration can be done at runtime using the NotificationsConfiguration external object.

Ports

Check if the ports indicated in this document are open: https://support.apple.com/en-is/HT203609

Intermediate Step

From now on, every time you execute a GeneXus application which 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. 

How are notifications sent?

Notifications are sent as shown in this Sample: Notification Provider API

Application execution

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.