Hi
I’m kinda new to the whole typescript / angular thing so I’m already sorry if this is a really noob-y question.
Anyway, I’m trying to open a new InAppBrowser window in my ionic 2 app, and then read the parameter in the URL on the ‘loadstart’ event.
The Event doesn’t fire tho, and I don’t know what I’m doing wrong. I tried it with Google Android Emulator API 25 and also via Ionic View on my iPhone.
Here’s my code:
let browser = new InAppBrowser(fullURL, '_blank');
browser.on('loadstart')
.subscribe(
((event) => {
let params = new URLSearchParams(event.url);
var access_token = params.get("code");
console.log(event.url);
console.log(access_token);
browser.close;
}
))
Ok, I’m having almost the same problem as you, but I am one step further I guess.
Turns out that you are subscribing to errors instead of successful results, because you are using one parameter on the subscription.
You can do this
let browser = new InAppBrowser(fullURL, '_blank');
browser.on('loadstart').subscribe(
(() => { //no args
//console.log(event.url); //problem is now I don't have the URL :(
browser.close; //but this will work
}
but then you cannot access event.url, and this is my problem right now…
After upgrading to the official Ionic 2.0 release my problem has been resolved. I also added the URL to the white list, maybe that will help?
1 Like
Same here, thanks! Upgraded to 2.2.1
I placed URL _blank and events are calling one by one after closing browser not on load url can you helping me out ?
can you tell me how you white list URL?