cordova-plugin-safariviewcontroller
cordova-plugin-safariviewcontroller copied to clipboard
SafariViewController throws NSInvalidArgumentException and crashes app
Testing on iOS, device nor simulators work:
- Browser works sometimes but then others, it says the NSString* urlString is NSNull in the SafariViewController.m show() function. Most of the url's are youtube video urls.
This 'if' statement appears to be throwing the error with [urlString lowercaseString] part:
The url is defined (prefixed with https) and doesn't appear to be the issue.
- Here's the output in XCode:
I don't know where the first 'null' output comes from.
- Ionic info:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.1
ionic (Ionic CLI) : 3.19.1
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.0.1
Cordova Platforms : android 6.3.0 ios 4.5.4
Ionic Framework : ionic-angular 3.8.0
System:
Android SDK Tools : 26.0.2
ios-deploy : 1.9.2
Node : v8.6.0
npm : 5.6.0
OS : macOS Sierra
Xcode : Xcode 9.2 Build version 9C40b
Environment Variables:
ANDROID_HOME : /Users/alexwood/Library/Android/sdk
Misc:
backend : pro
I was having this issue before. Turns out I was passing a string as the first argument to show()
and not an object. Make sure you pass an object with a string as url
. (at least that's what fixed it for me).
@tupperkion I’ll try that!
@tupperkion this is the code I was using. The "url" isn't null. The plugin works in other apps I've done. I think the issue is, I am binding "onclick" functions to all anchor tags thru the dom (for this app I'm pulling HTML thru an api and can't touch it myself) and this code resides in the onclick function. When I log the "url" variable, it's present. The setTimeout was something a different user tried and worked for them <- Didn't work for me, hence me creating the issue.