如果您无法获得本地通知,请检查下面的代码。
在AppDelegate.m文件中添加代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Handle launching from a notification
UILocalNotification *localNotification =
[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotification) {
NSLog(@"Recieved Notification %@", localNotification);
}
return YES;
}
添加处理本地通知的方法
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notification {
// Handle the notificaton when the app is running
NSLog(@"Recieved Notification %@", notification);
}