Flutter own push notifications (store agnostic) - flutter

I was wondering, given that Flutter is multi platform and each store requires its own procedure for the final step of setting up Push notifications, would it be worthwhile to implement a full "flutter proprietary push notification system" something that would ignore completely the Android/iOS and other stores implementation?
The main service that the store provides is to "find" the device in the final step of the push, this could be replaced with:
a subscribe / ack of this flutter layer to a server (whenever the app declares that it wants to use it), that will send the message when required (with a messaging queue?)
an always on instance on the phone to actually receive the push (this is probably the most critical part)
UPDATE: I am realising that this necessity will probably be covered by some sort of third party provider, such as what Crashlytics has done with error and crash reports.

Operating system push notification services (OSPNS) are provided by the Android and iOS and other platforms. If you want your messages to be shown as notifications on the notification tray/status bar you have to configure it as required by that platform and there is no other option for this. If you want to use only one push service than Huawei Push Kit might be the one to choose since it can send push notifications to all platforms Android, iOS, Huawei devices and also Web.

This is almost impossible.
Because on the basis of Android, there is a part handled by the OS in the case of push, so even if the app does not reside in memory, it can be processed. If you're going to create a Flutter-only Push system, the Flutter app should always be running as a background service (iOS is a different issue).
If you only want to be able to use push while the Flutter app is running, that might be the way to go. However, it will be difficult after the app is closed.
url link : https://developer.android.com/reference/android/app/NotificationManager

Related

How to make periodic background fetches in Flutter iOS and Android App?

I am developing an app that should fetch an API periodically (every 15 or 30 minutes). I am using Flutter for the frontend development. The app should be available for both Android and iOS devices.
The background task includes a call to the backend. In the backend, a worker is determining certain data (this can take up to one minute) and sending it then back to the frontend. The task has to be (at least partially) initiated by the frontend, as an decryption key is passed to the backend.
I had the idea to use Firebase Cloud Messaging to push the requested data to the devices. Unfortunately, it seems to be necessary to have the Apple Development Program enrolled to use it. As the app is an university project, and I'm not even sure, if the FCM approach is the best one, I don't want to pay the 99€ for the enrollment.
Beside the FCM approach, I found some flutter packages like "background_fetch", to pull the data instead of pushing it, which wouldn't be a problem for me. But all packages I found have the problem, that they work differently on iOS and Android, and are also not very reliable in terms of background task management by the respective operating systems.
Is there any "simple" solution for this problem, like a flutter package allowing me to schedule periodic background tasks on both iOS and Android, which is mostly reliable in that the time periode is respected at least roughly and the background task is not killed while waiting for the response? Or will I have to implement an own server-side Push-Service to avoid the costs for the Apple Developer Program?
Thank you in advance!

How to push up notifications from backend with flutter without firebase nor one signal?

I have searched Google, YouTube and stack overflow for the answer but I haven't found any real solution.
I want to implement my own push notification solution on flutter, without firebase nor One signal. I do not want to depend on a third party service.
My Backend is on GoLang with graphql.
On the frontend, I am using a block pattern (flutter_bloc v6) and graphql_flutter v4.
I am using graphql subscriptions, so whenever the Backend emits a signal, the flutter app is able to receive it immediately.
I would like to be able to push up notifications to my users whenever the Backend sends some information, no matter if the app is on the foreground, background, closed or whatever. I do not want scheduled notifications either (aka flutter_local_notifications)
Do you want to use a third service other than firebase/one signal?
Then you can try airship(https://docs.airship.com/reference/messages/message-types/push-notifications/)
But if you want to setup your own provider server, please check this page(https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server), this is the start point, from where you can start your investigation and development.
Then you have to create your own backend system to send push notifications to the device. You have to develop Native Application for iOS and Android going beyond flutter. The local push notification could be used but you need to develop a custom notification receiver that will respond to the notification call back from the server in the background.

What's the best way to run a function after a request sent by a server?

Here is the use case:
the user launches the app and grants permission, the app connects to the server
at some point in the future, the server sends a request to the app
the app
regardless of whether it is running or not in the foreground or background, wakes up to run this code
Here are some options I have explored which I am unsure about:
server sent events
websockets
push notifications
Is there a reliable and safe way to do this on android, whether it's Kotlin or Flutter? Can you provide examples or documentation?
Thanks!
Turns out that the best way to do it is with push notifications!
Websockets and server sent events are better suited for other use cases. Persistent connections to a server are resource consuming, and both Android and iOS have mechanisms in place to terminate apps running in the background to save memory etc. So we would probably lose the connection and not be able to receive anything from the server if we minimized the app or locked our phone screen.
Push notifications are basically built for this exact use case because, even though they work differently on Android and iOS, they are built to receive messages from a server regardless of whether the app is in the foreground, background, or not even currently running.
I used Firebase Cloud Messaging to build my app since it's primarily an Android app. It worked like a charm.

Sending iOS push notifications from my Machine?

I would like to add iOS push notification to my FREE iOS App
The push notification will be mainly advertising my other iOS applications. so I am expecting 1 or 2 push notifications every month
I checked service like urban airship, but I think it is expensive considering I have more than 1.5 Million active users.
So, what I am thinking of is collecting the devices token at Google App Engine ( java ), then whenever I want to send push notifications I export those tokens then send them from my Machine.
Is this is the right approach? what do you think?
Is there any framework that I could use instead of building things from scratch?
Many thanks
This approach looks ok to me. Having an app on Google App Engine to whom each of the iOS device is sending their device token. Later at any time utilizing a web page or web service running on Google App Engine APP you can push custom notification to all respective device tokens. Just keep in mind to filter the list of device tokens with obsoleted ones (in case somebody uninstall your app).
You may check http://code.google.com/p/javapns/ for APNS communication. I tried it couple of times and it worked really well.
You should also give http://www.scringo.com a try.
Among other things this framework does, it also gives you a free push notifications service to send push messages to all your users or some of them (based on your custom criteria).

How to use Push Notifications

Regarding push notifications. How do I get the provision from APNS to implement push notifications in to my application. Help me guys.
start from these series
http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12
iOS developers love to imagine users of their awesome app using the app all day, every day. Unfortunately, the cold hard truth is that users will sometimes have to close the app and perform other activities. Laundry doesn’t fold itself, you know :]
Happily, push notifications allow developers to reach users and perform small tasks even when users aren’t actively using an app!
Push notifications have become more and more powerful since they were first introduced. In iOS 9, push notifications can:
Display a short text message
Play a notification sound
Set a badge number on the app’s icon
Provide actions the user can take without opening the app
Be silent, allowing the app to wake up in the background and perform a task
This push notifications tutorial will go over how push notifications work, and let you try out their features...
I followed the steps mentioned in raywenderlich tutorial. It's some what easy to send Push notifications to my iPhone app by using my system as the temporary server(ie, sending the message by running the PHP code from the Terminal window).
But, while going for production and dynamic messages for different users at different time, it's very tough for me to set the service in a server.
So, I go with third party server to send Push Notifications. - Parse.com
Tutorial for how to use that API.
Documentation about the installations of the application.
Here, we have a tag parse.com for questions about this process.