ohh2ahh / AppAvailability

This Cordova / PhoneGap plugin allows you to check if an app is installed.
229 stars 117 forks source link

checkAvailability crashes with empty scheme #52

Closed pke closed 5 years ago

pke commented 6 years ago

line 12 in AppAvailability.m crashes if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scheme]]) with 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance. Instead it should set the pluginResult to false if there is no scheme specified. I remember the app working before, and since this plugin has not changed, I suspect now that the iOS implementation for canOpenURL might have changed an no longer accepting NSNull.

We ran into this situation since we just forward an API sent scheme to the function and the server sent no value down (or an empty string).

gravyplaya commented 5 years ago

line 12 in AppAvailability.m crashes if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scheme]]) with 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance. Instead it should set the pluginResult to false if there is no scheme specified. I remember the app working before, and since this plugin has not changed, I suspect now that the iOS implementation for canOpenURL might have changed an no longer accepting NSNull.

We ran into this situation since we just forward an API sent scheme to the function and the server sent no value down (or an empty string).

Has this been tested to work? If so it would be easy to fork this repo and make that fix.

pke commented 5 years ago

I think we ended up checking the schema before sending it to this plugin.

One fix would be to check the schema argument on the JS side of this plugin already here and here.

I'll create a PR