Description
Smartphones today Nowadays smartphones are increasingly considered more and more a key part in of any digital solutionssolution. Increased Their increased computing capabilities and faster internet connections allow for capacities and the higher speed of Internet connections, allow a new horizon of connected appsapplications. Some IoT applications today use smartphones as gateways, but it is also normal to use the smartphone as a notification and awareness tool in some cases where promptness speed is key.
That is why we have developed a new node for the onesait Platform Flow Engine: onesaitplatform-firebase-notification. This node features has integration with Firebase. Firebase is a Google platform from Google that helps developers dealing with manage the backend of their mobile apps backend. Some of the features of the platform features are open to everybody everyone and that is the case for the Cloud Messaging featureof the cloud messaging function.
...
This post showcases article shows an example of native notifications to for Android apps applications using the onesait Platform's Flow Engine. The guide will highlight the process needed required to perform carry out the example using the onesait Platform modules, whereas while the Firebase-specific task will only be just mentioned but and not explained in detail, please . Please contact us for extra info additional information on how to integrate your mobile app within the Firebase platform.
For this example, we have built a custom Android application (app) with a basic layout design and functionality:
...
This app has native integration with Firebase, allowing which allows it to be connected to Firebase and receive native notifications (to know learn more about the integration with Firebase integration , follow this this link).
The app behavior looks like thisbehavior of the application is the following:
First,
...
after the app
...
is installed, the app connects
...
to Firebase and is
...
given a Device Token. This token is unique
...
to the Android device
...
, although it
...
can be updated
...
later. It is advisable to monitor these changes using the callback
...
inside the onNewToken method of your class, which
...
extends FirebaseMessagingService.
...
Every time a new token is granted, or when the user clicks
...
the REGISTER DEVICE TOKEN button, the granted token is
...
sent to the onesait Platform. These token keys are stored in the NativeNotifKeys ontology, which looks like this (
...
For this example, the app will be messaging, and the user will be the IMEI code
...
of the host smartphone):
...
To perform step 2, the NativeNotifKeys ontology
...
must be created (they already
...
exist in the demo environment), and an API endpoint
...
will be created in the environment. This API will publish this ontology
...
via a URL, with INSERT capabilities. For this example this is
...
what the API definition looks like:
...
Now the app, which already has a valid Firebase token
...
, has replicated this
...
information to the onesait Platform, allowing developers to
...
take advantage of this data and send notifications to these devices. But we
...
have yet to enable a way to
...
push messages
...
through the onesait Platform to
...
end devices. That is why we define this ontology, to record
...
incoming messages:
...
After the creation of the ontology
...
, we
...
have to define the rule to send the messages inserted in the notificationMessage ontology to the end devices. We will use the onesait Platform Flow Engine module to perform this operation:
...
The first block
...
only inserts notification
...
message in the platform.
...
The second block then uses a onesaitplatform-notification-endpoint node to subscribe to the
...
above inserts in the notificationMessage ontology. This node will insert the message
...
in the onesaitplatform-firebase-notification node, which
...
handles the Firebase integration for the demo app.
With the flow set up, and before we start sending notifications,
...
we will next explore two different types of messages that we have integrated
...
into the example:
Notification to a single, specific device.
Notification to all devices subscribed to a
...
specific theme (or topic).
To change this behavior, there is a topic field
...
within the notificationMessage ontology. If it is blank ("topic":""), then the firebase-notification node will send this notification to the device corresponding to the user field
...
within the message, using the current Firebase token updated by the app via the NativeNotifKeys API
...
.
...
These are the message, the output of the Flow Engine
...
and how the notification appears on the mobile phone:
...
The notification appears promptly quickly with the title and body that we defined define in the ontology instance of the ontology. Firebase claims that over 95% of the notifications they send are delivered within an interval of 250msa 250-milisecond interval.
The last step will be to send notifications to a group of devices subscribed to a certain topic. To do so first, theme. For that, first you have to go to the app and click on press the SUBSCRIBE TO NEWS button:
...
And then change the topic to news inside the Flow Engine insertionstream engine embed:
...
For topictest the theme-based notifications testing, it is better best to install the example sample app into on more than one phone so you can see the difference. From one phone, the result of this will be the arrival of the notification:
...
The time - diagram to understand the full complete flow of actions is this:
...
Now test try it yourself and let us know how it went!
If you have any question questions or requirement requests, please contact us at support@onesaitplatform.com