Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
99
rated 0 times [  103] [ 4]  / answers: 1 / hits: 23684  / 9 Years ago, sun, december 13, 2015, 12:00:00

I'm developing an app and have almost everything figured out, except for the custom URL scheme plugin(https://github.com/EddyVerbruggen/Custom-URL-scheme). I've successfully installed the plugin and set up a custom URL scheme of signsrestaurantandbar. So when I use signsrestaurantandbar://, my application opens. The problem I'm facing is handling the URL. In the readme, it says I can use function handleOpenURL(URL) for this, but I'm still having issues trying to load a particular page within the app.



Here's what I tried:



function handleOpenURL(url) {
var strValue = url;
strValue = strValue.replace('signsrestaurantandbar://','');
window.location.href = strValue + .html;
}


I put this in my index.html page... though it should open page.html on loading signsrestaurantandbar://page, it doesn't do it properly. In my chrome console, it says it loaded the page, but it appears blank without any error and this happens only once. When I try to load signsrestaurantandbar://page the second time, it just loads the app.



I would appreciate any hints on how to approach loading particular pages using the custom URL scheme.


More From » angularjs

 Answers
142

You need to make sure you list your custom URL in your CSP.



Added 2016-02-11: NOTE: YOUR APP IS NOW INSECURE. IT IS UP TO YOU TO SECURE YOUR APP.



It would look something like this:



<meta http-equiv=Content-Security-Policy 
content=default-src * signsrestaurantandbar:;
style-src * 'self' 'unsafe-inline' 'unsafe-eval';
script-src * 'self' 'unsafe-inline' 'unsafe-eval';>


Usually the wildcard setting (*) can handle most applications, but not your custom protocol.
NOTE: Wildcard setting have the potential of keep your app out of the app stores.



You may also need to add to your config.xml



<allow-intent href=signsrestaurantandbar: />


This whitelist worksheet should help.
HOW TO apply the Cordova/Phonegap the whitelist system



You should also read the whitelist matrix, especially the sectionon <allow-intent (...) /> - Best of Luck


[#64078] Thursday, December 10, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jeniferjaliyahf

Total Points: 650
Total Questions: 104
Total Answers: 86

Location: Grenada
Member since Sun, Dec 20, 2020
3 Years ago
;