extension AppDelegate : UNUserNotificationCenterDelegate {
// Receive displayed notifications for iOS 10 devices.
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
print("userNotificationCenter-UNNotificationPresentationOptions")
// With swizzling disabled you must let Messaging know about the message, for Analytics
Messaging.messaging().appDidReceiveMessage(userInfo)
if let messageID = userInfo[gcmMessageIDKey] {
print("Message ID: \(messageID)")
}
// Print full message.
print(userInfo)
// Change this to your preferred presentation option
// AudioServicesPlayAlertSound(1016)
AudioServicesPlaySystemSound(1016)
completionHandler([.alert,.badge])
}
если отправка fcm push в foreGround Звук воспроизводится
но в backGround не воспроизводится звук
как играть AudioServicesPlaySystemSound
или AudioServicesPlayAlertSound
в фоновом режиме
Возможности фоновых режимов уже проверены
Swift 4, iOS 11