extension AppDelegate : UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
print("userNotificationCenter-UNNotificationPresentationOptions")
Messaging.messaging().appDidReceiveMessage(userInfo)
if let messageID = userInfo[gcmMessageIDKey] {
print("Message ID: \(messageID)")
}
print(userInfo)
AudioServicesPlaySystemSound(1016)
completionHandler([.alert,.badge])
}
如果播放FCM推送前台音频
但在后台没有播放音频
如何玩
AudioServicesPlaySystemSound
或
AudioServicesPlayAlertSound
在后台
已检查功能背景模式
Swift 4,iOS 11