Is there a way to find out if the user is online or not in flutter - flutter

Please I want to create an online or offline feature for users in my app
I tried onDisconnect in Firebase and it didn't work for me

You can use socket.io for flutter. When user open the app then socket will tell the server that specific user is connected.The user able to see other connected users. Here is a article of how to use socket.io in your project.

You can try pusher presence channels.
It is based on websockets, and it tells you who is connected to the channel (who is present). You can find the use cases for presence channels here.
click here to find out how to build presence channels.
I'm currently building an online and offline statusbar for a flutter app if a user is connected to a presence channel. If I have the working code I'll post an update.

Related

How to setup notifications in flutter application?

I was wondering if Flutter has the ability to generate push notifications from within the app. If so is there a code example of this?
Description:
An event occurs on the flutter app such as a button being clicked or an if statement being triggered, I want a push notification sent to the user.
The app should also always be running in the background, is this possible? If so can you provide me a link with an example of this implementation.
Thanks in advance for all the help!
I have looked on google but I haven't been able to find a lot of information regarding these two topics.
Being an iOS engineer, I'd say that you actually want local notifications. Push notifications are usually being sent by a server.
You could check how it's usually done on iOS natively: developer.apple.com.

Incoming call notification

We are developing an app with angular/ionic in which we use capacitor jitsi plugin for video calls. What we are now trying to do is to receive notifications (via firebase) like in whatsapp with the incoming call screen and two buttons to accept and decline. Any idea on how to do that?
Thanks
If you got the choice to change the notification service, instead or directly using firebase, you could use Onesignal which extends firebase and they already have a service named VOIP notifications which should kinda do your needs and here is the link:
https://documentation.onesignal.com/docs/voip-notifications
In case your are restricted with firebase or need to know how this could be done, bellow will be the way to achieve it..
As for android:
First as logic part, you need to add some code in the native layer since hybrid apps usually can't interact from JavaScript side to native side in case app was not launched, so in order to wake the application on a specific event like notification received or any other actions that phone system can hold..
Second, as technical part, you need to add broadcast receivers and the receivers role stand to interact as native code with system. example in the link below:
https://www.digitalocean.com/community/tutorials/android-broadcastreceiver-example-tutorial
also another video about foreground and background broadcast receiver service in the link below:
https://www.youtube.com/watch?v=rlzfcqDlovg
video code output in git:
https://github.com/borntocoderepos/callrecorder
in the Youtube video example, the user is launching a toast message on phone call if app was opened or closed (background or foreground) so you can launch your app with intent with passing data and capture the data on app start as Deep Links as capacitor (https://capacitorjs.com/docs/guides/deep-links) or Cordova (https://ionicframework.com/docs/native/deeplinks)..
And instead of listening to network or phone calls, you can listen to Notifications and for sure you need to do searches about your topic and or the notification service that you'll choose.
Now for the video and the tutorial not sure of the quality of code so make sure to do more researches about the way its done from different places (could be outdated code or bad code quality or even not complete service and will discuss about this point below).
In android there is policy about using background and foreground services so once you start a service you need to end it after your done so make sure after you receive the notification and launch your app to stop the listening since it would cost power usage and perhaps could be stopped by Playstore as harmful app.
Now considering IOS it should be the same concept so make searches about this topic, but for IOS, the listeners policy as I remember , the receivers should not be waked up for more than 15 mins, so also keep this in mind and make sure you stop the receivers directly after launching your Hybrid app.
Broadcast equivalent receiver for IOS:
http://www.andrewcbancroft.com/2014/10/08/fundamentals-of-nsnotificationcenter-in-swift/

How to send push notifications from a dashboard to a flutter app?

Currently working on a dashboard that controls and manages multiple processes going on in a flutter app (the link between them is firebase). Once I make a few adjustments on the dashboard, I want to be able to notify the user through a notification. Is this possible? Are there any useful resources for this?
Everything you need to know is present in the official Firebase Cloud messaging documentation :
https://firebase.flutter.dev/docs/messaging/overview/
Follow every steps carefully and you'll make it successfully work ;)

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.

Messaging service within my app

I need to implement a message service into my app that works exactly like this:
users register with a nickname within the app
they can add contacts (just nicknames) and send them a message by just specifying their nickname
they can send a message whenever they want, and the message is stored on a server until when the receiver connects to internet.
when a message is received, a push notification is triggered.
So, the messages work pretty much like emails, however instead of using email addresses, we only use usernames. I'm also going to build my own back-end for it.
Which APIs should I use or which 3rd party framework can I use ?
And any tip ?
N.B. I need to make it work with iOS 3.0 as well.
and in the future I will develop an Android app, so the nicknames should be unique and I should be able to send messages from iPhone to Android devices within the same app.
thanks
I've successfully used the Three20 library and would recommend giving it a try. It's an open source spin-off originated by the author of the Facebook app. It features a bunch of additional GUI components that might be useful to your project, like a message composer that resembles the one used by Apple's email app.
Also, Three20 features a nice framework for handling navigation within your app. Currently, the biggest drawback seems to be that certain features don't play well with the iPad API.
The answer seems to be Push Notifications