'Send push notification with ktor

I made a backend with Ktor framework for a android app and my question is:

How to send push notification from server to phone? What tools could I use for this?

I would like to send notifications that everyone will receive and that just given users will receive.

I am not familiar with Ktor, but my goal with this project is to learn.



Solution 1:[1]

Steps:

  • Setup your Android app on Firebase console.
  • Get your Server key from Project Settings -> Cloud Messaging -> Server Key

  • Get the FCM token from the mobile app and store on server database.

  • Trigger the notification on mobile app using the firebase API: https://fcm.googleapis.com/fcm/send

  • Sample for Notification Request: You can use data,notification or both.

    { "registration_ids": ["dfYSqZkGTPevi6gHY65F8J:APA91bF9e6vs2BOjgm8yVj3gdS1R_WHQI50I29uEXw01HDbVA1S67i78cBOXy4FubcfvvGerq36WPOuBggdxBZsF_EE0XHa3YSC6MbEDSvOIlQRypLSDhaOjvIiPawOEt7jGF98DjOik"], "data": { "title": "Hello", "body": "User " }, "notificatoin": { "title": "Hello", "body": "User " } }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Patel Jaimin