我在Cordova
應用程序中創建了自定義(CDVPlugin
)插件。如何從我的自定義CDVPlugin類(Objective C語言)調用JavaScript函數
通過該插件,如果JavaScript文件調用它在CDVPlugin
聲明的話,我可以很容易地通過
CDVPluginResult *pluginResult = nil;
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[NSString stringWithFormat:@"%@",deviceUUIDString]];
self.delegateCallbackId=command.callbackId;
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
但如何從我的自定義CDVPlugin類調用JavaScript函數發送響應的方法。
感謝您的幫助,但我想這樣'的NSString * jsfunctioncall = [NSString的〜應變gWithFormat:@ 「callCustomMethodJs()」]; viewController = [[CDVViewController alloc ] init]; [viewController.webViewEngine evaluateJavaScript:jsfunctioncall completionHandler:nil];' 沒有成功 –
不要創建CDVViewController的對象.CDVPlugin具有屬性webViewEngine和webView.You可以使用該屬性調用.JS需要首先加載才能使用「 evaluateJavaScript「。發佈您的更新代碼問題,即你在哪裏寫這個code.It可能會有所幫助。 – sanman
謝謝你的幫助我找到答案附近的答案只... –