[英]NativeScript plugin crashes in external ng2 projects (not the demo)
有問題的插件是: https : //github.com/sean-perkins/nativescript-opentok/tree/delegate-exploration 。 如果您安裝npm並將構建版本設置為1.4.4
,則將獲得此錯誤的最新測試版本。
該插件遇到兩個問題:
首先,無法識別{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} 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.