How to send push notifications to a mobile phone
Sending push notifications to mobile phones is only supported for native mobile applications. If you want to send push notifications to mobile phones in your native mobile applications there are several major steps involved. Most of them need only to be done once.
- Setup Apple and Google pre-requisites (for iOS and Android phones) – this should only be done once.
- Enter these pre-requisites into Aware IM (also done once only)
- Configure push notification rules in Aware IM to receive or send push notifications
Step 1
To enable mobile push notifications, you need to set up Google's Firebase Cloud Messaging (FCM) service.
- Go to Firebase Developers Console (https://console.firebase.google.com/) and create a project.
- Add an Android application for this project (when creating a zip file for the native application make sure that the package name corresponds to the package name of the Android application).
- Go to the “Settings” area of the application and in the General tab download the
google-services.json
file. - Record the project id on the same screen
- Go to the Cloud Messaging tab and generate a private key for the application. Save this key in a secure location on your machine.
- Enter the location of the
google-services.json
file, the downloaded file with the private key and the project id in the fields below. - Add an iOS application to the project. Make sure that the bundle ID of the application matches the package name of the Android application
- Enroll into the Apple Development program (if not enrolled already) and log into the Apple Developer Portal. Go to the Certificates and Identifiers page. Create a key for push notifications (make sure Push Notifications is selected when creating the key).
- Download the key and keep it in a safe location
- Import this key into the iOS application in Firebase (in the Cloud Messaging tab). When importing the key specify the ID of the key that you can find on the Certificates page in Apple Developer and the Apple team ID that you can see in the top right corner of the Certificates page.
- In the Firebase console under the
General
tab exportGoogleService-info.plist
.
Step 2. Enter iOS and Android pre-requisites in Aware IM
In the Configuration Tool, double click on the Business Space Version you want to change and click on Push Notifications
property in the list of version properties. A dialog will popup. In the FCM Settings section of the dialog enter the location of the google-services.json
file, the location of the GoogleService-info.plist
file, path to the private key file and Project ID. Once you click OK Aware IM will automatically add two predefined business objects (MobilePhone
and CMTopic
) and one predefined notification MobilePushNotification
to your business space version.
Step 3. Configure push notification rules in your application
1. Subscribe to a topic to receive a push notification
If you want to subscribe to a topic you need to setup management of the predefined CMTopic
object that represents subscription topics. An administrator may need to create a few instances of this object before the user can subscribe to them. Then you need to create a process that would subscribe to a particular topic. The instance of the appropriate CMTopic
object must be in the Context of the process. The process can subscribe to the topic by using the MOBILE SUBSCRIBE TO
action. For example,
FIND CMTopic WHERE CMTopic.Name='Fashion' MOBILE SUBSCRIBE TO CMTopic
This process should be activated on a mobile phone of the user. When the user logs into the mobile native application that has push notifications enabled for the first time, an instance of the MobilePhone
object is created. It is that instance that is subscribed to the topic. Once the phone is subscribed it will receive a notification about the topic. This notification will also be sent to the Aware IM application running on the server as a predefined notification called MobilePushNotification
. The instance of this notification will have the ID of the phone. A developer may set up rules attached to this notification.
2. Send a notification to a phone
In order to send a notification to a phone you need to define a process that will use the MOBILE PUSH action
. For example,
CREATE MobilePushNotification WITH MobilePushNotification.Body='Some message',MobilePushNotification.Title='Attention' MOBILE PUSH MobilePushNotification TO MobilePhone
where MobilePhone is process input