How to perform a segue when a UILocalNotification is fired? - ios

I am making an app with multiple schedule alarms in the future. The design is that a Local Notification will fire, then when the user opens the app any time after this notification (either through Notification Action or just by tapping the icon on the home screen), the app will automatically show an Alarm view controller, which the user interacts with.
I know I can just call on a function with performSegueWithIdentifier with the Notification Action feature, but I would really like a comprehensive method that covers the case when the user ignores the notification, then launches the app with other methods.
Thank you for your help!

Related

Perform action when opening app for the second time

When I open the app it fires the events viewDidLoad and viewDidAppear form my View Controller but when I close it and run it again it does not call any of them.
Any idea?
You need to read up on application states. Here is a link I found online outlining the different states:
http://www.techrepublic.com/blog/software-engineer/understand-the-states-and-transitions-of-an-ios-app/
What you really want is to be notified when your app becomes active.
Probably the easiest way is to implement the function applicationDidBecomeActive() in your app delegate. That will be called when your app becomes active as the foreground app either on launch, or when it returns to the foreground as the active app.
Note that if you want that notification sent to some object other than the app delegate you can listen for the UIApplicationDidBecomeActive notification.

How to know if a local notification was fired while the app is in background?

I've enabled the background mode for location updates. I create an scheduled local notification, and I'd like to be able to stop the location services when it is fired and the app is running in background.
It seems that the didReceiveLocalNotification method is only called when the app is in foreground, or it is in background and the user taps it, is there any way to notice that it is fired while the app is in background, but the user doesn't tap it?
I hope this might help
When the system delivers a local notification, several things can happen, depending on the app state and the type of notification. If the app is not frontmost and visible, the system displays the alert message, badges the app, and plays a sound—whatever is specified in the notification. If the notification is an alert and the user taps the action button (or, if the device is locked, drags open the action slider), the app is woken up or launched. (If the user taps one of the custom actions you specify using the additionalActions property, the app is woken up or launched into the background.) In its application:didFinishLaunchingWithOptions: method, the app delegate can obtain the UILocalNotification object from the launch options dictionary using the UIApplicationLaunchOptionsLocalNotificationKey key. The delegate can inspect the properties of the notification and, if the notification includes custom data in its userInfo dictionary, it can access that data and process it accordingly. On the other hand, if the local notification only badges the app icon, and the user in response launches the app, the application:didFinishLaunchingWithOptions: method is called, but no UILocalNotification object is included in the options dictionary. When the user selects a custom action, the app delegate’s application:handleActionWithIdentifier:forLocalNotification:completionHandler: method is called to handle the action.
This from Apple documentation.

How to perform an action when a user slides up a push notification in iOS

I want to perform a action when a user slides up a push notification on home screen in iOS. Precisely which functions gets called when a user slides up a local push notification.
I could be wrong, but I think you cannot get that kind of event..

Is it possible to trigger an event when a user clicks a local notification

In Unity3d, is it possible to trigger an event when a user clicks a local notification in iOS?
I am letting the user know that it is their turn in a turn-based game, using a LocalNotification with NotificationServices. I want the user to be able to click on the notification, and have the game load the latest turn information. I'm not sure how to have something trigger when the user clicks on the notification though.
When user click the notification didReceivelocalNotification method in the AppDelegate will be called. Put your code inside that method.

Swift UILocalNotification: Is it possible to fire an event when Notification is displayed?

So I know the didReceiveLocalNotification event is fired when a user selects an action on a Local Notification.
But, is an event fired prior to that when the notification is displayed as a banner or alert when the app is not active? And can that be accessed to do some background code?
I am looking for an answer in Swift if you can help.
No, local notifications do not and cannot awake the app when firing and the application is not active. The user must tap the notification, or perform a developer defined action on it before the app hears anything.
If you need your app to wake up, you need to use a remote notification with content available flag set.

Resources