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

Hi,

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 = ("https://abc.co.uk/image.jpg")

}

 

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

Comments

2 comments

  • 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: https://docs.airship.com/api/ua/#schema-tag-platform-overrides-extra

    Thank you,

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

     

    0
  • 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?

    Matt

    0

Please sign in to leave a comment.