Skip to content

Add try catch block to Safari View Controller logic #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2021

Conversation

Opstrup
Copy link

@Opstrup Opstrup commented Nov 27, 2020

PR Checklist

What is the current behavior?

Malformed urls is causing the app to crash since the Safari View Controller does not work with all urls.

What is the new behavior?

Fixes/Implements/Closes #189.

Based on the description okwast gives here a try catch block is added around the initialization of the SFSafariViewController.

With this change exceptions thrown by the native layer can be handled at the react native layer.

@Opstrup Opstrup marked this pull request as draft November 27, 2020 11:53
@Opstrup Opstrup marked this pull request as ready for review November 27, 2020 11:53
@jdnichollsc
Copy link
Member

Can we track that exception?

@Opstrup
Copy link
Author

Opstrup commented Nov 29, 2020

Im not sure what you mean by track, could you elaborate? :)

@jdnichollsc
Copy link
Member

jdnichollsc commented Nov 30, 2020

I was wondering if we can do something similar to this https://github.com/proyecto26/react-native-inappbrowser/blob/develop/android/src/main/java/com/proyecto26/inappbrowser/RNInAppBrowser.java#L167

In order to see the exceptions from Xcode and iOS Console
What do you think? :)

@jamesxabregas
Copy link

Any particular reason why this PR hasn't been merged? It fixes a critical bug that crashes the app.

@jdnichollsc
Copy link
Member

jdnichollsc commented May 4, 2021

Did you check my last comment? Please let me know how to do that and I can help you with a new release including that.

Best,
Juan

@jamesxabregas
Copy link

I'm not the original author of the pull request, nor an Objective-C developer, although I’ll help as best as I can.

According to this StackOverflow post, this is the way to do it.

NSLog(@"%@",[NSThread callStackSymbols]);

Although, is this something you'd just want to do in React Native DEBUG mode or in production code as well? If it's just going to be printed to the log on the user's device I'm not entirely sure what the value of this would be? The exception has been handled so it wouldn’t seem appropriate to be spitting out exception stack-traces to the logs.

Wouldn't it be better to pass the error back, or a summarised version, to the calling function at the JavaScript layer? At least this way the users of this plugin can handle it appropriately and log it to what every logging mechanism they are using. Some app developers may be using remote logging and/or event logging libraries etc at the Javascript layer.

@jdnichollsc
Copy link
Member

@maoapp can you help me reviewing this PR too please? <3

@Rehubbard
Copy link

This would be awesome to get merged and released 👍

@jdnichollsc jdnichollsc merged commit a280fc4 into proyecto26:develop Jun 25, 2021
@jdnichollsc
Copy link
Member

Ok, let me do that today :)

@jdnichollsc jdnichollsc mentioned this pull request Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Catching errors of Safari View Controller
4 participants