UITabBarController构造界面如何接收推送时候弹出一个ViewController


我的程序构造如下,我的目的:程序打开之后,检测有没有推送消息,如果有推送消息的话,弹出“推送视图”,显示详细内容。
图片描述

ios xcode swift objective-c

悲剧帝的小茶几 8 years, 11 months ago

因为我不太喜欢使用拖拽,还是代码组织这一部分比较好吧。建议一下。

推送接受函数

目标处理位置 AppDelegate.m

远程透传事件处理
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userinfo

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler

获取顶层VC


 - (UIViewController *)appRootViewController
{
    UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
    UIViewController *topVC = appRootVC;
    while (topVC.presentedViewController) {
        topVC = topVC.presentedViewController;
    }
    return topVC;
}

渲染弹出动作

获取到视图以后你就可以选择 模态 或者 跳转 方式来跳转了。

岛田pop answered 8 years, 11 months ago

Your Answer