Kalipso TechDocs Push Notifications - Sysdev Kalipso · Title: Microsoft Word -...
Transcript of Kalipso TechDocs Push Notifications - Sysdev Kalipso · Title: Microsoft Word -...
TECHNICAL NOTE
HOW TO USE PUSH NOTIFICATIONS
Document: Kalipso_TechDocs_Push_Notifications
Revision: 1.0
Kalipso version: 4.0.0 141117
Date: 19.02.2018
Author: RS
Kalipso documentation How to Use Push Notifications 2
Contents
Contents ................................................................................................................................................ 2
1. About ............................................................................................................................................. 3
1.1. How Push Notifications Work .............................................................................................. 3
1.2. Advantages ........................................................................................................................... 3
2. Application Examples .................................................................................................................... 4
3. Requirements to use Push Notifications ....................................................................................... 5
3.1. Android ................................................................................................................................. 5
3.2. Windows 10 .......................................................................................................................... 7
4. Push Notifications in Kalipso ......................................................................................................... 8
4.1. Push Notification Get Client ID ............................................................................................. 8
4.2. Push Notification Message Received ................................................................................... 9
4.3. Push Notification Get Message .......................................................................................... 10
4.4. Push Notification Get Lost Message ID List ........................................................................ 10
4.5. Push Notification Get Lost Message .................................................................................. 10
4.6. Push Notification Delete Lost Message .............................................................................. 10
5. Tutorial Demo Apps ..................................................................................................................... 11
Kalipso documentation How to Use Push Notifications 3
1. About
Push Notifications are messages that are sent directly to the user’s mobile device.
App Publishers can send them at any time and the message will pop up even if the device is locked or if the user is in another app.
They can be used to provide a richer experience to the application users, like sharing updated information or events.
Applications don’t have control over sending push notifications to the user as they are managed by push notification services like (Firebase Cloud Messaging).
These services uniquely identify devices with an identification token and not logged in users of the apps.
They then send this token to its own service which will be used to send messages to the device in a specified format.
1.1. How Push Notifications Work
Its behavior is like receiving phone calls or text messages.
The application connects to a notification server and asks to be informed and the answer then comes "delayed" when information is available.
1.2. Advantages
Doesn’t require specific applications on a mobile device to be open for a message to be received
Provide a way for the users to revisit the app.
Instant access to personalized and relevant info.
Broadcast to all users, or independently select just a sub-set of users to send the information.
Kalipso documentation How to Use Push Notifications 4
2. Application Examples
Transactional notifications
User feedback gathering
Sales and promotions
Price drop alerts (Send alerts to users who are watching out for price fluctuations on specific products or holiday destinations)
Notify customers when relevant new products are available on the app
New coupons
Remind customers about pending products in their shopping carts
“Product back in stock” messages
Share information about loyalty points accumulated and they could be used by the user
Complementary Communication Channel (Flight check in, change, and connection information)
Utility messages like traffic, weather and ski snow reports
Kalipso documentation How to Use Push Notifications 5
3. Requirements to use Push Notifications
In order to use Push Notifications, certain requirements need to be fulfilled.
3.1. Android
Google Play services need to be installed in your android device.
A Firebase Console account, which can be created at: https://console.firebase.google.com/
Kalipso documentation How to Use Push Notifications 6
A Firebase Project, created in the Firebase Console. This is where you download the google-services.json file used in the project push notifications settings.
Also, the server key and Sender ID are needed when sending a push notification to the devices.
Kalipso documentation How to Use Push Notifications 7
These values are loaded to the Android Sender ID and Android Google App ID fields. Located in the Project Properties.
3.2. Windows 10
Before you can send notifications using Windows Push Notification Services (WNS), your app must be registered with the Store Dashboard. This will provide you with credentials for your app that your cloud service will use in authenticating with WNS. These credentials consist of a Package Security Identifier (SID) and a secret key. To perform this registration, go to the Windows Dev Center and select Dashboard.
Each app has its own set of credentials for its cloud service. These credentials cannot be used to send notifications to any other app.
For more details on how to register your app, please see How to authenticate with the Windows Notification Service (WNS).
Kalipso documentation How to Use Push Notifications 8
4. Push Notifications in Kalipso
Kalipso supports Push Notifications in Android and Windows 10 (UWP).
To use Push Notifications in Kalipso, they need to be enabled in the Project.
Optionally messages can be saved when the application is not active.
Kalipso provides several Actions to handle Push Notifications.
It also provides an Event that is triggered when a Push Notification is received, allowing to perform actions based on that.
4.1. Push Notification Get Client ID
When the application starts, a unique ID token is generated. This token is used to directly target a single device, or device groups.
Since this ID Token can change after the first startup, it is recommenced to keep track of any changes that might occur.
http://docs.sysdevmobile.com/kalipso40/push_notification_get_client_id.htm
Kalipso documentation How to Use Push Notifications 9
4.2. Push Notification Message Received
This event is triggered when the device receives a Push Notification and the application is currently active in the screen.
http://docs.sysdevmobile.com/kalipso40/push_notification_received.htm
In Kalipso, a Push Notification can be one of Three types:
Notification Message
Data Message
Notification with Data
A Notification Message only has the content to be displayed in the System Bar
A Data Message only contains information that will be passed directly to the Application, and no notification icon or sound will appear in the System Bar, despite if the application is or not Active.
A Notification with Data is a message that has both the Notification that will appear in the System Bar, and Data that can be passed to the Application. This type is only useful to send data when the Application is active. If the application is in the background or closed, the Notification is received, but the data part is lost and cannot be retrieved by the application.
Kalipso documentation How to Use Push Notifications 10
4.3. Push Notification Get Message
When the message is received and the application is running in the foreground, the event is triggered, this Action can be used to retrieve any data contained in the Notification Message.
http://docs.sysdevmobile.com/kalipso40/push_notification_get_message.htm
When the application is not active, if the option to save messages is enabled in the Project Properties, Data messages will be kept in the device until they are retrieved.
4.4. Push Notification Get Lost Message ID List
http://docs.sysdevmobile.com/kalipso40/push_notification_get_lost_message_id_list.htm
4.5. Push Notification Get Lost Message
http://docs.sysdevmobile.com/kalipso40/push_notification_get_lost_message.htm
4.6. Push Notification Delete Lost Message
http://docs.sysdevmobile.com/kalipso40/push_notification_delete_lost_message.htm
Kalipso documentation How to Use Push Notifications 11
5. Tutorial Demo Apps
This is a simple Demo app to show how to enable any Kalipso application to receive Push Notifications.
1. With Kalipso open, create a New Project.
Kalipso documentation How to Use Push Notifications 12
2. In the advanced Tab check the Enable Push Notifications and click on Load from google-services.json.
Here, we select the previously downloaded file
Kalipso documentation How to Use Push Notifications 13
3. Create a new Form.
4. Configure the Left Arrow as an exit Button.
Kalipso documentation How to Use Push Notifications 14
5. Rename the Title Label.
6. Add a Text Input.
Kalipso documentation How to Use Push Notifications 15
7. Add a Label with text “Client ID”.
Now we need to get the Client ID for sending push messages to the application.
8. For convenience it will be displayed in the Input Box. In the Open Form Event add the action Push Notification Get Client ID.
Kalipso documentation How to Use Push Notifications 16
9. Next, we are going to add the Push Message Received Event, so that whenever a message is received and the application is active, the event is triggered and we can perform some actions.
10. In that event, we use the Push Notification Get Message action to retrieve the data from the notification.
We can retrieve any configured tag from a message. In this case we will be sending a message containing a “title” and “message” tags.
Android:
Kalipso documentation How to Use Push Notifications 17
In windows 10, we always retrieve the entire message content along with the notification type.
Windows 10:
11. Next, to display the received data we use a Message Box.
12. Test the application clicking Test on Device -> Android.
Kalipso documentation How to Use Push Notifications 18
The application will open presenting its Client ID.
To test if the notifications are working properly, Kalipso designer can be used to send Push Notifications to a Device.
Kalipso documentation How to Use Push Notifications 19
13. Click Send Request.
14. Click on the device’s platform to be tested.
Kalipso documentation How to Use Push Notifications 20
15. Fill with the information, like title and body, and also the Client ID in order to send the notification to the device.
16. Add the parameters title and message and click Next.
17. Click Next Again and Send:
Kalipso documentation How to Use Push Notifications 21
If the application is running, the Push Message Received event is triggered and the message box is displayed:
Also, the sent Push Notification is placed in the notifications panel.
Kalipso documentation How to Use Push Notifications 22
Notifications can also be received when the application is closed.
In order to process the lost messages, we need to know if any message was received.
18. In the Open Form event add the action Push Notification Get Lost Message ID List.
19. Next, we verify if there are any items.
Kalipso documentation How to Use Push Notifications 23
If there are, we need to iterate through all the items and display them.
20. Add the For Each action and select the option Browse the tokens of a String.
21. Click Next and define the parameters to use the IdList generated by the action Push Notification Get Lost Message Id List and click save.
Kalipso documentation How to Use Push Notifications 24
22. Inside the For Each add the Push Notification Get Lost Message action, defining the targets for the data retrieved in the required platforms. Windows 10
Android
Kalipso documentation How to Use Push Notifications 25
To display the retrieved data, add a Message Box
23. After the message is processed and displayed, delete the message with the Push Notification Delete Lost Message action.
To test, we now close the application and, in the Designer, we send a Data only message,
24. From the Project Properties, click Send Request.
Kalipso documentation How to Use Push Notifications 26
25. From the previous message, remove any text from Title and Body and click Next
Kalipso documentation How to Use Push Notifications 27
26. Click Send.
Now we need to send a Notification Message to signal that a Data Message was received while the application was closed.
27. In the notification sender from the Designer, send a message with the Title and Body
properly filled and click Next.
Kalipso documentation How to Use Push Notifications 28
28. Click Send,
If we check the Notifications panel on the device, a new notification will appear.
Kalipso documentation How to Use Push Notifications 29
29. Click on the received notification to open the application. When the application opens, it will start to display the received notifications.
After proper testing, to allow sending notifications from other sources like another Kalipso project, an application package needs to be generated (APK, APPX).
In the Deploy menu, click Create APK.
Kalipso documentation How to Use Push Notifications 30
30. Install the apk to obtain the new client ID.
Now you can use the sample application available to send Push Notifications.