2015-09-28 90 views
0

我的問題是當我重定向到另一個視圖控制器的數據未來。所以請幫助我..打開視圖控制器當推送通知收到或重定向到另一個視圖控制器

AppDelegate.m

我有聲明這樣

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
    { 

    NSDictionary *segueDictionary = [userInfo valueForKey:@"aps"]; 

    NSString *segueName=[[NSString alloc]initWithFormat:@"%@",[segueDictionary valueForKey:@"vendor_data"]]; 


    if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive) 
    { 

     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@" Offers" 
                 message:[NSString stringWithFormat:@"%@",[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]] 
                 delegate:self 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil]; 
     [alert show]; 

    } 

    else if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateInactive || [[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) 
    { 





    MessageViewController * referObject = [[MessageViewController alloc]init]; 
    //[self.navigationController pushViewController:referObject animated:YES]; 

    UINavigationController *navController = (UINavigationController *)self.window.rootViewController; 

    [navController.visibleViewController.navigationController pushViewController:referObject animated:YES]; 


    } 

    } 

UIApplicationStateInactive應用僅僅是開放的,它不是 重定向到MessageViewControllerUIApplicationStateBackground應用程序被重定向到MessageViewController

我想訪問MessageViewController & 這裏MessageViewController是一個Xib

請幫我....

感謝

+0

你的方法被調用或不 –

+0

你的意思是navController.visibleViewController.navigationController? navController是否足夠? – Johnykutty

+0

它是指揮,但什麼也沒有顯示,我是新來的iOS –

回答

0

對於iOS 8.x中使用

- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler { 
} 

對於iOS 9+使用

- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler { 
} 
+0

謝謝..但與上述問題相同。 –

+0

這個方法會被調用嗎?也沒有被叫到? – Johnykutty

+0

這種方法不叫 –

相關問題