The mobile plugin is largely built on top of the open source phonegap-plugin-push plugin. This plugin enables your mobile application to receive push notifications that are visible on the operating system notification center and also receive the notification data inside your OutSystems Mobile app.
The following flowchart explains how the application behaves when a push notification is received, depending on the application state.
The plugin receives the data from FCM service and triggers the OnNotification event on the instance of FCMCentralDispatcher WebBlock if the plugin has been successfully initialized. Additionally, no notification is shown on the notification center of the operating system since it isn’t the expected behaviour on both Android and iOS.
The plugin receives the data from FCM service and checks for the existence of a title or message in the received message payload. If it exists, the message is displayed on the notification center of the OS.
In order to enable push notifications on an OutSystems mobile application, some requirements must be met, specifically:
When targeting the iOS platform, in order to enable push notifications the mobile application has to be signed with push notification capabilities.
Access the Apple Developer Console and create a new App Id. Make sure to check “Push Notifications” under App Services.
Edit the created App Id and, under Push Notifications, create a new Push Notification certificate and save both the private and public certificate. In order to get a .p12 file, access your keychain and export both the public and private key.
You can now configure an application on Firebase. Access the Firebase console and create a new application.
Click on “Add Firebase to your iOS app”.
Insert the same bundle id/ app id created before on the Apple Developer Console and hit “REGISTER APP”
Download “GoogleService-Info.plist” to your machine and you can ignore the following steps.
This file is used to configure the FirebaseCloudMessagePlugin in your application. See detailed information under “FirebaseCloudMessagePlugin Configurations” section.
Under project overview, access the application Settings
Under “CLOUD MESSAGING” tab, scroll down to APNs Authentication Key and upload the APNs certificate generated earlier.
For more detailed information see: https://firebase.google.com/docs/cloud-messaging/ios/certs
Access the Firebase console and create a new project.
Open project settings
And under “Your Apps” hit the “Add Firebase to your Android app” button
FirebaseCloudMessagePlugin should be initialized as early as possible on the application life cycle. The recommended place to execute the plugin initialization process is on “OnApplicationReady” event handler.
Place a InitPushNotifications client action inside “On Application Ready” event handler. This action registers the device with Firebase Cloud Message service and initializes the plugin enabling the reception of push notifications on the device and within the application.
In order to receive push notifications on your application make use of the FCMCentralDispatcher WebBlock.
This block is responsible for dispatching OnNotification events upon push notification reception. For each received notification the following information is available:
Place this block on all pages of your application or on the layout, hook the OnNotification event and you’re all set.
Once the plugin successfully initializes, it is possible for the device to subscribe topics or to be associated with a user.
Topics allow an easy way of grouping many devices and to broadcast messages to that group.
The following client actions are present to deal with topics:
By default, a devices is registered anonymously but it is possible to associate one or more devices with one user.
The following client actions are available to deal with device registration with a user:
In order for your OutSystems Mobile application to register with FCM, these files must provided.
Note: Only use the file for the supported platforms or, if supporting both Android and iOS, use both google-service.json and GoogleService-Info.plist files.
On your mobile application, Import google-service.json and/or GoogleService-Info.plist files and make sure to:
Android platform supports custom icons for notifications presented on the system notification center/ system tray.
In order to add a custom icon to your application follow those steps:
Server side application responsible for managing device registrations with users and to provide a way to push notifications to devices.
Available server actions to send notifications:
Android offers additional features such as support for rich notifications and notification stacking.
In order to leverage those features, a specific set of payloads must be used when pushing notifications to the devices.
By default, every time a notification is received on Android devices, the notification present on the notification tray will be replaced with the most recent notification. To have one different notifications on the notification tray make sure to provide a notification id when sending a notification. When sending a notification, provide a custom data entry with the key “notId” and an integer value that identifies the notification.
Inbox style stacking allows to mimic the inbox style present on many messaging and email applications. To use it, add two custom data items:
By default, notifications show the application icon as the notification image. By sending a custom data item with the key “image” and value set to a valid URL of an online image, the image will be shown instead of the application icon.
It is also possible to present the image in a circular fashion. For that, provide a custom data item with key “image-type” and value “circle”.
Hi there,
In a multi-environment scenario (dev, qa, prod) our application identifier is different for each environment (e.g. com.envdev.app, com.envqa.app, com envprod.app).
How do you handle the deployment of the application and the need to have different configuration files (google-service.json and GoogleService-Info.plist) that depend on the application identifier?
Is there a way to set this file that doesn't involve manually replacing these files for each environment?
Thank you in advance
David Sousa wrote:
Hi David, unfortunately there's no other way, that I am aware of, to deal with this problem other than replacing those files on each environment.
Regards,
João Gonçalves
Please tell me what is application id and options.
mohd hasib ApplicationId, as the parameter documentation states, should be a unique string that identifies uniquely your application in the context of the environment.
This relates with Firebase Cloud Message Middleware and allows it to manage registered devices capable of receiving push notifications.
It also allows you to send push notifications to those devices that have been registered with that specific ApplicationId! Take a look at both SendNotificationToUser and SendNotificationsToUsers server actions on Firebase Could Message Middleware to see where this ApplicationId comes into play.
As for the Options, you should create a variable of type PushOptions, this is a Structure that you can find on FirebaseCouldMessagePlugin. This structure allows you to configure various behaviours of the plugin.
Cheers!
João Gonçalves wrote:
Now when i am generating the android apk it is showing me the following error:
In order for your OutSystems Mobile application to register with FCM, these files must be provided.
To do that you need to create a ZIP file with FCM files (Google-service.json and/or GoogleService-Info.plist) and make sure you name it "google-services.zip". On your mobile application, import google-services.zip file and make sure to:
Set “Deploy Action” to “Deploy to Target Directory”
Set the “Target Directory” to “google-services”. This is very important!
I am trying to use the firebase message plugin for demo application and I followed all the steps mentioned above. But I keep getting this message "Plugin is not loaded". I doubt that I am not using the correct ApplicationId . Can someone please let me know exactly what needs to be used. I tried using the server key, AppId mentioned on the firebase console as the input parameter for ApplicationId. But I guess I am in wrong direction
Mithilesh Dhupia wrote:
Dear Mithilesh,
Application ID is the Server key from firebase console. Where you are testing this application in a real device or in emulator?
It will not work on emulators.
mohd hasib wrote:
I am testing it on real device only. I tried using the server key but it keeps saying 'Plugin not loaded' on the splash screen
HI Mohd Hasib,
Thanks for your reply. Its working now. I followed this link https://www.outsystems.com/forums/discussion/29597/plugin-is-not-loaded/ as well and combining your answer I got it working.
Experts wrote:
Does it support deep linking on Android and iOS platforms?
Shreyas Bhondve wrote:
Also, does it support tagging feature for both Android and iOS platforms?
Hi Folks,
I am also implementing the sample for the same.perhaps @Shreyas please avoid hitting the "Reply" button as the topic is getting very big to read.
@Mohammad Hasib & @Mithilesh Dhupia Just to Correct with the application-Id. It is not the Server-key but the App-Identifier that we declare on Firebase & pass the same here i.e a Kind of Package-Name.
Well coming to my question - @Experts
# Will I receive the notification, even if the app is not open nor in background i.e closed completely.
Thanks in advance
Assif
assif_tiger wrote:
Ignore: & pass the same here i.e a Kind of Package-Name.
Hi,
I can register the device and can receive pushs but when I add the FCMCentralDispatcher my app crash and shows the message "There was an error processing your request."
In Service Center I have tihis error:
[ErrorScreen] Script error for "FirebaseCloudMessagePluginContext"
https://requirejs.org/docs/errors.html#scripterror
And in the console no error appears.
Any can help?
Hi Everyone.
I have configured everything as required.
Android works but not ios.
I get token but when I try to send test notification through firebase console it doesn't send.
Can anybody advice what should I do ?
I'm using the latest version of plugin.
It was working before when plugin was not the newest one.
regards
Anahit.
Anahit Pahlevanyan wrote:
- Check the Firebase Cloud Messaging APNs authentication key or APNs certificate to connect with APNs
- Check TeamID & BundleID configured correctly as per you Outsystem App Identifier
I am using the new version as well with MABS 5.0 probably the latest one & it is working.
Hi Assif
I've rechecked everything.
The team Id is correct and I'm using Cloud Messaging APNs authentication key.
On mobile also I put certificate and provisioning profile, the app is running on mobile device and it returns me the firebase id.
but when I try to send message firebase gives me invalid registrationid :(
Can anybody help
Anahit
Hi Everyone
I've rechecked everything
With the build from outsystems
Notification works on ios 12.4 , But 13.1.1 not working
I even created native xcode application and put same certificates there, and the xcode app worked with 13.1.1 os version.
can anyone help ?
Hi Anahit,
Did you solved notifications receiving issue in ios devices., Please let me know how you have solve this issue in ios.I am also not receiving notifications in ios ,only receiving in android devices.
thanks
Harish