Hi All,
I am building an Ionic App where a Login Page will open an InAppBrowser for Log in and after that a CUSTOM URI Scheme will trigger( inside the Inappbrowser) and open the app.
I added the following plugin:
cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=testapp
But, when the inappbrowser opened, i got an error
**The webpage at testapp:// could not be loaded because: net::ERR_UNKNOWN_URL_SCHEME**
How to solve this.
Below is the code.
**index.html**
<ion-content ng-controller="ExampleController" padding="true">
<button class="button button-full button-assertive" ng-click="openInExternalBrowser()">
Open In External Browser
</button>
<button class="button button-full button-assertive" ng-click="openInAppBrowser()">
Open In App Browser
</button>
<button class="button button-full button-assertive" ng-click="openCordovaWebView()">
Open In Cordova Webview
</button>
</ion-content>
Now the Controller Part
**app.js**
function handleOpenURL(url) {
setTimeout( function() {
var event = new CustomEvent('LaunchUrl', {detail: {'url': url}});
window.dispatchEvent(event);
}, 0);
}
angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.controller("ExampleController", function ($scope) {
$scope.openInExternalBrowser = function()
{
// Open in external browser
window.open('http://google.com','_system','location=yes');
};
$scope.openInAppBrowser = function()
{
// Open in app browser
window.open('testapp://','_blank');
};
$scope.openCordovaWebView = function()
{
// Open cordova webview if the url is in the whitelist otherwise opens in app browser
window.open('testapp://','_self');
};
});