I would like to know if we can actually redirect the alert box to a specific view. Meaning that when they clicked on “View” which is on the notification alert, it will redirect them to a particular view, just like the text message notification pop up. Is there any idea on how this works?
Share
From your question, you could mean two types of alert dialogs:
UIAlertViewUILocalNotificationalert dialog, shown when the application is in the background ("just like the text message notification pop up")I will address them in order.
First, how to handle a
UIAlertView"View" button click.Implement the
alertView:didDismissWithButtonIndex:method of theUIAlertViewDelegateprotocol in your controller class, and when youinittheUIAlertViewset itsdelegatetoself. Then when the user clicks a button marked e.g. "View", do this:Secondly, how to handle a
UILocalNotificationwhich triggers an application launch.Apple docs on
UILocalNotificationstate:You need to write code for handling this launch case in your app delegate class, in the
application:didFinishLaunchingWithOptions:method.IF you happen to get a
UILocalNotificationwhile the app is running, Apple docs state:EDIT: To take the user to a specific view straight away, you can manually push something onto a
UINavigationControllerstack (if your app usually operates with navigation controllers, it makes sense to do this), or present a modal view controller. I’ve linked there to guides for both.