在您的业务逻辑中
-(void)scheduleNotificationForDate:(NSDate *)fireDate{ UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.fireDate = fireDate; notification.alertAction = @"View"; notification.alertBody = @"New Message Received"; notification.userInfo = @{@"SiteURLKey": @"http://www.google.com"}; [[UIApplication sharedApplication] scheduleLocalNotification:notification]; }
在你的AppDelegate中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; if(notification != nil){ NSDictionary *userInfo = notification.userInfo; NSURL *siteURL = [NSURL URLWithString:[userInfo objectForKey:@"SiteURLKey"]]; [[UIApplication sharedApplication] openURL:siteURL]; } } -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{ NSDictionary *userInfo = notification.userInfo; NSURL *siteURL = [NSURL URLWithString:[userInfo objectForKey:@"SiteURLKey"]]; [[UIApplication sharedApplication] openURL:siteURL]; }