Giter Site home page Giter Site logo

Comments (7)

plutoless avatar plutoless commented on September 24, 2024 1

hi @riverbaymark im not seeing you calling sendMessage api, did you miss that?

from agorartm_ios.

riverbaymark avatar riverbaymark commented on September 24, 2024

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.

plutoless avatar plutoless commented on September 24, 2024

@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.

riverbaymark avatar riverbaymark commented on September 24, 2024

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.

plutoless avatar plutoless commented on September 24, 2024

@riverbaymark can you listen to the connectionStateChange callback and see what you get for both users?

from agorartm_ios.

maxxfrazer avatar maxxfrazer commented on September 24, 2024

@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.

maxxfrazer avatar maxxfrazer commented on September 24, 2024

I think this issue was solved by changing the RTM ID.

from agorartm_ios.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.