Crash with custom-url-scheme on android
See original GitHub issueI am trying to replace InAppBrowser with SafariViewController in oAuth flow involving a web server. See #34.
The redirect_uri on the web server (which is whitelisted with the oAuth provider) returns:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'none';script-src 'unsafe-inline';">
</head>
<body>
<script>window.location.assign('com.example.app://token' + window.location.hash);</script>
</body>
</html>
then the handleOpenURL event handler parses the oAuth token in the hash.
This works perfectly in iOS but in android SafariViewController crashes on the above page before hitting handleOpenURL.
I know the custom url scheme is properly configured because I can hit handleOpenUrl from a link in a page opened in Chrome.
if I replace:
<script>window.location.assign('com.example.app://token' + window.location.hash);</script>
with
<script>window.location.assign('http://www.google.com');</script>
the redirection works just fine so SafariViewController simply does not like ‘com.example.app://’ on Android only, not iOS.
Any suggestions to have SafariViewController (Chrome Tabs) accept a custom scheme made with https://github.com/EddyVerbruggen/Custom-URL-scheme on Android ?
Project can be found at https://github.com/kidoju/Kidoju-Mobile.
I am using:
- Phonegap 6.3.0
- Android Platform 5.2.1
- Latest versions of all plugins (latest versions on Phonegap build as of today)
I am testing on a Nexus 7 with Android 5.1.1 and Chrome 54.0.2840.85.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:12 (1 by maintainers)
Top GitHub Comments
Thank you. You can easily reproduce the Chrome custom tabs “crashing” and the 10sec gap during which the splashscreen replaces the webview before hitting handleOpenURL by:
where scheme.html is:
Then just click the button to open Chrome custom tabs and click the Authenticate link.
That’s because in iOS the SafariViewController run as part of the application. While in android it is a different Activity (like a process) that is activated by your Cordova activity. What I’m saying is that it’s completely different code that runs on a completely different framework, so what is and isn’t working on iOS is not an indication to anything IMO. I hope I’ll have time to take a better look over the weekend. If you can find a working example of authentication using Chrome custom tabs, it might speed things up. Sorry I can’t help you more, and good luck!