首页 > 解决方案 > Ionic Cordova OpenTok 无法从 IOS 发布视频

问题描述

我正在尝试在离子应用程序上实现 OpenTok,但我无法从 iphone 发布视频。从视频订阅工作(我可以在我的计算机上运行该应用程序并发布一个视频,我可以在我的 iphone 上看到),但反之亦然它不起作用。

我的 config.xml 中有以下设置

        <config-file parent="NSCameraUsageDescription" target="*-Info.plist">
            <string>This app needs to access your camera in order to take a profile photo or save a photo in the files or messages section.</string>
        </config-file>
        <config-file parent="NSMicrophoneUsageDescription" target="*-Info.plist">
            <string>This app needs to access your microphone in order to record videos that you can upload in the files or messages section.</string>
        </config-file>

而且,我正在使用这段代码:

    startCall() {
        this.session = OT.initSession(this.apiKey, this.sessionId);
        this.publisher = OT.initPublisher('publisher');

        this.session.on({
            streamCreated: (event: any) => {
                this.session.subscribe(event.stream, 'subscriber');
                OT.updateViews();
            },
            streamDestroyed: (event: any) => {
                console.log(`Stream ${event.stream.name} ended because ${event.reason}`);
                OT.updateViews();
            },
            sessionConnected: (event: any) => {
                this.session.publish(this.publisher);
            }
        });

        this.session.connect(this.token, (error: any) => {
            if (error) {
                console.log(`There was an error connecting to the session ${error}`);
            }
        });
    }

我添加了一些console.logs,它进入了session.on sessionConnected和session.connect,没有其​​他错误,所以我不明白会发生什么

谢谢

标签: ioscordovaionic-frameworkwebrtcopentok

解决方案


这是因为 cordova openTok 插件与最新的 iOS SDK 不同步,它指向 2.15.5,但最新的是 2.17.4。所以你可以尝试指向版本。为了快速测试,我更新了插件,您可以测试它是否适合您。您可以像在 config.xml 中一样添加插件

<plugin name="cordova-plugin-opentok" spec="github:neerajpathak77/cordova-plugin-opentok" />

这将导致 package.json 中的以下内容

"cordova-plugin-opentok": "github:neerajpathak77/cordova-plugin-opentok",

现在,这应该适合你。

您可以尝试测试的另一种方法是您可以在 Xcode 中打开 YourProject.xcworkspace 文件,然后打开 Podfile 文件并将以下行添加到 pod 文件中(注意:我们正在更改生成的文件,因此每次运行 cordova platform add ios这些更改将消失)

pod 'OpenTok 2.17.0'

然后运行命令

pod install

如果发生错误,请将目标更改为 pod 文件中的最新目标

platform :ios, '13.0'

希望能帮助到你


推荐阅读