I currently have my app setup to receive push notifications. When I am in the app and I receive a push notification, I have a custom UIView slide down from the top of the screen and displays the notification (similar to the new version of Whatsapps). Essentially I am trying to mimic the banner style notifications in iOS 5.
What I am looking to do now is have that UIView clickable. When clicked, based off of the type of notification received, will bring me to a different view controller (similar to how whatsapp does it).
For example, I am in chatroom A. I receive a message in chatroom B. The slider view comes down, I tap that and it brings me to chatroom B. In the push notification I am essentially passing the chatroomID which I can use to identify which room (essentially some view) I would like to join.
I have a root view controller setup already with a navigation controller as well. I am modally pushing other view controllers as the user navigates throughout the app. Would I dismiss the current view and push the next view when receiving a notification?
Also how would I go about making my slider view detect taps like the iOS banner notification? (and maybe have a selected animation, similar to the “grey clicked style” in a UITableView)?
Here’s a trick for detecting a tap on a view: Use a
UIControlinstead of aUIView(UIControlis a superclass ofUIView). Then use theUIControl‘saddTarget:action:forControlEvents:method with controlEvents ofUIControlEventTouchUpInsideto send the object of your choice a message when the view is tapped. If you’re configuring the view in Xcode’s graphical editor, you can use the Identity inspector’s Class field to change the class of your view fromUIViewtoUIControl, and then you can configure the Touch Up Inside event.(I learned this technique from iOS Programming: The Big Nerd Ranch Guide by Conway and Hillegass.)