Hariprasad.J
Hariprasad.J

Reputation: 307

Open a Specific View controller when user launch UILocalNotification in ViewBased Application

I am working with UILocalNotification.Here When i Launch the notification i need a specific view in application.But I have tried like below coding .

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch.
     [[UIApplication sharedApplication]setStatusBarHidden:NO];

    SplashView *mySplash = [[SplashView alloc] initWithImage:
                            [UIImage imageNamed:@"Splash.png"]];

    [window insertSubview:mySplash atIndex:1];

    [window makeKeyAndVisible];


    mySplash.delay = 5;
    mySplash.animation = SplashViewAnimationFade;
    [mySplash startSplash];
        [self.window insertSubview:viewController.view atIndex:0];
        [self.window makeKeyAndVisible];
        [mySplash release];

    // Add the view controller's view to the window and display.    [self.window addSubview:viewController.view];

    UILocalNotification *localNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];

    if (localNotification) 
    {
        NSLog(@"Notification Body: %@",localNotification.alertBody);
        NSLog(@"%@", localNotification.userInfo);
    }
    [[UIApplication sharedApplication] cancelAllLocalNotifications];

    application.applicationIconBadgeNumber = 0;
    return YES;

}





- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

UIApplicationState state = [application applicationState];
    if (state == UIApplicationStateInactive) {

showItemContrller = [[Showitem alloc] initWithNibName:@"Showitem" bundle:nil];
        [self.window addSubview:showItemContrller.view];
        [self.window bringSubviewToFront:showItemContrller.view];

}

}

But When i launch the notification it is showing the previous view for fraction of seconds the it is going to showItemControllerView.

Thanking you

Upvotes: 0

Views: 1508

Answers (1)

Abhishek
Abhishek

Reputation: 2253

 //comment this line.... 

//[self.window insertSubview:viewController.view atIndex:0];

Upvotes: 1

Related Questions