Change push notification sound in code: iOS

Viewed 121

I would like to change some parameters of Push Notification without changing payload from backend side.

So the app receives a push notification:

{
    "Simulator Target Bundle": "com.test.iphone.driver.test",
    "aps":{
        "alert":"This is Alert.",
        "sound":"default"
    }
}

But I need to change sound in code to "custom.mp3" before performing notification. It should be done in this method: willPresent notification before calling completion handler

func userNotificationCenter( _ center: UNUserNotificationCenter,
        willPresent notification: UNNotification,
        withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
      ) {
       completionHandler([.banner, .sound]) 
}

Is it possible?

0 Answers
Related