-(void)addNotification{ // 创建一个本地推送 UILocalNotification *notification = [[[UILocalNotification alloc] init] autorelease]; //设置10秒之后 NSDate *pushDate = [NSDate dateWithTimeIntervalSinceNow:10]; if (notification != nil) { // 设置推送时间 notification.fireDate = pushDate; // 设置时区 notification.timeZone = [NSTimeZone defaultTimeZone]; // 设置重复间隔 notification.repeatInterval = kCFCalendarUnitDay; // 推送声音 notification.soundName = UILocalNotificationDefaultSoundName; // 推送内容 notification.alertBody = @"推送内容"; //显示在icon上的红色圈中的数子 notification.applicationIconBadgeNumber = 1; //设置userinfo 方便在之后需要撤销的时候使用 NSDictionary *info =[[NSDictionary alloc]initWithObjectsAndKeys:@"呵呵你好",@"name",[[NSString alloc]initWithFormat:@"%d",purchaseId],@"id", nil]; // [NSDictionary dictionaryWithObject:@"呵呵你好" forKey:@"name"]; // [info dictionaryWithObject:[[NSString alloc]initWithFormat:@"%d",purchaseId] forKey:@"id"]; notification.userInfo = info; //添加推送到UIApplication UIApplication *app = [UIApplication sharedApplication]; [app scheduleLocalNotification:notification]; } }