从本地通知加载我的应用程序时,我正在尝试读取其有效负载。为此,我有以下代码:
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Loading Stuff
UILocalNotification *localNotif =
[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
[(UITabBarController *)self.window.rootViewController setSelectedIndex:1];
UINavigationController *nav = [[(UITabBarController *)self.window.rootViewController viewControllers] objectAtIndex:1];
IMTRewardsViewController *rvc = [storyboard instantiateViewControllerWithIdentifier:@"rewardsView"];
[rvc loadPushNotification:localNotif];
[nav pushViewController:rvc animated:NO];
}
return YES;
}
IMTRewardsController.h:
-(NSDictionary *)loadPushNotification:(UILocalNotification *)notification;
IMTRewardsController.m:
- (NSDictionary *)loadPushNotification:(UILocalNotification *)notification
{
NSLog(@"%@",notification.userInfo);
return notification.userInfo;
}
当我从本地通知加载我的应用程序时,我收到以下错误:
<Error>: -[UIViewController loadPushNotification]: unrecognized selector sent to instance 0x14e70b30
<Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController loadPushNotification]: unrecognized selector sent to instance 0x14e70b30'
关于如何解决这个问题并防止它在未来出现的任何想法?