Getting access to the URL within the media_attachment payload via iOS Swift


I have a Swift application that plugs into Airship SDK 14 and its all working well (including the rich push notification pull back etc...) Its also implemented with a overriding UAPushNotificationDelegate (based on the one within the SWIFT Xcode example) so when it receives a background notification - it can prompt the user with an alert within the app controlled in the receivedNotificationResponse function.

I need to get the URL of the media attachment from the payload (I can see its within notificationContent.notificationInfo - based on the example again from the Swift sample) and I while I can step through the NSDictionary (Hashable: Any) to see the key / values = I cannot grab the URL is coming back. I cannot access it or pull it out of the payload to use it within the alert . I need to get the URL of the image attached to the push notification message under 'com.urbanairship.media_attachment' so I can display the image on the alert that is popping up to the user.

I cannot find any examples, code files etc... or any example within the swift code samples to help unfortuntely. (it really urgent now). I have tried writing my own function to read NotificationInfo but because the URL comes back in the payload in a non JSON / data format it cannot read it. I am seeing it come back as:

com.urbanairship.media_attachment {

url = ("")



in summary - what is the best way (swift code example would really helpful within the receivedNotificationResponse function) in getting the URL of the media_attachment within the payload for SWIFT 5?

Didn't find what you were looking for?

New post



  • Stuart,

    I think the best way to solve your issue is by using the extra object in your push payload. The extra payload allows you to pass key/value data that you can access:

    Thank you,

    Eric L.
    Technical Support Engineer
    Airship Group | Apptimize | Portland 


    Comment actions Permalink
  • Hi Eric,

    Thank you for your feedback and your help. Does doing that mean when someone creates a new message on Airship - they will need to supply the JSON within the Extra options tag each time and there is no way to pull back the URL for the media attachment within the SDK on iOS?


    Comment actions Permalink
  • If you're working with push notifications on iOS using Swift and you want to access the URL within the media_attachment payload, you would typically handle this in the UNNotificationServiceExtension Bengal Cat Diet. The UNNotificationServiceExtension allows you to modify the content of a remote notification before it is presented to the user. Here's a general guide on how you might achieve this:

    Comment actions Permalink
  • Access the URL within the media_attachment payload effortlessly with guidance from Dubai Mall timing. Our expert team provides specialized support for iOS Swift development, ensuring seamless integration of media attachments into your app. Whether you're retrieving images, videos, or other media files, we offer solutions to help you access the URL efficiently. Trust Dubai Mall timing to assist you in navigating Swift development and enhancing the functionality of your iOS app.

    Comment actions Permalink

Please sign in to leave a comment.