0

I have a project in which my VCs are embedded in MMDrawerController. Problem I have received push notifications in my appdelegate but I don't know how can I open that particular screen for which I have received the notification. Making VC as centerVC will not work. It is not useful in my case because some screens have back button. I have also used

[_drawerController.centerViewController.navigationController pushViewController:pushedVC animated :true]

But its useless It doesn't have any impact on screens. Any help is appreciated in advance.

Here is my Code which i'm using in AppDelegate to go to ChatVC

-(void)GotoChatVCNotification{
UIColor *navBarColor = [UIColor colorWithRed:52.0/255.0 green:56.0/255.0 blue:52.0/255.0 alpha:1.0];
[[UINavigationBar appearance] setBarTintColor:navBarColor];
NSDictionary *titleDict = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName, nil];
[[UINavigationBar appearance] setTitleTextAttributes:titleDict];
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];

ChatVC *centerViewController = [storyBoard instantiateViewControllerWithIdentifier:@"ChatVC"];
centerViewController.User_id = [APPDELEGATE.userDetailsDic objectForKey:@"user_id"];
_otherUserID=[self.dicPushData valueForKey:@"sender_id"];
centerViewController.Reciever_id = [self.dicPushData valueForKey:@"sender_id"];
centerViewController.strFrom=@"notification";
centerViewController.strFriendId = [self.dicPushData valueForKey:@"sender_id"];
centerViewController.strProjectId = [self.dicPushData valueForKey:@"project_id"];
centerViewController.strChatUserName = [self.dicPushData valueForKey:@"full_name"];
centerViewController.strSupportChat = @"Chat";

[[APPDELEGATE.sideController.centerViewController navigationController] popToRootViewControllerAnimated:false];

[[APPDELEGATE.sideController.centerViewController navigationController] pushViewController:centerViewController animated:false];

//I have also used this below line, by which i'm able to redirect on that screen, but my MMDrawerController's Fictionality is absent there. // [[self topMostController] presentViewController:centerViewController animated:NO completion:nil];}

Amit Kumar
  • 583
  • 5
  • 16

1 Answers1

0

you can try it in the following way.

If you are at a different screen which got pushed on top of MMDrawerController's centerViewController, then you can try the following:

// Assuming you have access to _drawerController

// The below line is to remove any UIViewController on top of center

[[_drawerController.centerViewController navigationController] popToRootViewControllerAnimated:false];

// _screenToBeRedirectedTo is the UIViewController you want to be redirected to

[[_drawerController.centerViewController navigationController] pushViewController:_screenToBeRedirectedTo animated:false];

The above code is by assuming that you don't want any additional information for redirected to the _screenToBeRedirectedTo screen

Edit

If you can specify the constraints you have, I can give more detailed answer. Feel free to comment if you have any doubts :)

KrishnaCA
  • 5,615
  • 1
  • 21
  • 31
  • thankyou! for quick response but it is not working for me. It is popping the view controllers upto rootVC but after that it is not pushing the my _screenToBeRedirectedTo Screen – Amit Kumar Nov 01 '17 at 05:27
  • @Amit, let me check – KrishnaCA Nov 01 '17 at 05:31
  • @Amit, Can you please tell me if you are using this line `[_drawerController.centerViewController navigationController] popToRootViewControllerAnimated:false]` or this one `[_drawerController.centerViewController navigationController] popToRootViewControllerAnimated:true]` – KrishnaCA Nov 01 '17 at 06:53
  • I'm Using [_drawerController.centerViewController navigationController] popToRootViewControllerAnimated:false]. – Amit Kumar Nov 01 '17 at 07:57
  • @Amit, I checked it. It's working for me. Can you please update the question with the current code you are using to do the same? With more information, I can help you – KrishnaCA Nov 01 '17 at 08:37