RaphaelWoude / capacitor-native-settings

Capacitor plugin to open native settings screens for android and iOS
MIT License
95 stars 30 forks source link

UIApplication.shared.canOpenURL should be used from main thread #10

Closed leye0 closed 3 years ago

leye0 commented 3 years ago

I received this warning...

UI API called from background thread: UIApplication.canOpenURL(_:) must be used from main thread only

...when navigating back to my application.

It seems like the main thread should be retrieved before calling the UIApplication.shared.canOpenURL method. Maybe something like this would help?

DispatchQueue.main.async {
    UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
        call.resolve([
            "status": success
        ])
    });
}

image

Thanks

RaphaelWoude commented 3 years ago

That should do the trick. Would you be able to make a pull request for this? @leye0

dennisameling commented 3 years ago

Here's a PR: https://github.com/RaphaelWoude/capacitor-native-settings/pull/12