'Agora Voice chat issue in android build from unity
This is my script which handles the voice chat, when I was building for windows it worked well but when the app is built for android it doesn't work, I think its probably because it doesn't get permission for using the mic in android but I passed a code for that even, I cant figure out what is the issue here.
If you could help me out it would be great. Thank you.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using agora_gaming_rtc;
using System;
using Photon.Pun;
using UnityEngine.Android;
using Hashtable = ExitGames.Client.Photon.Hashtable;
public class VoiceChatManager : MonoBehaviourPunCallbacks
{
string appID = "7768ab4a96174a22bcd8c383c4acd2db";
public static VoiceChatManager Instance;
IRtcEngine mrtcEngine;
void Awake()
{
if (Instance)
{
Destroy(gameObject);
}
else
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
}
void Start()
{
if (Permission.HasUserAuthorizedPermission(Permission.Microphone))
{
}
else
{
Permission.RequestUserPermission(Permission.Microphone);
}
if (string.IsNullOrEmpty(appID))
{
Debug.LogError("App ID not set in VoiceChatManager script");
return;
}
mrtcEngine = IRtcEngine.GetEngine(appID);
mrtcEngine.OnJoinChannelSuccess += OnJoinChannelSuccess;
mrtcEngine.OnLeaveChannel += OnLeaveChannel;
mrtcEngine.OnError += OnError;
mrtcEngine.EnableSoundPositionIndication(true);
}
void OnError(int error, string msg)
{
Debug.LogError("Error with Agora: " + msg);
}
void OnLeaveChannel(RtcStats stats)
{
Debug.Log("Left channel with duration " + stats.duration);
}
void OnJoinChannelSuccess(string channelName, uint uid, int elapsed)
{
Debug.Log("Joined channel " + channelName);
Hashtable hash = new Hashtable();
hash.Add("agoraID", uid.ToString());
PhotonNetwork.SetPlayerCustomProperties(hash);
}
public IRtcEngine GetRtcEngine()
{
return mrtcEngine;
}
public override void OnJoinedRoom()
{
mrtcEngine.JoinChannel(PhotonNetwork.CurrentRoom.Name);
}
public override void OnLeftRoom()
{
mrtcEngine.LeaveChannel();
}
void OnDestroy()
{
IRtcEngine.Destroy();
}
}
Solution 1:[1]
Error with Agora: UnityEngine.Debug:LogError (object) VoiceChatManager:OnError (int,string) (at Assets/Scripts/VoiceChatManager.cs:60) agora_gaming_rtc.IRtcEngine/<>c__DisplayClass283_0:b__0 () (at Assets/AgoraEngine/Scripts/AgoraGamingSDK/AgoraGamingRtcEngine.cs:4411) agora_gaming_rtc.AgoraCallbackQueue:Update () (at Assets/AgoraEngine/Scripts/AgoraGamingSDK/tools/AgoraCallbackQueue.cs:54)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gene Animate |
