Basic-Audio-Call icon indicating copy to clipboard operation
Basic-Audio-Call copied to clipboard

Web users can't hear ios users, but ios users can hear web users.

Open dzziwny opened this issue 3 years ago • 13 comments

Describe the bug I have implemented agora sdk into web, using capacitorjs framework. It works fine on all devices browsers, like ios safari, android chrome, desktops etc. It also works fine on android WebView. There appeard problem on ios. In docs is written that there must be a native implementation for ios. I used sample from official agora documentation (https://github.com/AgoraIO/Basic-Audio-Call/tree/master/Group-Voice-Call/OpenVoiceCall-iOS) and it looks that ios users hear everyone else, but nobody hear ios users. What did i wrong? Is there any additional magic setting? I tested on ios 13.

Here is piece of code from my private app, where ios behavior is the same

import Foundation
import Capacitor
import AgoraRtcKit

@objc(AgoraIos)
public class AgoraIos: CAPPlugin {

    var agoraKit: AgoraRtcEngineKit!

    @objc func initialize(_ call: CAPPluginCall) {
      let appId = call.getString("appId");
      agoraKit = AgoraRtcEngineKit.sharedEngine(withAppId: appId, delegate: nil);
      call.resolve();
    }

    @objc func join(_ call: CAPPluginCall) {
        let channelName = call.getString("channelName");
        let userId = call.getString("userId");
        agoraKit.joinChannel(byToken: nil, channelId: channelName, info:nil, uid: userId) {[unowned self] (sid, uid, elapsed) -> Void in
            self.agoraKit.setEnableSpeakerphone(true);
            call.resolve();
        }
    }

    @objc func leave(_ call: CAPPluginCall) {
        agoraKit.leaveChannel(nil);
        call.resolve();
    }

    @objc func talk(_ call: CAPPluginCall) {
        agoraKit.muteLocalAudioStream(true);
        call.resolve();
    }

    @objc func mute(_ call: CAPPluginCall) {
        agoraKit.muteLocalAudioStream(false);
        call.resolve();
    }
}

To Reproduce Steps to reproduce the behavior:

  1. Just download code from this repo and run to connect with others.

Expected behavior It should work like web implementation.

Smartphone (please complete the following information):

  • Device: iphone 6s
  • OS: ios
  • Version 3.1.2

dzziwny avatar Oct 05 '20 19:10 dzziwny

@dzziwny sorry for late reply. could you pls share the channel name you used for testing?

plutoless avatar Oct 15 '20 04:10 plutoless

It's just 'test'. Today I am going to create a sample app and share on issue page.

On Thu, Oct 15, 2020, 6:21 AM Qianze Zhang [email protected] wrote:

@dzziwny https://github.com/dzziwny sorry for late reply. could you pls share the channel name you used for testing?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AgoraIO/Basic-Audio-Call/issues/25#issuecomment-708887476, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRFY67WFHETEOKWJFQPHX3SKZ2FBANCNFSM4SFB7W5Q .

dzziwny avatar Oct 15 '20 06:10 dzziwny

I created separated repo for agora plugin wrapper for capacitorjs. There is a sample app with bug - https://github.com/dzziwny/capacitor-agora-sdk/tree/master/sample

dzziwny avatar Oct 15 '20 20:10 dzziwny

@dzziwny try calling setChannelProfile to make the channel profile livebroadcasting. then call setClientRole to make yourself a broadcaster and see if it's now working for you. btw "test" is a too common name, i'm trying to look for your channel in our backend, it would be helpful if you can provide test in a channel which has more unique name.

plutoless avatar Oct 17 '20 17:10 plutoless

@plutoless thank for help, I have added your suggestions, now i have such error - 2020-10-29 19:45:30.216484+0000 App[1331:353091] [Client] Updating selectors after delegate removal failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 87 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service on pid 87 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}. Channel name was Thursday29102020. Here is the sample app https://github.com/dzziwny/capacitor-agora-sdk/tree/master/sample

dzziwny avatar Nov 02 '20 16:11 dzziwny

@dzziwny hi, i did a test using your app and it's working fine. are you sure you have successfully joined the channel at all?

plutoless avatar Nov 09 '20 16:11 plutoless

btw i tested using web -> click JOIN CHANNEL -> make myself muted, using iOS -> click JOIN CHANNEL -> click TALK, and web can hear iOS

plutoless avatar Nov 09 '20 16:11 plutoless

i did a search using "Thursday29102020" and failed to find a channel. I believe you failed to join the channel somehow. please check your join channel callback, and whether you have turned on token but failed to provide a valid one.

plutoless avatar Nov 09 '20 16:11 plutoless

btw i tested using web -> click JOIN CHANNEL -> make myself muted, using iOS -> click JOIN CHANNEL -> click TALK, and web can hear iOS

Did you check on ios native app or safari on ios?

dzziwny avatar Nov 09 '20 18:11 dzziwny

@dzziwny i checked on ios native app using your instructions on readme.

plutoless avatar Nov 10 '20 05:11 plutoless

by running this npx cap add ios npx cap open ios + run from XCode

plutoless avatar Nov 10 '20 05:11 plutoless

Hi @plutoless,

I didn't test example project yet, but as an iOS developer, after reading example code, I think you forgot ask permission to use microphone. Please try below code to require microphone's permission:

AVAudioSession.sharedInstance().requestRecordPermission { (success) in
    print(success)
}

tuannguyenanh177 avatar Nov 13 '20 13:11 tuannguyenanh177

@tuannguyenanh177 thanks, i am going to make up asking for mic permission. it seams that @plutoless is right, i was creating token in a wrong way.

thank you guys, i think we can close the ticket.

dzziwny avatar Nov 13 '20 13:11 dzziwny