【发布时间】:2014-11-12 22:24:41
【问题描述】:
我的应用需要有一些闹钟功能。
其中之一应该是在 LocalNotification 触发并且应用程序处于后台时让手机播放声音。
在 iOS 7.1 中一切正常,但在 iOS8 中,在应用返回前台之前不再播放声音。
目前我正在使用AudioToolbox/AudioServices.h 类。
我该如何解决这个问题?
【问题讨论】:
-
您是否使用
registerUserNotificationSettings注册本地通知。 -
@Bhumit:是的,这样:` if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) { [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeSound|UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIRemoteNotificationTypeSound categories:nil ]];}`
-
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{ if (notificationSettings.types == UIUserNotificationTypeNone) { NSLog(@"Denied"); } else{ NSLog(@"Granted"); } }
-
您确认您在委托回调中被授予使用上述方法的权限?
-
@Bhumit:我也确实在后台模式下进行了检查 -> 检查:模式:音频和 AirPlay 并对 app.plist 进行了设置
标签: ios objective-c uilocalnotification avplayer