mobile addon for local plugin

mobile addon for local plugin

by Jean-Roch Meurisse -
Number of replies: 13
Picture of Core developers Picture of Plugin developers Picture of Testers

Hey there,

I'm trying to put my hands on addons dev for moodle mobile.
For a start I wrote a mobile version of one of our local plugins and related webservices. This addon adds an item to the mobile app side menu and it works smile  (at least in a dev environment with google chrome or chromium)
I then tried to package it as a remote addon and followed the procedure described in the doc (gulp-generated .zip into local/*pluginname*/mobile, and 

$addons = array(
"local_mypluginname" => array()
);

into db folder), removed the addon folder from the mobile code and finally bumped up version number of my plugin.

When connecting the mobil app to my moodle platform, the side menu item no longer shows.

I probably missed something but cannot figure out what...

Any help?

Regards

Jean-Roch Meurisse

Average of ratings: -
In reply to Jean-Roch Meurisse

Re: mobile addon for local plugin

by Juan Leyva -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Jean,

have you checked that the zip name is "local_mypluginname.zip" and is correctly stored in the /mobile/ folder?

Here you have a real example:

https://github.com/markn86/moodle-mod_certificate

Regards, Juan

In reply to Juan Leyva

Re: mobile addon for local plugin

by Jean-Roch Meurisse -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi Juan, 

Thanks for your answer.

The zip name is correct, behaviour depends on context:

- when using ionic serve with local app addon: ok
- when using ionic serve without local addon but with remote one : the app starts and works in the browser but my extra sidemenu item doesn't show
- when building local app for ios device: install ok but menu item not showing
- when using the official app from appstore: "error in index.html", the app works but the side menu cannot build itself completely (only mycourse, website help and items below divider show, the spinner is displayed between mycourses and website menu items)

I tried the mod_certificate remote addon that works perfectly with the official ios app but neither with android official app or a locally rebuilt app  ("your organisation installed a plugin that is not yet supported", with both ionic serve or ios device)

Any hints?

Regards, J.-R.

In reply to Jean-Roch Meurisse

Re: mobile addon for local plugin

by Juan Leyva -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi,

the mod_certificate should work in Android, please try again removing the site and adding it again (I just tried in a 3.1 site with the latest version of the app and it works as expected).

Can you attach here your Moodle plugin with the zip so we can check what is happening?

Thanks, Juan

In reply to Juan Leyva

Re: mobile addon for local plugin

by Jean-Roch Meurisse -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi,

Finally, mod_certificate indeed works on android, but still not in chrome with a local install of mobile app and remote addon.

You'll find attached my module including the packaged remote addon. It's based on the calendar addon and was made very quickly so there is still unused code...

Thanks in advance for your help

Jean-Roch

In reply to Jean-Roch Meurisse

Re: mobile addon for local plugin

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

Hi Jean-Roch,

sorry for the delay in answering. There was a bug in our gulpfile:

https://tracker.moodle.org/browse/MOBILE-1895

That bug was fixed some weeks ago. I checked your addon and it's failing because it includes the testing code.

Please update your moodlemobile2 master branch and package the addon again. Let me know if that fixes it for you smile

Kind regards,

Dani

In reply to Dani Palou

Re: mobile addon for local plugin

by Jean-Roch Meurisse -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi Dani,

First of all, thanks a lot for your help! It's now working with the official Mobile app.

Unfortunately, when rebuilding the app locally using a clean fork of the app (I only changed the widget id, name and description, and added nothing else), the remote addon doesn't show, neither in a browser with ionic serve or in android/ios device.

Any hint?

Kind regards

Jean-Roch 

In reply to Jean-Roch Meurisse

Re: mobile addon for local plugin

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

Hi Jean-Roch,

that's weird. Did you check that there are no errors shown in the Javascript console?

Also, if you're building the APK using phonegap CLI make sure you have all the cordova plugins installed in your development environment. The list of plugins used by the app can be seen in this config.xml file:

https://github.com/moodlehq/moodlemobile-phonegapbuild/blob/master/config.xml#L112

Kind regards,

Dani

In reply to Dani Palou

Re: mobile addon for local plugin

by Jean-Roch Meurisse -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hey Dani,

I tried with mod_certificate too and experienced the same problem.

See console screen capture attached

This is a very well known security error with xmlhttprequest, but I can't figure out how to solve this here since the .zip package is generated from the mobile dev environment

I got the same error with mobile.css file and image core/u/f1 and a bunch or errors like the following

22/12/2016 08:59:39 $mmSite: WS function 'tool_mobile_get_config' is not available, even in compatibility mode.

Thanks again for your help

Jean-Roch

Attachment Capture d’écran 2016-12-22 à 09.21.35.png
In reply to Dani Palou

Re: mobile addon for local plugin

by Jean-Roch Meurisse -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hey again, 

There were missing cordova plugins... After fixing that and rebuilding the app, it is functional on an ios device but still missing remote addons when served in either Chromium or Google Chrome (same errors as in my previous post).

Kind regards

Jean-Roch

In reply to Jean-Roch Meurisse

Re: mobile addon for local plugin

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

Hi again,

I'm glad it works in iOS. To fix the CORS errors in Chrome or Chromium you need to use some flags when opening the browser. It is explained in here:

https://docs.moodle.org/dev/Moodle_Mobile_development_using_Chrome_or_Chromium#Installation

Kind regards,

Dani

In reply to Dani Palou

Re: mobile addon for local plugin

by Jean-Roch Meurisse -
Picture of Core developers Picture of Plugin developers Picture of Testers

Great! What a Christmas present wink

Thanks a lot, remote addons correctly show now smile so as far as I know everything works 

I didn't do that since de doc says it's not necessary any more from moodle 3.0

However I still have a bunch of 

    function 'tool_mobile_get_config' is not available, even in compatibility mode

I don't know whether it's important or not.

Thanks a lot again

Jean-Roch

In reply to Jean-Roch Meurisse

Re: mobile addon for local plugin

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

Hi Jean-Roch,

I'm glad it works now!

tool_mobile_get_config is a WebService that was introduced in Moodle 3.2. Since your Moodle site is previous to 3.2, the WS is not available.

This WS is used to fix this bug:

https://tracker.moodle.org/browse/MOBILE-1749

And it's also used to show the grades for all course (this feature also requires gradereport_overview_get_course_grades, another WS introduced in Moodle 3.2).

So it's not mandatory for the app to work fine, don't worry about that.

Kind regards,

Dani

In reply to Dani Palou

Re: mobile addon for local plugin

by Jean-Roch Meurisse -
Picture of Core developers Picture of Plugin developers Picture of Testers

Thanks for all Dani,

It's very stimulating to get so quick and efficient support!

Merry Christmas

Jean-Roch