App stucks at connecting website screen

App stucks at connecting website screen

Akshay Dusane -
回帖数:16

Hello everyone,

I have build moodle mobile custom app for my website. I am successfull in running the app in the browser 

Command

cordova serve 


But when I am building this app for android, It stucks at the screen "Connect to moodle" . Inspite of giving the correct url of my moodle website the app halts at this screen only.

Please find a screenshot of the issue in the attachments below.


Thanks and Regards

附件 Screenshot_2017-03-06-16-16-31-846.jpeg
回复Akshay Dusane

Re: App stucks at connecting website screen

Dani Palou -
Core developers的头像 Moodle HQ的头像 Peer reviewers的头像 Plugin developers的头像

Hello,

in a private message you said that the error thrown is "ReferenceError: Connection is not defined". This means that you haven't installed the plugin cordova-plugin-network-information. If you run the app using Ionic/Cordova CLI you need to install all the plugins and platforms. You can do so running "ionic state restore". Please follow the steps detailed in here:

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

Kind regards,

Dani

回复Dani Palou

Re: App stucks at connecting website screen

Akshay Dusane -

Thanks Daniel, It worked for me. Now my another query is If I am changing something like I have the color in the mm.bundle.css is not reflecting in the app Why is it so ? Thanks 

回复Akshay Dusane

Re: App stucks at connecting website screen

Dani Palou -
Core developers的头像 Moodle HQ的头像 Peer reviewers的头像 Plugin developers的头像

Hi Akshay

we don't recommend changing the file mm.bundle.css directly, since running gulp or ionic serve can override your changes. You should search the scss file where those styles are declared and modify them in there. 

Kind regards,

Dani

回复Dani Palou

Re: App stucks at connecting website screen

Akshay Dusane -
Thanks Daniel for the quick response really appreciated. I will try this  and revert. One last thing I need to know is, if I want to make my moodle site a default site in the app (no need to ask to enter the website for the new user), what changes I have to make, in which files and how to build the app again. Do the moodle provides documentation for the moodle mobile app for developers for these type of changes
回复Dani Palou

Re: App stucks at connecting website screen

Akshay Dusane -

I have made changes in the mm.bundle.scss file but again the same problem the changes done are getting reverted. Any other file I have to make the changes.

回复Akshay Dusane

Re: App stucks at connecting website screen

Dani Palou -
Core developers的头像 Moodle HQ的头像 Peer reviewers的头像 Plugin developers的头像

Hello Akshay,

sorry for the delay in answering.

All the files inside the build folder are generated when you run gulp or ionic serve, so you shouldn't modify them. You should apply your styles to a SCSS in the core or addons folder. If the styles apply only to a certain addon, we recommend putting them in the SCSS of that addon inside the addons folder. For example, www/addons/mod/assign/scss/style.scss. If the styles are more generic you can put them in www/core/scss/styles.scss.

For the default site, you should edit the file www/config.json and put your Moodle URL in the siteurl field. You have more info in this page.

回复Dani Palou

Re: App stucks at connecting website screen

David Brown -

Hi,

I am getting same error 'ReferenceError: Connection is not defined'

I have double checked all plugins, they are installed. After running  "ionic state restore" i see Ionic state restore completed.

Also followed the setup manual . But it is not working for me.

Please help,

thank you,

david


附件 Untitled.png
回复David Brown

Re: App stucks at connecting website screen

Dani Palou -
Core developers的头像 Moodle HQ的头像 Peer reviewers的头像 Plugin developers的头像

Hi David,

this error is shown in an Android/iOS device, right?

If so, you should check that the plugin has been installed in the android/ios platform (the one you're using) as it should.

In Android, go to platforms/android/src/org/apache/cordova and check there is a networkinformation folder.

In iOS, go to platforms/ios/www/plugins and check there is a cordova-plugin-network-information folder.

Kind regards,

Dani

回复Dani Palou

Re: App stucks at connecting website screen

David Brown -

Hi Dani,

No, I see this error in chrome console. 

i have checked both networkinformation folder , cordova-plugin-network-information folder and also plugins, they are all installed.

thank you,

David

附件 Untitled.png
回复David Brown

Re: App stucks at connecting website screen

Dani Palou -
Core developers的头像 Moodle HQ的头像 Peer reviewers的头像 Plugin developers的头像

Hi David,

the Cordova plugins are for Android and iOS. It's normal to see this error in Chrome browser since it doesn't support the Cordova plugins (we mocked up some of them in www/core/components/emulator, but the network plugin wasn't one of them because we can use other tools to detect it).

So you can ignore this error in browser or desktop, it shouldn't break anything. 

Kind regards,

Dani

回复Dani Palou

Re: App stucks at connecting website screen

Narasimha Daruru -

Hi Dani,

It is breaking the app to run on browser. I can't able to navigate from the first page where we enter the site url. It just throwing "ReferenceError: Connection is not defined ".


Regards,

Narasimha

附件 issue.png
回复Narasimha Daruru

Re: App stucks at connecting website screen

Pau Ferrer Ocaña -
Core developers的头像 Moodle HQ的头像 Peer reviewers的头像 Plugin developers的头像

Hi,

It seems something on Chrome and Chromium has changed in the recert releases and it's breaking the API. There are many workarrounds to solve that while we find and integrate a final solution:

1. Declare Connection object. In any part of the code just add (I recommend in the main app.js):

window.Connection = {
            UNKNOWN: 'unknown',
            ETHERNET: 'ethernet',
            WIFI: 'wifi',
            CELL_2G: '2g',
            CELL_3G: '3g',
            CELL_4G: '4g',
            CELL: 'cellular',
            NONE: 'none'
        };

2. Downgrade your browser version.

Kind Regards,


Pau

回复Pau Ferrer Ocaña

Re: App stucks at connecting website screen

Narasimha Daruru -

Hi Pau,

Thank you for your reply. It is working fine with ionic. But when I am working with the phonegap build, it still gives the same error.


Regards,

Narasimha

回复Narasimha Daruru

Re: App stucks at connecting website screen

Dani Palou -
Core developers的头像 Moodle HQ的头像 Peer reviewers的头像 Plugin developers的头像

Hi,

the PhoneGap build repository uses the file build/mm.bundle.js that includes all the Javascript file. You should apply the changes in that file (or copy the built file from your moodlemobile2 repository and apply it to the phonegap build one).

In any case, we already have a solution that will hopefully be integrated soon.

Kind regards,

Dani