In this guide, learn how to integrate native push notifications in Mendix Native apps using Firebase. Discover how to configure Firebase, set up notifications, and keep users engaged with real-time updates.
Dependencies: -
1)Community Commons
2)Nanoflow Commons
3)Native Mobile Resources
4)Atlas Core
5)Data Widgets
6)Pop-Up Menu Widget
7)Encryption Module
8)Push Notifications Module
install these all modules & Widgets from Mendix marketplace.
1.After installation done Open the app in the MX Studio Pro, Go to navigation
Add new item, in the onClick event select “show a page” & select “Administration” page from Push Notification Module.

2. Go to settings, in the Runtime tab “After Startup” select “AfterStartup_PushNotifications” microflow from Push Notification Module.

Firebase Configuration: -
1.First Login/Sign Up on the Firebase console & create a new project.
https://console.firebase.google.com/

2. Open the newly Created Project, Click the Project Overview cogwheel and select Project settings.

3. Go to the General tab and scroll down & click Add app and select your target platform Android & give the any name in the Your apps section.


Copy this Android Package Name & save it somewhere secure.

Download google-services.json & save it somewhere secure.
4. Go to the Service accounts tab, On this page, press Generate new private key. Store the resulting file in a secure location. You will use this file when configuring FCM in the back-end of your Mendix application.

Configure Push Notifications: —
Go to your MX Studio Pro & Search NativeHomepage_Snippet
and Drag & Drop this snippet inside Home_Native page.

Go to Navigation -> Click the Native mobile (tablet & phone) navigation tab -> Click the Synchronization configuration button & From the Download dropdown menu, select All Objects for DeviceRegistration entity from the PushNotifications module and click OK.

Go to https://passwordsgenerator.net/ this website, generate 32-character key length, In the MX Studio Pro search EncryptionKey & paste this 32-character key here.

How to make an APK using Mendix
https://medium.com/@mohammad.saqib_1262/how-to-make-an-apk-using-mendix-e1ed2c6d27e1
IMPORTANT :-
Here you have to remember somethings
1) You have to publish your application first before making the APK.

2) When you are making an APK you have to keep same package name which you copied from firebase console.


3) Select App Capabilities -> Firebase Configuration -> On Push Notification & Upload google-services.json file which you downloaded from firebase console.

Testing the notifications:-
Now run the application in publish environment & open in the browser.
1.Click on Administration Page on the server, The first time you open this page it will present you with a wizard to set up the Firebase configuration.
2.Check for the Android in this case. If you want, you can do it for Web and iOS too.
3.Go to the Firebase Project, In the General tab, Copy the Project ID & Paste here.
4.Upload the Previously downloaded private key file, your file name will be “ProjectID-firebase-adminsdk-identifier.json”.


5. After successful installing your APK in your physical device -> Open your mendix publish environment app -> Go to Administration page -> Then go to devices tab, You will see your device is registered.

Now test the notification.
Open your mendix publish environment app -> Go to Administration page,
Then go to devices tab, You will see one popup menu if you click on this you will see there will be one button Send Message. Sometimes this pop up menu does not work i am not sure why if this is not working just take another button and call that microflow(IVK open send message form) & publish again.

Now click on that button & send the message what you want.


Conclusion:
I hope this article has helped you understand How To Implement Native Push Notification In Android Application With Firebase
Thanks for reading this! See you in the next blog post.
