Reputation: 203
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
// Handle the notificaton when the app is running
NSLog(@"Recieved Notification %@",notif);
NSLog(@"local notifications count = %d", [[[UIApplication sharedApplication] scheduledLocalNotifications] count]);
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef =CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"everything9", CFSTR ("mp3"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
[[NSNotificationCenter defaultCenter] postNotificationName:@"RELOAD_DATA"object:nil];
}
What can I implement here to push a specific view when the application arrives (when the user slides the app icon when the iPhone is locked, for example)... I'm trying [self.navigationController pushViewController:CompletedViewController animated:YES];
and I get some errors... Is there a specific way I should do it? Maybe in didFinishLaunchingWithOptions
?
Upvotes: 0
Views: 4921
Reputation: 157
if ([EntNotStrApp isEqualToString:@"1"])
{
EntNotStrApp=@"0";
UIWindow *window = [[[UIApplication sharedApplication] windows] objectAtIndex:0];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
UINavigationController *navController = (UINavigationController *)window.rootViewController;
DumpFeed *dump = [storyboard instantiateViewControllerWithIdentifier:@"DumpFeed"];
dump.isPushed=YES;
dump.strUserId = appDelegate.strFriendid;
[navController pushViewController:dump animated:YES];
}else
{
[[iToast makeText:NotMess] show];
}
Upvotes: 0
Reputation: 697
maybe you should call this
[_window.rootViewController pushViewController:CompletedViewController animated:YES];
The code above doesn't work now. You should try using this instead.
//We take the rootViewController first which is expected to be a UINavigationController in your case
UINavigationController *naviController = _window.rootViewController;
//We then call the push view controller code
[naviController pushViewController:CompletedViewController animated:YES];
this is how you push to your current navigation controller from the AppDelegate if you are using storyboards. Specially if your starting point on the story board is a navigation controller.
Upvotes: 3
Reputation: 3515
"[self.navigationController pushViewController:viewController animated:YES];”
This can’t be used from AppDelegate.m (ie. from didReceiveLocalNotification).
Try once by using “self.pushViewController” from didReceiveLocalNotification.
Upvotes: 0
Reputation: 483
In the older versions of Xcode, We have an option while creating the applications is navigation based applications. But in the latest Xcode generations, we can create Single view based or window based applications. So, if you want to use the navigation controller properties, you need to create the instance for UINavigationController and need to set the rootViewController. The code is as follows,
appDelegate.h
@property (strong, nonatomic) UINavigationController *navigationController;
appDelegate.m
@implementation AppDelegate
@synthesize navigationController = _navigationController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
So that, you can use navigation properties throughout the application.
I think this may helpful to you.
Upvotes: 0