I am working on an iphone app where I store all the local(and push) notifications for my app. There will be a screen on app which shows all the notifications generated by the app. My question is that can an iphone app know when a local notification for that app is shown. for example, suppose that a local notification is shown, but the user simply ignores that notification, and does not tap on it, so in this situation, can my app somehow find out if the local notification was shown and do some processing on it(for example, store the notification data in sqlite database).
I have tried both "didFinishlaunchingWithOptions" and "didReceiveLocalNotificatios", but from my understanding, they are invoked when a user laucnhes app by tapping on the notifiaction, is there a method by which I can have the notification data even when user does not tap on the notification.
tldr; can an iphone app handle(process) local notifications even when user does not launch app by tapping the notification.
No, your app wan't get any notification whcih user has ignored. Your app will notified only when user presses view or tap on that notification.
Related
I want to know if the following is possible in flutter using flutter firebase messaging (FCM)
Scenario:
The app is closed or killed. A firebase push message is sent to the device (or device is listening on some topic etc.). The app gets the notification in the background and based on a flag in the data, either shows a notification in the notification tray or opens the app and displays a modal dialog to alert the user of an emergency notification. This has to happen automatically without having the user to click on the notification
Use case,
Any notification with medium severity that comes in can be displayed as a notification in the notification tray. The user can click on it and open the app whenever he wants to
Any notification with critical severity and which requires immediate user attention needs to automatically show a modal dialog with some buttons to enable the user to take action. It must play some sound to get the users attention.
I have done this in android previously where we used to get the notification in the notification handler and then based on the incoming message data, we used to either show a notification or show a dialog.
I have an app that can receive several notifications at the same time.
I'm able to receive all of them (by setting style as inbox) but the issue is that when the user click on one notification, the app is opened and ALL the notification disappears... Is there a way that the device can keep the OTHER notifications in the notification list until the user click each of them?
I saw this working in other apps, but I'm trying to do it with Ionic2.
Thanks!
This question already has answers here:
Relaunch iOS app without user interface when application in background?
(4 answers)
Closed 10 years ago.
Please suggest me objective c code for bringing the app from background to foreground without any user interaction when push notification comes.
Unfortunately it is not possible as Notification come and your app started automatically even without user interaction.
As Push Notification comes it Handles by OS.
If a notification for an application arrives when that application is not running, the device alerts the user that the application has data waiting for it.
Then It means user have to interact with the Device.
From The Apple Doc.
When the operating system delivers push notification (iOS or OS X) and the target application is not running in the foreground, it presents the notification (alert, icon badge number, sound). If there is a notification alert and the user taps or clicks the action button (or moves the action slider), the application launches and calls a method to pass in the local-notification object or remote-notification payload. If the application is running in the foreground when the notification is delivered, the application delegate receives a local or push notification.
That's All.
I hope it clears to you.
I dont think its possible. Once push notification came, the os itself handles and show notification if it is enabled for your app. Then from the notification, if you are going to app, then didReceiveRemotenotification callback will be fired.
Thanks.
It's possible but it would require a jailbroken iPhone and hook the push notification receiver to launch your app when the notification is received.
If you aim for App Store you can't.
I'm using local notification in my app but have a problem handling them correctly.
When app is running, and active, in didReceiveLocalNotification I can fetch user settings from NSUserDefaults and handle the repeating notification, and cancel it if fire date isn't the day it should fire, or show an alert if it's correct date.
However, when app is running, but inactive, the notification will fire although it shouldn't.
Same thing when app is not running, the notification will fire although it shouldn't.
Question
When app is not running, and when app is inactive, how can I access NSUserDefaults and cancel the notification before the alert show up?
Edited answer
The reason I had to ask this was because of bad app design and logic. I tried to set repeating local notification no matter what settings user has set and access NSUserDefaults in it although I should have access user settings first in app itself and then set notifications accordingly.
You can't. a UILocalNotification is handled by iOS and not your app.
Only when your app is active the notification get directly pushed to you app.
In all other cases the os will just show the notification.
I have a UILocalNotification that fires on a recurring schedule. The purpose that the notification fulfills is to just simply remind the user to do something. When the notification fires, they can enter into the app and another alert pops up and asks them if they complete the task, and the app tracks accordingly.
If the user is using their phone, the notification fires, and the app switches great, and the user input is recorded. If they are using the app at the time the notification fires, everything works great. If they aren't using their phone, the notification wakes the phone up, and has an option to "Slide to view" whereupon the app comes up and the alert pops up great and the input is recorded.
The problem is when the user isn't using their phone, and the user DOESN'T slide to view during the few second window that the alert wakes up the phone, when the user wakes up the device later on, the alert window is still there, letting the user know that something happened, but the "Slide to view" option is replaced with the standard "Slide to unlock" and when the phone is unlocked, the ability to go into the app is gone, and the user input can't be recorded.
So I am losing access to the ability to respond to a notification in my app. Is there anything that can be done to solve this problem? Thanks!
Only way to do that is to keep track on notification outside notification system. Unfortunately notification system is not allowing you to read any data about notifications you set.
Whenever you set a notification add it to a list of notifications with a date when it will be launched. When user enters your application go through your local list and see which notification expired (date < NOW).