Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback not working with Phonegap + Onsen UI #101

Open
qroft opened this issue Feb 17, 2019 · 2 comments
Open

Callback not working with Phonegap + Onsen UI #101

qroft opened this issue Feb 17, 2019 · 2 comments

Comments

@qroft
Copy link

qroft commented Feb 17, 2019

I am developing a hybrid app with Phonegap and Onsen UI.
My console shows me that the language file has been correctly loaded, but the localization does not appear.
After several tries, i used the example with the callback from this Github repo together with a simple alert AND a console.log - but nothing happens.

This is my code so far:

var opts = { language: "de", pathPrefix: "/js", skipLanguage: "en-US" }; opts.callback = function(data, defaultCallback) { data.message = "Optional call back works."; $("[data-localize]").css({color: "#FF8833"}); defaultCallback(data); alert("this is an alert for the callback"); console.log("the callback console logger."); } $("[data-localize]").localize("lang", opts)

I have a CSP Meta-Tag that should allow everything (also load local JSON files, afaik).
It looks like this:
` meta http-equiv="Content-Security-Policy" content="
default-src 'unsafe-eval' 'unsafe-inline' *;
script-src 'self' 'unsafe-inline' 'unsafe-eval' *;
worker-src blob:;
style-src 'self' 'unsafe-inline' *;
img-src 'self' 'unsafe-inline' 'unsafe-eval' *"

I am sure that i am missing some privileges somewhere, but i am not able to find the error.`

@qroft
Copy link
Author

qroft commented Feb 17, 2019

[UPDATE] It definitely has to do something with the CORS.
I have just emulated my app to the browser and there everything works as expected.
At the same time, the phonegap console also shows that everything is loaded, but that is untrue.
I will now try to figure out hwo to change my META CSP tag so that JSON files are allowed to load locally and as soon as i find out i will post it in here.

@qroft
Copy link
Author

qroft commented Feb 18, 2019

[SOLUTION] For some odd reason i had to prepare the phonegap project. It now works.
Check that you have the Whitelist plugin installed.
Check that you have the config.xml set up properly
Check that you have the Content-Security-Policy inside your index.html

Then everything should work fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant