Comments (7)
hi @riverbaymark im not seeing you calling sendMessage api, did you miss that?
from agorartm_ios.
Sorry I left that code out int the above snippet. I call it from my SwiftUi view like below:
func sendData() { print(agoraChatOO.channel) agoraChatOO.channel?.send(AgoraRtmMessage(text: dataTextSending)){message in print(message) } }
agoraChatOO is the @StateObject view model for the AgoraObservable class.
from agorartm_ios.
@riverbaymark is there any chance you can provide the minimal reproducible project to me? it seems agoraChat00.channel? can potentially be nil? either you can put everything together or you may provide the reproducible project can help me solve your problem quicker.
from agorartm_ios.
Here is a shortened example of my view that utilizes the observable object above. I do check with the print statement in the sendData() function and the agoraChatOO.channel is not nil and is the same as when created in the observable object class.
import SwiftUI
import AgoraRtmKit
struct AgoraChatView: View {
@StateObject var agoraChatOO = AgoraObservable()
@State var dataTextSending: String = ""
@State var joinedChannel: Bool = false
func sendData() {
print(agoraChatOO.channel)
agoraChatOO.channel?.send(AgoraRtmMessage(text: dataTextSending)){message in
print(message)
}
}
var body: some View {
GeometryReader {
geometry in
VStack{
Button(action: {
joinedChannel.toggle()
if !joinedChannel {
self.agoraChatOO.members.removeAll()
self.agoraChatOO.rtckit.leaveChannel()
self.agoraChatOO.rtmkit?.logout()
self.agoraChatOO.rtmIsLoggedIn = false
} else {
self.agoraChatOO.joinChannel()
}
}, label: {
Text("\(joinedChannel ? "Leave" : "Join") Channel")
.accentColor(joinedChannel ? .red : .blue)
})
HStack {
TextField("Message", text: $dataTextSending)
.padding()
.textFieldStyle(RoundedBorderTextFieldStyle())
Spacer()
Button(action: {
self.sendData()
dataTextSending = ""
}) {
Text("Send")
.padding(8)
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(8)
}
}.navigationBarTitle("RadChat")
}
}
}
}
struct AgoraChatView_Previews: PreviewProvider {
static var previews: some View {
AgoraChatView(agoraChatOO: AgoraObservable())
}
}
from agorartm_ios.
@riverbaymark can you listen to the connectionStateChange callback and see what you get for both users?
from agorartm_ios.
@riverbaymark are the two users logging in with the same rtmId of "test"? They cannot both be the same value.
I usually use UIDevice.current.identifierForVendor?.uuidString
. Note that it will be extremely unlikely to be nil
, but add a fallback random UUID just in case.
from agorartm_ios.
I think this issue was solved by changing the RTM ID.
from agorartm_ios.
Related Issues (9)
- When use SPM it not work... HOT 2
- Xcode targets iOS 9 as min version in target range, yet package still targets iOS 8 HOT 1
- Could not build for arm64. HOT 5
- Not able to login via SwiftUI app HOT 2
- Can't build for iOS Simulator on M1 HOT 2
- 1.5.1 is using openSSL v1.1.1h that vulnerable to CVE-2023-0286
- Missing visionOS support for SPM HOT 3
- Privacy Manifest HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from agorartm_ios.