Best way to trigger notification in flutter - flutter

My flutter app allows users to schedule events and needs to notify them when the time comes. These events involve multiple users and may be deleted. I am looking for the best way to trigger the notifications.
So far, I have found 2 packages that may be able to achieve this: firebase_messaging and flutter_local_notifications.
With firebase_messaging, I thought of creating a cloud function that would be triggered when an event was created in firestore, which schedules another cloud function to be run during the event, checking whether the event still exists in firestore, and triggering notifications accordingly. However, I am unsure of whether it is possible to schedule a cloud function from within another.
With flutter_local_notifications, my issue is that user B may create events involving user A or the event may be deleted whilst user A's app remains terminated. As such, the scheduled notifications for user A have no way of being adjusted accordingly.
What do you think is the best approach?

If you need to involve multiple people , flutter local notifications isnt for you. It is not build for that.

Related

Determine source of Database Event in Firebase RealTime Database and Flutter

I have a Flutter app using Firebase Realtime database. I have created subscriptions to add, change, and delete for a node.
I would like to determine if the DatabaseEvent received for these subscriptions was generated by the local application, or by something else (for example, a direct edit using the Firebase Console.)
I know I could probably store some information when I issue the database add, change or delete, and then when I receive the event compare to see if the same item referenced, but I was hoping to see if there was some information in the Event itself (or somewhere else) that would tell me this.
Anyone have an idea?
I have examined the DatabaseEvent object returned when the subscriptions fire, but I don't see any information that could help.
firebaser here
There is nothing built in for this in the Firebase Realtime Database SDK or in any of its other APIs. If you want to know the source of the data, you'll have to track it yourself.
One of our early demo apps for a shared whiteboard held a list of the push keys for all its pending writes, so that it could filter those in its listener (as it had already drawn the local strokes before even sending them to the database). But there are many other valid approaches for this too.

How to send push notification when data changes from API

I'm currently creating an iOS application in Swift that fetches data from a third party API and then displaying it on the screen.
One of the features includes enabling push notification so that the user gets a push notification if there's a change in the API data.
However, I'm struggling to figure out how to implement the push notification side of it so that I can constantly monitor the API data and then send out a push notification when there's a change in the data.
Can someone point me in the right direction on how to do this? I've previously used Firebase to implement push notifications but the push was triggered from a user action. I was wondering whether there's something similar I can utilise in Firebase or if there's any other recommendations?
Thank you!
You may be able to use cloud functions. If you're monitoring the data client side you can perhaps make a call to a cloud function to send a push notification.
Or you may want to look into local notifications. I'm not sure exactly what you're trying to accomplish so it's tough to really say, but as far as a direction goes I would recommend checking out cloud functions and local notifications to see if either one solves your needs.
Edit:
Now that I know more what you're looking for I would check out this article here. It will explain about Background App Refresh. Here's an excerpt from the article.
When the system calls your app delegate’s application(_:performFetchWithCompletionHandler:) method, configure a URLSession object to download any new data. The system waits until network and power conditions are good, so you should be able to retrieve adequate amounts of data quickly. When you finish updating your app, call the completion handler and provide an accurate result of your outcome, which can include saying that no new data was available.
So in the application(_:performFetchWithCompletionHandler:) method you would want to:
Download the new data
Compare it to old data and see if there's been a change
And then probably I would just display a Local Notification to the user.
I think that would be the easiest way with your current architecture and without having to write any server side code.

Firebase notifications Swift

Yes I know that this has been asked on StackOverflow before but I just can't find exactly what I am looking for. So what I would like is when a user (user1) send a message to another user (user2) , for user2 to get a notification saying they have a new message from user1. So far I have set my app up so that I can send a push notification from the Firebase Console, but not so that the app does it automatically. I think I need an observe function but I am not quite sure what to do or the code for it?
Thank you so much for all the help! This is my first time with Firebase.
You can just use Cloud Functions.
It simply triggers a Function when an Event occurs.
For example whenever a new message added to a node you can run a function that sends a Notification to the user
Check the Documentation
Also check this sample which matches what you need
I have asked same question some time ago. The thing that was bothering me was why should I use Cloud Functions and write and deploy functions for it in javascript if I just wanted to send Notifications just between two users?
So I checked out other options and setup everything in just about few minutes without writing any javascript functions in the Firebase Cloud Functions.
Well it depends on what you will exactly need but in my case using Cloud Functions just to handle that was nonsense. If you are in the same situation as I was you can use OneSignal like I did. There is also my question on this and you can check it out here.
you can try this it can worked for me sending notification through fire base cloud
https://github.com/firebase/quickstart-ios
https://github.com/firebase/quickstart-ios/issues/286#issuecomment-304992090

Creating event reminders

I am working on an ionic project. It is based on medication managing.And I want to remind the user about their medications. I am new to this and can some one give me a sample code, link or something to create reminders.
I would recommend taking a look at Local Notifications, they are notifications that can be scheduled on the device without the need for a server. It is commonly used for things like reminders. You can also choose to do this using a server with Push Notifications, but that doesn't seem necessary in your situation.
For starters, take a look at the documentation for Local Notifications, see if it works for your use case.

Prevent google calendar from creating duplicate entries when a remote icalendar file changes

There's a lot of events happening all the time on my university campus, and, together with a few other students, we thought it would be nice to provide the event schedule as a calendar. So organisers register their event on the intranet, and it gets added to an icalendar file which people on the campus can subscribe to.
This works great when people load the calendar url on their iPhones, but it doesn't when loading in Google Calendar. We have noticed two problems:
When you subscribe to the calendar and then log out and back in, events are no longer visible. Sometimes, clicking refresh fixes it. The vents do not disappear from android devices associated with your account.
When an event is removed from the icalendar file (eg. if it's cancelled), it still remains on the android devices that sync with any google account that subscribed to the calendar. New events sync fine, though, so it's not that the sync didn't happen.
Do you know how I can solve these two problems? I've noticed the STATUS:CANCELLED property in VEVENTs, but it doesn't seem to work when the calendar method is PUBLISH.
Thanks!
PS: If you can suggest a way to test changes faster that waiting for Google to pull the changes from the server, it would be great; right now, I have to wait about 6 hours between each test...
my understanding is that removing it from the file is not the way to cancel an event. One must ensure that there is a UNIQUE identifier to match any changes.
Also must follow the spec for cancelling/changing an event.
See How to cancel an calendar event using ics files?
If all of that is correct, then the various applications that 'subscribe' to a calendar should in theory update the event status when they read the updated file. Unfortunately the speed and frequency of that is up to that application. (NB: note also difference between subscribe and "import")
Yes I have noticed that google is slow to update sometimes. Only thing I can think of is use another application where you have control perhaps over the subscription update frequency to test if the way that you are cancelling an event is working. Once you see the cancellations happening there, then resume testing on google (I have noticed Google is more pedantic than some apps, so you may still have to work to get it 100% working on google.)
Hope that helps!
I've tried the suggestions but Google Calendar only ever adds another event. The iCalendar validators say that the files I generate are valid, and iCal on the Mac removes an event if it has cancel information. But neither Google Calendar or Outlook do. Rather frustrating.