关于iOS8上本地通知接收不到的问题

补充一下:

本地推送线上的项目没事,我这测试了6 plus xcode创建的项目正常。如果是新xcode创建的项目的ios8不行,需要加新方法

//注册本地通知

    if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){

        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];

    }



需要手动加上这句话 

if ([UIApplicationinstancesRespondToSelector:@selector(registerUserNotificationSettings:)]){

        [[UIApplicationsharedApplication] registerUserNotificationSettings:[UIUserNotificationSettingssettingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSoundcategories:nil]];

    }

    

    UILocalNotification *alarm = [[UILocalNotificationalloc] init];

    if (alarm)

    {

        NSDate *now = [NSDatedateWithTimeIntervalSinceNow:10];

        alarm.fireDate = now;

        alarm.timeZone = [NSTimeZonedefaultTimeZone];

        alarm.repeatInterval = NSCalendarUnitDay;

        alarm.soundName = @"LocalAlarm.caf";

        alarm.applicationIconBadgeNumber =1;

        alarm.alertAction = @"电池管家";

        alarm.alertBody = @"事件闹铃";

        NSDictionary *infoDic = [NSDictionarydictionaryWithObject:@"alarmLocalNotificationName"forKey:@"alarmLocalNotificationKey"];

        alarm.userInfo = infoDic;

        [[UIApplicationsharedApplication] scheduleLocalNotification:alarm];

    }

你可能感兴趣的:(关于iOS8上本地通知接收不到的问题)