I made a controller that inherit embedded cordova webview. And I created a custom plugin.
javascript call custom plugin method.
I want to access my controller that inherit embedded cordova webview in plugin method.
// MyPlugin.m
@import "MyPlugin.h"
@import "MyController.h"
@implementation myPlugin
- (void) myPluginMethod: (CDVInvokedUrlCommand *)command {
// How to access my controller that inherit embedded cordova webview in this.
}
In a regular plugin you can get the viewController with
self.viewController
But, as you are using an embedded cordova webview it might not work.
So, if it doesn't work you can always get the rootViewController like this:
UIViewController *vc = [[[UIApplication sharedApplication] keyWindow] rootViewController];
If you want to access the webView just use
self.webView