'How to show push notifications in to do app KOTLIN?
I am creating to-do app project in Android Studio, language is Kotlin. I have created Email/Google signIn, signOut and create/read/update/delete task functions. Each created task object has selected by user datetime, and tasks for each account are storing in Firebase Realtime Database. After realising those functions I started to integrate notifications to my app, and there was a problem. How can I do that? Should I use Firebase Cloud Messaging or do notifications locally. I tried to use FCM but, thing that I couldn't understand and I couldn't find any information for this topic is how to schedule notification to selected by user date and send it to device? Can anybody help pls. This is my first kotlin project, and I am new at android development
Solution 1:[1]
I recommend you to watch this video https://www.youtube.com/watch?v=B5dgmvbrHgs&t=674s&ab_channel=CodePalace
If you can't, I will send you my own code, but it will be difficult for you to change it according to yourself, I made it with this video.
I also did it with a data from the firebase database, but I could not use FCM. I do not recommend
Solution 2:[2]
This should help you, Firebase Notification Scheduler
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\r\n \"payload\": {\r\n \"to\": \"<Device FCM token>\",\r\n \"notification\": {\r\n \"title\": \"Check this Mobile (title)\",\r\n \"body\": \"Rich Notification testing (body)\",\r\n \"mutable_content\": true,\r\n \"sound\": \"Tri-tone\"\r\n }\r\n },\r\n \"sendAt\": \"2022-08-29T09:12:33.001Z\"\r\n}")
val request = Request.Builder()
.url("https://firebase-notification-scheduler.p.rapidapi.com/messages")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("Authorization", "undefined")
.addHeader("X-RapidAPI-Host", "firebase-notification-scheduler.p.rapidapi.com")
.addHeader("X-RapidAPI-Key", "SIGN-UP-FOR-KEY")
.build()
val response = client.newCall(request).execute()
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 | Ă–mer Seyfettin Yavuzyi?it |
| Solution 2 | VoteCoffee |
