Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Phonegap with ajax and Perl backend

by Anonymous Monk
on May 11, 2017 at 07:46 UTC ( [id://1190035]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

Has anyone used Phonegap with Ajax and Perl (and MySQL) as the backend to create an android or iOS app? I have a website created with Perl (and MySQL) and Ajax and would like to convert it to an app that can be downloaded on an Android phone or Iphone (just like a native app but made with Phonegap(with html, css and ajax)).

I have installed Phonegap Desktop on Windows and have gotten as far as seeing the Success message displayed on the PhoneGap app on my Iphone. I am also able to display alert messages on the PhoneGap app from my custom Javascript code. However I am unable to display data from my Ajax call via Perl as the backend. I get the response status 0 (using my local server address 192.168.1.12 (also tried localhost) for about AJax GET and POST).

Is it even possible?

Replies are listed 'Best First'.
Re: Phonegap with ajax and Perl backend
by LanX (Saint) on May 11, 2017 at 10:18 UTC
    Where is the Perl logic supposed to run?

    On the smartphone? Then you should consider porting to javascript.

    Otherwise Corion successfully ran Perl with Mojolicious on Android, see

    but as far as I remember installing several other CPAN modules and Android's file system posed problems.

    Anyway this won't help you with iOS though.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      The Perl would do the backend processing (with MySQL) and pass the output to Ajax.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Phonegap with ajax and Perl backend
by Corion (Patriarch) on May 11, 2017 at 13:28 UTC

    Personally, I found PhoneGap to be a horrible experience.

    Besides running Perl on Android, I'm currently looking at Progressive Web Apps and Service Workers to aggressively cache web pages on the client. If you can limit the communication to the server to very few instances or precacheable responses, you can create something that very much looks like a native application on Android. You don't get access to interesting Android services like the user address book or user calendar that way.

    If you need some more fancy interaction, you will have to implement your backend two times. The "online" backend in Perl. This is what you already have. The "offline" backend in Javascript, this backend will be accessed by your service worker when the online backend is unreachable. That Javascript backend should behave like the online backend but store the interactions for later.

    I'm not entirely convinced that this is less work or a better approach than porting a complete application to Java, but at least you get the "web front end" and "native application" from one codebase that way.

      Oh...how was it a horrible experience? Did the app work on both Android phones and Iphone when converted from a web site using PhoneGap?

        It was a horrible experience in the sense that I was stuck when getting the complete thing set up. I never got as far as building the app, even for Android.

        Maybe I was looking at the wrong instructions or outdated instructions. I found the mix of plug-ins that need to be installed for functionality and the (un)availability of the features depending on versions of various plugins perplexing and the process of installing too opaque.

        In retrospect I'm sorry I didn't keep notes of my dealings with Phonegap, but I think I wasted three or four evenings on it before trying Java instead. In comparison, the Google Android Studio (rebranded IntelliJ) made Java on Android shine and I got to a working application within one or two days of autocompletion and Stackoverflow.

Re: Phonegap with ajax and Perl backend
by marto (Cardinal) on May 11, 2017 at 10:10 UTC

    " I have a website created with Perl (and MySQL) and Ajax and would like to convert it to an app that can be downloaded on an Android phone or Iphone"

    I have not used phonegap, are you sure it can do this? I doubt it very much. Most of these things I've seen create a UI (HTML/CSS/JS) within a wrapper and expose things like GPS, accelerometers etc via HTML5. Think about what you're trying to do. The "server" does not get downloaded onto the phone. Also, WFIW, I've reversed a couple of "apps" created using similar systems distributed by my employer. I was wondering why a 4 page "app" (one pointless splash screen, one legally unenforceable 'licence' page, a help page and one stupid graph) was over 40MB in size. Bloatware combined with binary runtimes for various targets, all bundled up in a .apk file. If you have this running on a web server, why bother having an app at all? Why not just have a web interface with a nice UI?

      The app stands a higher chance of being used if it can be found on the phone like a native app (Iphone or Android) phones. I came across someone's blog where he wrote about serving his Javascript game via web and via an app that can be downloaded on Android phones. He said the usage of his game is higher in the app format.

        "I came across someone's blog where he wrote about serving his Javascript game via web and via an app that can be downloaded on Android phones."

        So a blog you found is the authoritative answer on the subject? Both (the fact you found a blog/the claim of an app getting more users than a website) simply sounds like a matter of marketing. Regardless of how you deliver it, you're attempting to deliver a service. I'd focus my efforts there.

        A Javascript game - or application - is already running in the device. Converting it to an actual Android App is not a structural change. (Don't know about conversion to an iOS app.)

        Converting a server-based application to an Android app, however, is a serious structural change. And you may still end up with an app that communicates with a server. (And probably even more difficult to do for iOS.)

        A more realistic approach would likely be converting just the web-based UI to an Android (or iOS) app.

        Also, I've heard that there are apps that, supposedly, just pass an URL to the web browser. I haven't tried. So far, the only Android app I've "created" was the result of following a tutorial and adding/modifying some features. Curiosity satisfied, I've not had a reason to do more.

        I'd much rather use Perl. Then, if I need to use it on my tablet, put a web interface on it. If some one else needs to use it from their tablet or smart phone, they will, despite the lack of an app.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1190035]
Approved by Discipulus
Front-paged by Discipulus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-20 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found