Flutter best way to store App Notifications? - flutter

Is there a way to store app notifications in a flutter app. Most of the time this app will be closed and the app notifications will not directly be hitting the app. I would like to store app notifications in a notifications received section. I know I can get the notifications if the app is opened, but for if the app is closed and it just shows as a status, I can't get them in the device unless the user clicks on the notification message. and it opens the app. What options do I have and is what I am wanting to do even possible?

First interpretation of your question: If I read your question correctly, you're saying its not possible to have text in your notifications when the app is not open. This is definitely possible, almost all your apps create notifications on the device with more than just 'status'.
Another interpretation of your question: In response to a firebase cloud messaging message, you might want to save data or do some other background task, instead of just creating a notification the user sees. This is not enabled by default. There's lots more instructions on enabling and using this in the README
By default background messaging is not enabled. To handle messages in the background:
The golden nugget of information is _firebaseMessaging.configure(onBackgroundMessage: yourBackgroundMessageHandler) which is not listed under the receiving messages section.
Let me know if I misread. What do you mean by status?

You can use background Fetch to make the app stay in the background. The package will awaken an app in the background about every 15 minutes.

Related

Custom Length Vibrations For Notifications in Swift

I am developing an app that sends vibrations to a users phone based on how long the user trying to reach them holds down a button. However, it has to work when the users app is not open. Is there a way to attach custom haptics to a notification to achieve this? I was also thinking that generating user feedback haptics locally when a message is received would work but I need it to work when the user is not using the app. Any suggestions?
This feature isn't available to the Firebase FCM library and would require the vibration settings configured on a per device basis.

Can a flutter app run code on receiving a push notification while Not Running

I have push notifications working and have both a data and notification part in them. In the data part is a tag that tells the app what updates are available for the user.
The problem is that I would like the app to fetch those updates even if the user does not tap on the notification.
With other apps, eg Whatsapp, a notification is shown. Without tapping this notification, and even when the app is not running, the app downloads the data. For example if the user switches to flight mode right after receiving the notification and then opens whatsapp, the message and/or picture is there, already downloaded and displayed in the app.
So the question is how to get an app written in Flutter to download something in response to getting a push notification, regardless of whether the app is in the foreground, background, or not running.
Checkout isolate mentioned in Flutter background processes with a link to Medium Executing Dart in the Background with Flutter Plugins and Geofencing
Checking with GitHub issue Flutter should provide an abstraction for background execution and issue comments/references after that you may find some other examples. Bottom line is people need more examples.

OneSignal - Sending silent notifications that only increment badge (app in background)

My app (iOS) is in background and I want to send a push notification that won't display anything (silent) and that will only increment badge count on the app's icon.
I am still not clear on how to manage that.
Is it a parameter in the message body or in my handler code?
Thanks
Try to send a push notification with content-available=1
Turn on the content-available (iOS) or silent-notification (Android)
fields. This will cause your application to be automatically woken
up in the background whenever a notification is received (even if
it's not clicked). Your custom code must be write with native code,
Java on Android and Swift or Objective-C on iOS. See Apple's
content-available for iOS and our Android Background Data guides for
details on receiving and processing the event.
In your app, we
provide an API that you can use to run custom code when the above
occurs. Your custom code can then save a copy of the notification
content on the device in order to be displayed in an activity feed
when the app is next launched. Or it could save a copy of it on your
servers.
https://documentation.onesignal.com/v3.0/reference

Local or Push notification

I have a simple application that shows some videos from a YouTube channel. I need to send a notification to my users when that YouTube channel have a new video.
I've been thinking and I realize that if I use local notifications the app will have to run a method every "5 minutes" and check if there's a new video, BUT when the user closes the app my method will stop running and the app will stop checking for new videos.
Otherwise, I'll use remote notification. I'll store the user device token into a database and check for new videos with PHP. When it happens, I'll send a push to all my users. Unfortunately, this case will overload the server that the PHP is.
My question is: What's the best solution? Is there any way to I keep executing a method when my app is closed?
Push is your best option. There isn't a good enough way to keep checking in the background to use local notifications accurately enough. Monitor for new videos on your server as often as you feel necessary and fire a push notification to the user. That model exists in many apps across the app store. Good luck.

iPhone Push notifications via mobile safari

Is there a way to simulate push notifications by pushing data to mobile safari? Here are 2 scenarios.
I make a web app via phonegap and dont want to use APNS but rather make a web-socket connection and push data to the device myself. On the device end is there a "alert" function I can call to emulate a pop up when a user is not in the application?
Lets throw web app out the window. Is there a way I can do this in native mobile safari? Im not talking about a plain old JS alert window that would only come up if the user was in the app, but be able to do so with it backgrounded.
You cannot run background tasks with mobile safari so for #2 you can't do true push notifications or alerts. However you can send a user an SMS if you have the user's phone number. This can have a hyperlink to a part of your web site (which can contain some sort of payload). You can use a service such as Twilio to help you send SMS'es. However this costs money. APNS does not.
For scenario #1 I'm assuming you're talking about a native app using a phonegap solution. In this case when the app is backgrounded you cannot access any UI at all and wake up the app and show a UIAlert. In fact unless an app is registered for location updates or background music, the app is effectively not going to respond after a set period of time (it only can "finish" certain operations it had started before). So the websocket solution will only be effective if the user has the app opened.
You could register a local notification that runs at some predetermined time which will show an alert. But that is not being pushed from the server so its probably not what you want.
APNS is your best solution for scenario #1. Its not that hard to implement and its pretty inexpensive. Check out urban airship if you want to avoid building out your own server-side components for it.