after studying apple's "Local and Push Notifications in Depth" and loads of forum postings,
i still cannot figure this out:
my application schedules a notification in 10" at startup in didFinishLaunchingWithOptions.
if the app stays open, didReceiveLocalNotification is called after 10" and i can start another notification there. good.
if the app is in the background, the system alert pops up.
if i click "View", didReceiveLocalNotification is also called and i can schedule the next notification. good.
if i click "Close", nothing is called so far and i cannot renew the notification.
BAD.
i wonder, how i can capture the Close button event from the system's local notification alert popup.
any ideas?
TIA
dave
You cannot.
You can use recurring notification or schedule up to 64 for local notifications in advance and cancel/reschedule as needed.
Related
STR -
when notification receive dismiss from notification panel
close the app and don't use it for some time
open the app again
now will see the previously dismissed notification is showing up again.
shows previous past time of received notification. Example as 5h.
Expected result -
cleared notification from notification panel should not show when the app is opened next time.
I've implemented a macOS app + extension.
The extension might send notifications to the app via DistributedNotificationCenter.default() and postNotificationName(_ name: ...).
The questions is regarding to the app life cycle on macOS - what happens if the user minimized the app, and the extension (which is running) sends a notification with the 'deliverImmediately' flag.
Will the app be able to handle it, even while minimized? If no, any other way to achieve this behavior?
P.S - I didn't find anything at the documentation, and when trying to check what happens, sometimes the app got the notification, and sometime it didn't..so asking to check what is the expected behavior.
The app isn't paused while minimized. Being minimized is a state of NSWindow not NSApplication. The app's run loop still executes, perhaps less frequently, and of course, the window won't be receiving any keyboard or mouse events while minimized, but the app will still be able to process notifications, AppleEvents, network or file I/O, etc... You may need to "un"minimize if the notification involves user interaction in the minimized window with NSWindow.deminiaturize(_ sender: Any?).
If the app is hidden it also still runs, and you'll want to activate it with NSApplication.activate(_ sender: Any?) to do any UI.
Is there any way to launch an app when push notification is received from background?
I want to bring up a modal page (alert page with some info) when push notification is received.
I have tried to use the plugin https://github.com/katzer/cordova-plugin-background-mode, but no luck. (wakeUp and unlock function do not work)
How can we make fire the push notification delegates if app is not running state without tapping the received notification.
1. Received notification
2.Not tapping on notifications
3.Launching the app by clicking app icon
In this state how can i check if push notification received or not?
See the comment here:
UIApplicationLaunchOptionsRemoteNotificationKey not getting userinfo
Basically set "content-available": 1 in the payload and application:didReceiveRemoteNotification:fetchCompletionHandler will be called.
There is a way, using that you can process your every push notification. add key content-available with value 1 in to your aps dictionary.
so it will look like,
{
"aps" : {
"alert" : {
"title" : "Game Request",
"body" : "Bob wants to play poker",
},
"badge" : 5
"content-available" : 1
}
}
If iOS system detects pushNotification with "content-available" key having value 1, it will call application:didReceiveRemoteNotification:fetchCompletionHandler: of your appDelegate.
Apple - Discussion
Use this method to process incoming remote
notifications for your app. Unlike the
application:didReceiveRemoteNotification: method, which is called only
when your app is running in the foreground, the system calls this
method when your app is running in the foreground or background. In
addition, if you enabled the remote notifications background mode, the
system launches your app (or wakes it from the suspended state) and
puts it in the background state when a remote notification arrives.
However, the system does not automatically launch your app if the user
has force-quit it. In that situation, the user must relaunch your app
or restart the device before the system attempts to launch your app
automatically again.
You need to enable background modes.
I want to do a simple alert as per given time from the application,alert is also show if phone is locked. and when press ok then go to application view(if phone is locked). if we can not navigate to the application programmatically, then i can do manually do the screen unlock. but when i do the unlock the application should open. so is there any way to do like this?
Yes i know the i can do it with local notification but my question is : when i click "View detail" or any other button + my phone is locked - so can i go to my app.
I think your are looking for Local Notifications see About Local Notifications and Push Notifications