bradmartin / nativescript-advanced-webview

NativeScript plugin for Chrome CustomTabs on Android and SafariViewController on iOS.
Other
60 stars 28 forks source link

'error' [TypeError: null is not an object (evaluating 'app.keyWindow')] #41

Closed bnowacky closed 5 years ago

bnowacky commented 6 years ago

Using Nativescript-vue. 4.2.3

In our main.js file, we're calling:

const AdvancedWebView = require("nativescript-advanced-webview");
AdvancedWebView.init();

in our vue component, we're calling:

var opts = {
        url: 'https://google.com',
};

try {
      AdvancedWebView.openAdvancedUrl(opts);
 } catch(err) {
      console.log('error', err);
 }

Unfortunately though, we are getting the error noted above: 'error' [TypeError: null is not an object (evaluating 'app.keyWindow')]

We know the openAdvancedURL() method is being called, because if we leave the opts.url blank, we get the appropriate error.

any ideas on what we're missing?

bradmartin commented 6 years ago

Only instance of keyWindow in repo here https://github.com/bradmartin/nativescript-advanced-webview/blob/92ab8d454ec1439d86f9a7f6c3581bc31bd9ac7f/src/advanced-webview.ios.ts#L57 not sure why that happens. Leaving for reference 👍

bnowacky commented 6 years ago

Yup... Saw that as well, and we logged values to see where we died before that.

console.log('utils', utils);
console.log('utils.ios', utils.ios);
console.log('thewholething', utils.ios.getter(UIApplication, UIApplication.sharedApplication));

utils.ios.getter() returns null , so app is null, which is why it's erring I believe.

FWIW, we're running on iOS 12. but we've tried on 11 as well with no luck. Not something you've experienced before?

bradmartin commented 5 years ago

Never seen that and demo app runs fine. I added a check on the keyWindow and published 3.0.2, see if that helps clean things up and let me know.