cordova-plugin-safariviewcontroller icon indicating copy to clipboard operation
cordova-plugin-safariviewcontroller copied to clipboard

SafariViewController throws NSInvalidArgumentException and crashes app

Open woodi3 opened this issue 7 years ago • 3 comments

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:

screen shot 2018-02-23 at 4 44 37 pm

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.

screen shot 2018-02-23 at 4 38 01 pm

  • 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

woodi3 avatar Feb 23 '18 21:02 woodi3

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).

kiontupper avatar Apr 14 '18 17:04 kiontupper

@tupperkion I’ll try that!

woodi3 avatar Apr 14 '18 22:04 woodi3

screen shot 2018-04-14 at 6 26 35 pm

@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.

woodi3 avatar Apr 14 '18 22:04 woodi3