chat-sdk / chat-sdk-ios

Chat SDK iOS - Open Source Mobile Messenger
http://sdk.chat
Other
913 stars 276 forks source link

Uploading file using the sdk missing document #489

Closed ahmadrushdie closed 2 years ago

ahmadrushdie commented 2 years ago

i am trying to upload file after seclect from UIDocumentPickerViewController the picker return list of URL so i take the url and i am trying to convert it to [AnyHashable : Any] in order to accept by sendMessage any recommendation about which data should i pass in dectionary

BChatSDK.fileMessage()?.sendMessage(withFile:[AnyHashable : Any] , andThreadEntityID: threadEnitty).then({ result in

        DispatchQueue.main.async {
            self.loadChatMessages()
        }

    }, { error in
        if let error = error {
        }
        return nil
    })
}
bensmiley commented 2 years ago

Is this a bug?

ahmadrushdie commented 2 years ago

for me Yes because the poor documentation of the SDK BChatSDK.fileMessage()?.sendMessage ask for Dectionary and i didnt fine any documentation about which data should i pass inside dectionary

ahmadrushdie commented 2 years ago

@bensmiley i update the description the issue that i am unable to figure which data should be pass to sendMessage for file

bensmiley commented 2 years ago

This method isn't documented because it's a semi-private API. But if you want to send your own file, you can do it like this:

NSURL * localURL = file[bFilePath];
NSData * data = file[bFileData];
NSString * fileName = file[bFileName];
NSString * mimeType = file[bFileMimeType];

Here are the keys you need to set.

#define bFilePath @"file-path"
#define bFileData @"file-data"
#define bFileName @"file-name"
#define bFileMimeType @"file-mime-type"

You will also need the FileMessageModule to be enabled.

https://chat-sdk.gitbook.io/chat-sdk/commercial/module-licensing

I've also added this information to the PFileMessageHandler.h protocol for future reference.

ahmadrushdie commented 2 years ago

i already buy the file message module but where i can find the pod for the module?

bensmiley commented 2 years ago

Can you email me your license confirmation or tell me the email address you used to buy it? to: team@sdk.chat