0
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])
    }

if fcm push send in foreGround Audio is play

but in backGround not played audio

how to play AudioServicesPlaySystemSound or AudioServicesPlayAlertSound in background Capabilities Background Modes already Checked

Swift 4 , iOS 11

Adam
  • 325
  • 1
  • 4
  • 20

1 Answers1

0

You have to set up the background mode for play audio, to be able to do this. It's described in detail in this answer iOS background audio not playing.

enter image description here

Martin Prusa
  • 201
  • 1
  • 5