2016-08-31 34 views
0

插件問題是:https://github.com/sean-perkins/nativescript-opentok/tree/delegate-exploration。如果你使用npm安裝並將版本版本設置爲1.4.4,你將得到這個bug的最新測試版本。NativeScript插件在外部ng2項目中崩潰(不是演示)

插件遇到兩個問題:

  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}文檔:

「被覆蓋的方法將根據它們實現的基類或協議推斷它們的簽名。」

編號: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測試項目中找到。

回答

1

對於遇到這個問題的任何人,請確保如果你的插件有一個數字API鍵或任何值的話,這應該是一個字符串...一定要把它作爲字符串強制轉換爲.toString() 。我的整個問題都圍繞着這個小小的細節。