繁体   English   中英

NativeScript插件在外部ng2项目(而非演示版)中崩溃

[英]NativeScript plugin crashes in external ng2 projects (not the demo)

有问题的插件是: https : //github.com/sean-perkins/nativescript-opentok/tree/delegate-exploration 如果您安装npm并将构建版本设置为1.4.4 ,则将获得此错误的最新测试版本。

该插件遇到两个问题:

  1. 首先,无法识别{N}的新构造函数声明样式,因此我不得不退回到老式的Class.alloc().initWith声明样式。 我相信这实际上可能与#2有关。

  2. 更新构造函数后,同一行代码将失败,并带有以下内容: [__NSCFNumber length]: unrecognized selector sent to instance 0xb00000002b879aa2

有问题的代码是:

public static initWithApiKeySessionIdToken(apiKey: string, sessionId: string, token:string): TNSOTSession {
        let instance = <TNSOTSession>TNSOTSession.new();
        instance.events = new Observable();
        instance.session = OTSession.alloc().initWithApiKeySessionIdDelegate(apiKey, sessionId, instance);
        let errorRef = new interop.Reference();
        instance.session.connectWithTokenError(token, errorRef);
        if(errorRef.value) {
            console.log(errorRef.value);
        }
        return instance;
    }

类( TNSOTSession )扩展了NSObject并为OTSessionDelegate实现了协议,该协议应根据{N} docs维护选择器实例:

“被重写的方法将从其实现的基类或协议中推断出其签名。”

参考: https : //docs.nativescript.org/runtimes/ios/how-to/ObjC-Subclassing

如果您需要查看OpenTok的iOS API文档,请参阅: https ://www.tokbox.com/developer/sdks/ios/reference/Classes/OTSession.html。

谢谢任何可以帮助我在这个问题上前进的人。 该演示非常完美。 该问题在{N} + Angular 2测试项目中找到。

对于遇到此问题的任何人,请确保如果您的插件具有数字API密钥或与此相关的任何值,则该字符串应为字符串...请务必使用.toString()将其转换为字符串。 我的整个问题集中在一个小细节上。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM