I am developing a simple android app using Ionic Framework where at some point I’m using this.http.get('https://somedomain.com')
.
Testing locally with ionic serve
everything works, but on device it fails to load.
On the debug log the message is net::ERR_UNKNOWN_URL_SCHEME
and I believe its because the protocol is being changed from https://
to intent://
and I don’t know why.
My code is:
this.http.get('https://somedomain.com')
and the error is:
intent://www.somedomain.com/path/2345435#Intent;scheme=https;package=com.net…ps%3A%2F%2Fwww.somedomain.com%2Ftitle%2345435%3FpreventIntent%3Dtrue;end:1
GET intent://www.somedomain.com/title/2345435
net::ERR_UNKNOWN_URL_SCHEME
Hi,
I suspect you might have a missing access origin setting in your config.xml???
Something like…
<access origin="*" />
Will allow everything - then you can restrict after that if required.
No, it is there.
I have also (re)installed cordova-plugin-whitelist
and added the lines bellow to AndroidManifest.xml
, but nothing seems to fix it.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Is it the expected behavior? Does the framework replaces http://
with intent://
?
What “device” are you talking about? What platform?
Did you remote debug the problem on the device already?
Follow these instructions here to debug the problem in Safari dev tools: https://ionic.zone/debug/remote-debug-your-app#ios
Follow these instructions here to debug the problem in Chrome dev tools: https://ionic.zone/debug/remote-debug-your-app#android
Look at the console and network tabs for errors.
I’m curious whether we’re dealing with the ordinary Angular Http
or the native HTTP
here.
@Sujan12, I’m testing in an Android device.
And, yes. I got the error net::ERR_UNKNOWN_URL_SCHEME
debugging from chrome device inspector.
@rapropos, I’m using Angular http:
import { Http, Request, RequestMethod } from '@angular/http';
So you put in http://...
and it then loads something starting with intent://...
- that looks like Android being smart and opening the app connected to that domain.
Here is a way to handle this natively:
Maybe this gives you a new idea.