I have got push notification working but the next thing I want to do is to open a relevant view when clicking on the notification.
In my appDelegate.m in didFinishLaunchingWithOptions, I have the following:
NSString *params=[[launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"] objectForKey:@"alertType"];
if ([params length] > 0 ) {//app launch when VIEW button of push notification clicked
if (params == @"sc") {
Alerts *alerts = [[Alerts alloc] initWithNibName:@"Alerts" bundle:nil];
[[self navigationController] pushViewController:Alerts animated:YES];
[Alerts release];
} else {
}
}
However, in this line: [[self navigationController] pushViewController:Alerts animated:YES];, a warning comes up saying Method ‘-navigationController’ not found (return type defaults to ‘id’).
How can I rectify this warning and am I right in trying to push the relevant view in didFinishLaunchingWithOptions?
Thanks.
Your
navigationControllermay not be declared as a@property, so you can’t use[self navigationController]. Just tryself.navigationController, or even justnavigationController, if that’s its name in your.h.Also, please don’t compare strings with
==. You have to doif ([params isEqualToString:@"sc"]). That compares the contents instead of the address of your string.