[英]Launch app on specific view controller using iOS8 actionable notifications
我的應用程序上有一個可執行的通知設置,帶有“是”按鈕。 觸發通知並按“是”按鈕時,是否可以將您帶入特定視圖控制器(而不是初始視圖)上的應用程序。
是的,您可以對此任務使用handleActionWithIdentifier
的新方法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;
}
其他相關問題鏈接
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.