How to disable and enable notification in an app? - flutter

I want to make a Focus Based App where once the user enters in the Focus Mode, no social media notification or any kind of notification will disturb the user.
Please help me.

I think by notifications you mean FCM notifications, if that is the case you can simply make a switch that will add/remove FCM token from the backend.
For more info you can check the Firebase messaging package on pubdev

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.

Flutter best way to store App Notifications?

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.

An alert like whatsapp when app is in background in ionic

I am using One Signal push notifications in my ionic app. I want to show an alert when i receive a notification when my app is in background.
I tried using the platform pause and remuse functionality to check for background and foreground and then generate an alert when app was in background using ionic alert controller but was not able to produce the desired result.
I want a pop up dialog box like one in whastapp when u receive a message.
Can anyone please suggest a solution to this.
There is no way to achieve what you're trying to achieve through the use of OneSignal alone. The OneSignal plugin for Ionic has two calls to action:
handleNotificationReceived() & handleNotificationOpened()
The first one is called when the notification is received and the app is in the foreground.
And the second is called when the app is launched from the notification.
You would need some other service to record when notifications are sent to see if there were any when the app was launched by itself. If you use OneSignal's REST API to send notifications yourself, you can record when a notification is sent, and then when the app is launched by itself, you can fetch missed notifications or notification count from your own server. That's just one way you can do it.
But OneSignal is a push notification service, which send notifications. Even if you did FCM yourself and went through the scenario you mentioned, the results would be the same.
It's not a OneSignal issue. It's the way notifications are designed.

phonegap ios) is it possible distinguish push notification that user clicked?

I am using phonegap push notification plugin and all seems work fine. push comes without any problem.
But the problem is there is nothing I can do when app is back-grounded.
multiple push notifications can arrive when app is backgrounded. I can not expect which push
notification user going to click. Whatever notification user clicks, app will be resumed without
information of user selection. I have to trigger different events depanding on what nofitication
user selected. I need to know what notification user selected when app is resumed but don't
know how to... seems very tricky problem. is there anybody had same problem?
how did you guys handle this problem?
any help will be appriciated.
never mind...
I thought window.plugins.pushNotifiction.getPendingNotification would return all pending
notifications which arrived while app is background.
But getPendingNotification function only returns the notification that user selected on
notification center or mobile screen.
well... seems nice..
you can`t get all notification information which fire during application is off or app. is in background but, you can fetch user info shortly receive notification in native iOS app.
please follow this application:didFinishLaunchingWithOptions.
At first call of launch you can check for options and retrive the user-info.
for more info refer above link.

push notifications: sounds and badges

I'm working with push notifications and i have a doubt: if in my script (server-side) there are badge and sound, but the user set sounds and badges off... what happens?
I mean: i need to register in my database every setting for every token, or i send the notification and the iPhone does all the work? :)
Thanks!
You don't need to worry about the user settings. The user will receive the alerts he allowed. So if he doesn't want to have the sound and he switch it off. You can still send it and he just receive the alert and or badge...
If the user switches off a particular notification type in user settings, such notifications are not received by the application. For example:- lets say I registered for sound and badge notifications but I disabled the badge notifications in user settings, the application will only receive the sound notifications from now until I enable the badge notifications in user settings or register again for alter notifications too. Re-registering for badge notifications wont enable the badge notifications since they are disbled in user settings.