我在Ionic 3.9.2中实现RTCMultiConnection(流音频)存在问题。与Android版本不同,在Android版本上一切正常,IOS应用程序只能以一种方式运行-当用户连接到现有的流应用程序时,它会从中接收音频。如果用户启动新的流,则没有任何效果,甚至缺少要求麦克风权限的弹出窗口。终端不显示任何错误。你们中有人遇到过这样的问题吗?
我还实现了此插件 https://github.com/BasqueVoIPMafia/cordova-plugin-iosrtc/blob/master/docs/Building.md
[index.html]
<body>
<script src="https://rtcmulticonnection.herokuapp.com/dist/RTCMultiConnection.min.js"></script>
<script src="https://rtcmulticonnection.herokuapp.com/socket.io/socket.io.js"></script>
<script>
document.addEventListener("deviceready", function() {
if ((typeof device !== "undefined") && device.platform == 'iOS'){
cordova.plugins.iosrtc.registerGlobals();
}
}, false);
</script>
</body>
[home.ts]
constructor(public navCtrl: NavController, private platform: Platform) {
}
clickBtn(){
this.requestPermissions().then(() => {
this.createConnection();
});
}
createConnection() {
const RTCMultiConnection = window['RTCMultiConnection'];
const connection = new RTCMultiConnection();
connection.socketURL = 'https://apilink:9001/';
connection.socketMessageEvent = 'RTC-audio';
connection.session = {audio: true, video: false, oneway: true};
connection.bandwidth = {audio: 64};
connection.sdpConstraints.mandatory = {OfferToReceiveAudio: true,OfferToReceiveVideo: false};
connection.iceServers.push({
urls: 'turn:217.182.77.219:3478',
credential: 'credential_password',
username: 'rtc_username'
});
connection.onPeerStateChanged = this.onPeerStateChanged;
connection.onleave = this.onleave;
connection.onstream = this.onstream;
connection.onstreamended = this.onstreamended;
connection.onRoomFull = this.onRoomFull;
connection.onMediaError = this.onMediaError;
connection.openOrJoin('Channel12345');
}
onPeerStateChanged = event => {
console.log('onPeerStateChanged', event);
}
onleave = event => {
console.log('onleave', event);
}
onstream = event => {
console.log('onstream', event);
}
onstreamended = event => {
console.log('onstreamended', event);
}
onRoomFull = event => {
console.log('onRoomFull', event);
}
onMediaError = event => {
console.log('onMediaError', event);
}
requestPermissions() {
if(!this.platform.is('cordova'))
return Promise.reject('not cordova');
if (this.platform.is('android')) {
return this.requestAndroidPermissions();
}
else if (this.platform.is('ios')) {
console.log("PLATFORM IOS")
return Promise.resolve(true)
}
}
requestAndroidPermissions() {
return new Promise((resolve, reject) => {
const {permissions} = window['cordova'].plugins;
permissions.requestPermissions([
permissions.CAMERA,
permissions.MICROPHONE,
permissions.MODIFY_AUDIO_SETTINGS,
permissions.RECORD_AUDIO,
permissions.ACCESS_NETWORK_STATE,
permissions.ACCESS_WIFI_STATE
],
ok => resolve(ok),
error => reject(error)
);
})
}
}
config.xml
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="*" />
<allow-intent href="itms-apps:*" />
<hook src="hooks/iosrtc-swift-support.js" type="after_platform_add" />
<preference name="ios-XCBuildConfiguration-ENABLE_BITCODE" value="NO" />
<config-file parent="NSMicrophoneUsageDescription" target="*-Info.plist">
<string>App uses your microphone to make calls.</string>
</config-file>
<config-file parent="NSCameraUsageDescription" target="*-Info.plist">
<string>App uses your camera to make video calls.</string>
</config-file>
...
</platform>
我想增加在IOS上启动新流的功能,因为现在它不起作用。