- https://medium.com/codex/complete-guide-on-sending-push-notifications-on-android-using-firebase-82a4c2f7f3a7
- https://medium.com/nybles/sending-push-notifications-by-using-firebase-cloud-messaging-249aa34f4f4c
- https://medium.com/@Codeible/android-notifications-with-firebase-cloud-messaging-914623716dea
- https://dev.to/dallington256/how-to-send-push-notification-to-an-android-device-using-firebase-and-nodejs-3o4i
- https://stackoverflow.com/questions/70979624/delayed-push-notification-on-android-phone/70980691#70980691
- https://www.reddit.com/r/androiddev/comments/988pgq/how_does_whatsapp_still_receives_messages_on_time/?utm_source=share&utm_medium=web2x&context=3
- https://firebase.google.com/docs/cloud-messaging/android/client
- https://firebase.google.com/docs/cloud-messaging/send-message#example-notification-message-with-platform-specific-delivery-options
- https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send
- Follow the "SETUP FIREBASE PROJECT" and "Connecting Firebase With Android" bits at https://medium.com/codex/complete-guide-on-sending-push-notifications-on-android-using-firebase-82a4c2f7f3a7 to create a new Firebase project and link it to your app.
- Install the Firebase SDK into your app (see the build.gradle files included in this gist for reference)
- Create a
MyFirebaseMessagingService
class in your app (see theMyFirebaseMessagingService.java
file included in this gist for an example) - Register the Firebase service (
<service></service>
tag) in your AndroidManifest.xml file (see the example file included in this gist if you want) - Initialize Firebase in your app startup (in the main activity). Also you can optionally subscribe to a topic so you can identify your users' devices and send notifications to them individually if you want later. (See the
MainActivity.java
class included in this gist for an example) - You can now either use the Firebase console to send a test notification, or write your own backend implementation that'll send the proper API requests to Firebase (See the
Backend code.js
file included here for an example in Node.js) - Also optionally if you want, you can customize the
MyFirebaseMessagingService
class to handle the notifications on your own (i.e. if you want to create custom notification channels, etc). See "Displaying the Notification" at https://medium.com/@Codeible/android-notifications-with-firebase-cloud-messaging-914623716dea for an example
-
NOTE: Firebase Cloud Messaging (FCM) is completely free and has no limitations :)
-
one more note: do yourself a favor and don't try to avoid FCM (even if you think its a tad complex). It's hard to send notifications in the background (when your app is closed) without FCM (see https://www.reddit.com/r/androiddev/comments/988pgq/comment/e4eanld/?utm_source=share&utm_medium=web2x&context=3 and https://developer.android.com/training/monitoring-device-state/doze-standby#using_fcm)
-
another note: There's a difference between 'push notifications' and just 'notifications'.
Notifications are a message or alert that is displayed on the device, while push notifications are messages that are sent from a server to the device.
If you want to send local offline notifications even when the app is closed, it's preferred to see all the answers of this Stackoverflow question: https://stackoverflow.com/questions/39674850/send-a-notification-when-the-app-is-closed
- final note: i'm not doing this again :dead: