插件問題是:https://github.com/sean-perkins/nativescript-opentok/tree/delegate-exploration。如果你使用npm安裝並將版本版本設置爲1.4.4
,你將得到這個bug的最新測試版本。NativeScript插件在外部ng2項目中崩潰(不是演示)
插件遇到兩個問題:
起初,新構造函數聲明樣式{N}無法識別,所以我要回退的老派
Class.alloc().initWith
聲明風格。我相信這實際上可能與#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}文檔:
「被覆蓋的方法將根據它們實現的基類或協議推斷它們的簽名。」
編號: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測試項目中找到。