How do I open a particular screen for a remote notification if I'm using mmdrawerController

40 Views Asked by At

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];}

1

There are 1 best solutions below

5
KrishnaCA On

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 :)