Stack Overflow Asked by 9to5ios on December 18, 2021
how I get public room in swift4.X and above using Matrix SDK for ios
this line mxSession.start { response in //give error –> **Cannot invoke 'start' with an argument list of type '(@escaping (MXResponse<Void>) -> Void)'**
let credentials = MXCredentials(homeServer: "http://matrix.org",
userId: "@your_user_id:matrix.org",
accessToken: "your_access_token")
// Create a matrix client
let mxRestClient = MXRestClient(credentials: credentials, unrecognizedCertificateHandler: nil)
// Create a matrix session
let mxSession = MXSession(matrixRestClient: mxRestClient)
// Launch mxSession: it will first make an initial sync with the homeserver
mxSession.start { response in
guard response.isSuccess else { return }
// mxSession is ready to be used
// now wer can get all rooms with:
mxSession.rooms
}
Can you someone explain me how to make upload and download mediaFiles with this SDK. Ok i read documentation but i don't understand a lot of it. I make seasion in room and what to do next, where and how to make upload with userA and download from userB. I wrote Swift 5
Answered by Ivan Jovanovik on December 18, 2021
SwiftMatrixSDK
requires Swift 5.0. Check the SwiftMatrixSDK.podspec:
s.swift_version = '5.0'
Based on this comment ...
This swift layer was brought by the community. The matrix core team runs projects in Obj-C so that maintaining this pod is not in our priorities at the moment.
... I wouldn't expect that they will be maintaining Swift 4 compatibility as well since the Swift 5 is with us for more than one year. But I can't speak for them, it's just my assumption.
Your example is clearly a copy & paste from the README and it doesn't work even with Swift 5. The MXSession
initializer is fallible and you have to use:
guard
for the let mxSession
ormxSession?.start
, mxSession?.rooms
The following code compiles fine with Swift 5:
import SwiftMatrixSDK
func doSomethingWithRooms() {
let credentials = MXCredentials(homeServer: "http://matrix.org",
userId: "@your_user_id:matrix.org",
accessToken: "your_access_token")
// Create a matrix client
let mxRestClient = MXRestClient(credentials: credentials, unrecognizedCertificateHandler: nil)
// Create a matrix session
guard let mxSession = MXSession(matrixRestClient: mxRestClient) else { return }
// Launch mxSession: it will first make an initial sync with the homeserver
mxSession.start { response in
guard response.isSuccess else { return }
// mxSession is ready to be used
// now wer can get all rooms with:
let rooms = mxSession.rooms
}
}
I would say that you should fill an issue (question) and ask there or switch to Swift 5.
The project migrated to Swift 5 in the v0.13.0
version. Check the release notes:
SwiftMatrixSDK: Migrate to Swift 5.0.
Theoretically, the previous version (v0.12.5) should work with Swift 4. Should work means that you should be able to compile it, but it will lack quite a lot of features and bug fixes, because this version was released on May 3, 2019.
Answered by zrzka on December 18, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP