是否可以通過AppDelegate方法handleActionWithIdentifier
展示視圖控制器?PresentViewController From AppDelegate handleActionWithIdentifier
我註冊活動分類類似如下:
action1 = [[UIMutableUserNotificationAction alloc] init];
[action1 setActivationMode:UIUserNotificationActivationModeBackground];
[action1 setTitle:@"Tweet"];
[action1 setIdentifier:NotificationActionOneIdent];
[action1 setDestructive:NO];
[action1 setAuthenticationRequired:NO];
當我的遠程通知到達時,我可以下拉或向左滑動主屏幕上看到文字「分享Tweet」
我handleActionWithIdentifier
方法很簡單:
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:@"Tweeting this is awesome!"];
[self.window.rootViewController presentViewController:tweetSheet animated:YES completion:^{}];
}
if (completionHandler) {
completionHandler();
}
}
但是,當我從我的通知中單擊「Tweet」操作類別時,它什麼也不做。它現在不會顯示Twitter的鳴叫窗口。
我不希望應用程序必須打開才能執行此操作。思考?