I've created two different android applications, one for the admin panel which has only one user itself, and the other one which will be installed on other android devices. As the admin adds notifications in his application, all users will get the notifications. what should I do? How to implement this?
How to send notification from one android application to other android application?
1.1k Views Asked by Abhishek VD At
2
There are 2 best solutions below
1
On
Use firebase FCM for sending the push notifications to android devices. Here you will find lot of options. https://firebase.google.com/docs/cloud-messaging
You sound a beginner so I will explain in simple words first.
PHPas your server side language then you can use my code below.PHPscript on server that can trigger notification. I assume you already know how to call aPHPscript, It's same as calling the normalAPIto do operations inDatabase.Having known the process flow you need to follow below steps.
Follow this tutorial to start a
Firebaseproject and acquireFCM Notificationfunctionality. Get firebase api key from the console.In your User application subscribe to a topic using the code below. Put this code in the
onCreatemethod of theActivityafter user logs into app. Unsubscribe the topic if you want user to stop receiving notifications.Put this code in a
PHPfile, you need to call this to trigger notification.Now call this
PHPscript from your Admin application. You can pass parameters according to your needs. You will be able to get a notification in your User app.You can customize the notification in your
Androidcode, like playing a specific sound. For that you need to follow the official document guide I linked above.