Ios8 ios 8 UILocalNotification丢失,仅声音
我在应用程序中安排本地通知,如下所示:Ios8 ios 8 UILocalNotification丢失,仅声音,ios8,uilocalnotification,Ios8,Uilocalnotification,我在应用程序中安排本地通知,如下所示: UILocalNotification * notification = [UILocalNotification new]; notification.applicationIconBadgeNumber = 1; notification.repeatInterval = NSCalendarUnitMinute; notification.fireDate = date; notification.timeZone = DEFAULT_TIME_ZO
UILocalNotification * notification = [UILocalNotification new];
notification.applicationIconBadgeNumber = 1;
notification.repeatInterval = NSCalendarUnitMinute;
notification.fireDate = date;
notification.timeZone = DEFAULT_TIME_ZONE;
notification.alertBody = alertBody;
notification.alertAction = @"View";
notification.soundName = @"my_sound";
notification.userInfo = userInfoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
在最新版本的ios 8 gm上,我可以听到通知的声音,但是没有警报,通知中心没有消息等等。
我加入了
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions:
....
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
//ios 8
UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:
UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound
categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
}
但是用户在第一次运行时不会发出请求权限的警报