Closed lovelyelfpop closed 4 years ago
hi @lovelyelfpop, I'm a little confused, in what way are you using this plugin?
InAppbrowser can not call cordova plugins' methods, so I use postMessage to cordova webview and let cordova webview to handle it
Can you share with me the code you have written so I can see what are you doing more clearly please?
Inside inappbrowser:
webkit.messageHandlers.cordova_iab.postMessage(JSON.stringify({
action: "openFile",
path: "file:///var/mobile/Applications/xxx-xxx-xxx-xxxx/Documents/1.docx"
}));
In cordova:
var ref = window.open('http://remote.site.page', '_blank', '');
ref.addEventListener('message', function (params) {
var data = params.data;
if (data.action== 'openFile') {
cordova.plugins.fileOpener2.open(
data.path,
null,
{
error : function(){ },
success : function(){ }
}
);
}
});
Use code below to find top most viewController and presentOptionsMenuFromRect
in it
- (UIViewController *)getPresentedViewController
{
UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
UIViewController *topVC = appRootVC;
if (topVC.presentedViewController) {
topVC = topVC.presentedViewController;
}
return topVC;
}
You shouldn't need to hack anything in Objective-C to achieve this. Use InAppBrowser.hide
function to hide the child window.
I use
webkit.messageHandlers.cordova_iab.postMessage
inside InAppBrowser to notify cordova webview to show file opener menu, but the menu shows behind the inappbrowser.