moodle mobile 2 don't accept path urls?

moodle mobile 2 don't accept path urls?

by Mohammed Essaid MEZERREG -
Number of replies: 5

Hello,

I am customizing moodle mobile 2 application, I cloned the source code from the main repository, the thing is: when I run a test and enter the the first two demo-urls from www/config.js file in the url filed of the first screen they work very good, 

but the third one didn't work showing this message:

error message from mobile app

the same thing happened with my moodle website. the common thing between the two of them is the url form (path format). my version is 2.8 (of the moodle website).

I tested the two urls using the official mobile app for android and it works for both of them.

Average of ratings: -
In reply to Mohammed Essaid MEZERREG

Re: moodle mobile 2 don't accept path urls?

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hello Mohammed,

that site should work fine, if it works in the official app then it should work in your custom app. It's weird that some sites work for you but not these ones. Maybe you lack some Cordova plugin?

Please make sure you have everything installed if you're running the app using Ionic CLI:

https://docs.moodle.org/dev/Setting_up_your_development_environment_for_Moodle_Mobile_2

You can also try to use Remote Inspectors (Chrome and Safari) to see what's written in the Console/Network, maybe that helps you fix the issue.

Kind regards,

Dani

In reply to Dani Palou

Re: moodle mobile 2 don't accept path urls?

by Mohammed Essaid MEZERREG -

I think the problem is because I am using cloud9 (http://c9.io) as my development environment and when I test I write (ionic serve -ip $PORT) and c9  give an https url which causes problems with non https url entered to the siteurl field.

site url log errors


In reply to Mohammed Essaid MEZERREG

Re: moodle mobile 2 don't accept path urls?

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi again,

if  you're testing in a browser you should start it without security to allow requests without CORS. We recommend using Chrome or Chromium, here's how to start it.

Chrome in Windows:

"Path to chrome\chrome.exe" --allow-file-access-from-files --disable-web-security

Chrome in Mac:

open -a "Google Chrome" --args --allow-file-access-from-files --disable-web-security

Chromium in Mac:

open -a /Applications/Chromium.app --args --allow-file-access-from-files --disable-web-security

I hope this helps you fix the issue.

Kind regards,

Dani

In reply to Dani Palou

Re: moodle mobile 2 don't accept path urls?

by Mohammed Essaid MEZERREG -

I tried it in windows also, but it still not working!

Did you try it with the third demo_site url? I think there is a problem when testing with browsers, I build it with PhoneGap and it working but not in browser.

In reply to Mohammed Essaid MEZERREG

Re: moodle mobile 2 don't accept path urls?

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Please read my previous post. You need to start the browser using these flags:

--allow-file-access-from-files --disable-web-security

If I test your site without using those flags I get the same error as you do. Then I kill the browser, start it again using those flags and it works. That's because of CORS, it only affects browsers because Cordova doesn't perform the same checks as browsers.

Kind regards,

Dani