0
我有一個YES按鈕在我的應用程序上的可操作的通知設置。是否有可能在通知被觸發並按下是按鈕時將您帶入特定視圖控制器的應用程序,而不是初始視圖。使用iOS8可執行的通知在特定的視圖控制器上啓動應用程序
我有一個YES按鈕在我的應用程序上的可操作的通知設置。是否有可能在通知被觸發並按下是按鈕時將您帶入特定視圖控制器的應用程序,而不是初始視圖。使用iOS8可執行的通知在特定的視圖控制器上啓動應用程序
是的,您可以使用iOS8的新方法handleActionWithIdentifier
來執行此任務。每當你按動作按鈕,這些代表就會打電話。
委託localNotification:當你的應用程序已經被用戶選擇從本地通知的動作被激活時調用。
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler
委託remoteNotification:當你的應用程序已經被用戶選擇從遠程通知的動作被激活時調用。
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler
注意:應儘快你處理完動作調用完成處理程序。
然後你可以得到你的rootViewController
使用這個,然後重定向到其他ViewController。
- (UIViewController*)GetTopViewController
{
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
UIViewController *rootViewController = appDelegate.window.rootViewController;
if ([rootViewController isKindOfClass:[UINavigationController class]])
{
UINavigationController* rvc = (UINavigationController*)rootViewController;
rootViewController = rvc.visibleViewController;
}
return rootViewController;
}
其他相關Question Link
感謝。我已經有了這些代表。如何在特定的視圖控制器上打開應用程序頂部? – user3626407 2014-10-13 08:06:44
再次檢查答案... – Rajneesh071 2014-10-13 10:07:14