I’m implementing push notification and i’m managing it when user is using app. So an alert view appear and on view click it must redirect to an uiview. now if user is showing that uiview when alert is coming how can i know the uiview on top? how can i update the uiview current? Alert is shown in application delegate in the metod didReceiveRemoteNotification.
Thankss
EDIT:
i want to do something like this:
UiviewController current* = [delegate getCurrentView];
if(current.toString=="NotificationView"){
[current update:notificationText];
}else{
saveNotification;
goToNotificationView;
}
I think most probably you have a
UINavigationControllerin your mainwindow(it can be aUITabBarController,etc), but if you have aUINavigationControllerin your mainwindowthen you can check the top view controller of yourUINavigationControllerby using[self.navigationController topViewController];or you can also check forUINavigationController‘sviewControllersstack that returns an array of all view controller’s you pushed inUINavigationControllerand can get the last object of thatarraywhich is your top view by using[[self.navigationController viewControllers] lastObject];.If you have a
UITabBarControllerin your mainwindow, then you can get the instance ofUINavigationController(if its there) by using[[self.tabbarcontroller viewControllers] objectAtIndex:[self.tabbarcontroller selectedIndex]];and can do the above steps to get the top view.