iOS 本地通知

iOS8以上 申请推送

  if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){
        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
    }
    else {
        [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge];
    }
    



 
    UILocalNotification* localNotification = [[UILocalNotification alloc] init];
    
    localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];  //30秒后推送
    localNotification.timeZone = [NSTimeZone localTimeZone];
    localNotification.userInfo = @{
                                   @"name":@"the Name",
                                   @"id":@"0",
                                   };
    localNotification.alertBody = @"alertBody";
    localNotification.alertTitle = @"title";
    
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; //注入系统

你可能感兴趣的:(iOS 本地通知)