NodeDad
NodeDad

Reputation: 1537

perform segue from didReceiveRemoteNotification in appDelegate

EDIT: Before i o any further i should say i have found solutions to what im trying to do IF im using a navagiation controller based app, but thats not my case here.

Ive create my Push Notifications to have a Job, i have logged everything and recieved a push, clicked the push notification and recieved the correct logs.

My goal, is i want to perform a segue to get to my specific view controllers depending on which job there going to.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    NSString *job = [[userInfo valueForKey:@"aps"] valueForKey:@"job"];

    if([job isEqualToString: @"msg"]) {
        NSLog(@"Going to message");
    }
    if ([job isEqualToString: @"friend"]) {
        NSLog(@"Going to friend request");
    }
    if ([job isEqualToString: @"inv"]) {
        NSLog(@"Going to invite notifications");
    }
    if ([job isEqualToString: @"find"]) {
        NSLog(@"Going to find notifications");
    }
}

Upvotes: 1

Views: 1627

Answers (1)

Abdullah Shafique
Abdullah Shafique

Reputation: 6918

  if([job isEqualToString: @"msg"]) {
    NSLog(@"Going to message");
    UIStoryboard* storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    UIViewController* detailVC = [storyBoard instantiateViewControllerWithIdentifier:@"msg"];
    [self.window.rootViewController presentViewController:detailVC animated:YES completion:nil];
 } 

Upvotes: 1

Related Questions