Sending Notifications To Your Users Just With Phone ! Using Firebase
For any Android developer, sending notifications or messages is an important thing to notify the user and get his attention, therefore most developers use firebase (cloud service) as a “third part” to get this feature. However, you can’t just send your message or notification with your mobile phone, instead you’re gonna need a computer to get access to the cloud service website,and do your job.
But hold on a minute, what should I do ?
Great question ! here’s your answer : You can use an app that’s gonna help you sending your notifications at any time, without having to use a computer or a laptop, it’s called “Push Notification firebase”.
Download from here Assuming you have the application now, there’s a couple of steps that need to be executed before you start using it
1-subscribe all user in same topic named “any”
make all your users subscribing to topic named “Any”, just like this code below (In JAVA):
SharedPreferences shared_Save = getSharedPreferences("UserData", Context.MODE_PRIVATE);if (!shared_Save.getBoolean("NOTIFICQTION",false)){FirebaseMessaging.getInstance().subscribeToTopic("any").addOnCompleteListener(new OnCompleteListener<Void>() {@Overridepublic void onComplete(@NonNull Task<Void> task) {if (task.isSuccessful()){shared_Save.edit().putBoolean("NOTIFICQTION",true).apply();}}});}
2 add your Server key to app
Add your server key to the “Push Notification” app, you can find the server key of your firebase project by going to
Project settings -> cloud Messaging -> server key
3- One last thing, don’t forget to add MyFirebaseMessagingService class to your project And that’s it ! you’re good to go .