Sending photo from ShareExtension

When using SDK 3.1.7, and building a ShareExtension in Swift, when trying to send a photo using a code similar to:

        let file: Data = xxx    
        let params = SBDFileMessageParams(file: file)
        params?.mimeType = xxx
        if let params = params {
            sbChannel.sendFileMessage(with: params, completionHandler: { message, error in
                completionHandler(id, error)

I’m getting an error like this:

ShareExtension[xx:xxx] Task <xxx>.<1> finished with error [-995] Error Domain=NSURLErrorDomain Code=-995 "(null)" UserInfo={_NSURLErrorRelatedURLSessionTaskErrorKey=(
    "BackgroundUploadTask <xxx>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundUploadTask <xxx>.<1>}

sending a text message from the same environment works.

Is there a known issues for sending photos from a share extension?

also worth mentioning, when using the message with:

let params = SBDFileMessageParams(fileUrl: "")

would work, as well as sending the file message from the main app rather than the Share Extension

for anyone who might encounter this in the future, I’ve solved the problem by adding:

SBDMain.setSharedContainerIdentifier("<your app group key here>")
1 Like