【发布时间】:2015-04-02 22:04:29
【问题描述】:
是否可以通过 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 推文现在窗口。
我不希望应用必须打开才能执行此操作。想法?
【问题讨论】:
标签: ios objective-c apple-push-notifications presentviewcontroller