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

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

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


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

推送接受函数

目标处理位置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;
}

渲染弹出动作

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

【热门文章】
【热门文章】