0

I am trying to show a miniBox on a RedBoxViewController. When the user presses on Ok button on the AlertView the miniBox should appear on the ViewController.

RedBoxView is the rootView and it is on the screen when the user receives the alertView. I am trying to find ways to show the redbox. It has been days and I can' think of any alternative way.

I know I should not push a viewcontroller that is already on the screen. I think that is the problem. Because when I am on another Viewcontroller on another storyboard, the view is pushed to RedBoxViewController and I am able to see the miniBox. However I want to see it when I am on the RedBoxViewController.

What are the ways to show the minibox on the screen after receiving the alertView?

I have the following codes in App Delegate:

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

    if ([[userInfo objectForKey:@"aps"] objectForKey:@"alert"]) {
        NSString *message = [[userInfo objectForKey:@"aps"] objectForKey:@"alert"];

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Package here"
                                                        message: message
                                                       delegate: self
                                              cancelButtonTitle: @"OK"
                                              otherButtonTitles: nil];
        [alert show];


    }

}


-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {
        NSLog(@"The OK button was clicked for alertView");


        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"RedStoryboard" bundle:nil];
        RedBoxViewController *redBoxView = (RedBoxViewController *)[storyboard instantiateViewControllerWithIdentifier:@"redBoxView"];
        redBoxView.miniBox.hidden = NO;
        [(UINavigationController *)self.window.rootViewController pushViewController:redBoxView animated:NO];
    }
}
Celeo
  • 5,583
  • 8
  • 39
  • 41
EsmaGo
  • 141
  • 1
  • 7

0 Answers0