Can Meteor be used with PhoneGap?

CordovaMeteor

Cordova Problem Overview


Can a Meteor template be packaged up and deployed as a PhoneGap application?

Cordova Solutions


Solution 1 - Cordova

Yes, this is possible, but not by packaging the meteor app on the phone. You have to point phonegap to your meteor server instead (you will still be able to use the API for accessing functionality on the device). Here are the instructions:

That's it. Compile and run the app.

A couple of time savers:

  • You can start setting up your meteor directory by copying the www/ directory contents into your meteor server root directory. Make sure to copy the javascript files under the client/ directory so that they get loaded before the main meteor js file.

  • Run app.initialize(window) from your main meteor js file, if the window parameter is not passed, the app will crash.

  • Don't try to set up the meteor server under the www/ directory in Xcode. You won't be able to deploy to a device because the .meteor subdirectory contains symbolic links to your node modules.

Solution 2 - Cordova

Solution 3 - Cordova

Well, I guess the best starting point is figuring out how far you want/need to go.

Would you want

  • A Meteor.js PhoneGap app that connects to a server somewhere? Then you´d probably want to use the Meteor classes in a PhoneGap project and connect to your server with Meteor.connect(url).

  • Offline App data persistence - That´s gonna get tough... That´s not something Meteor was designed to do, although there surely are ways
    to achive it. I remember that discussions from backbone, spine and
    other client side JS frameworks. It´s easy to use local storage, but the real effort there begins when you want to sync data between local and the server.

That should help to get to the point...

Solution 4 - Cordova

I have done in crude way to some extent and here the process I followed:

  • Take todos example
  • Create a todos bundle with meteor bundle ../todos.tgz
  • Extract the bundle Open the extracted bundle in your editor
  • Open the .js file in static_cacheable/ folder and format it, and replace the ajax call from "file://" request with actual host request.
  • I did this on line 1766 which creates the ajax handler with


u.protoype._start = function(a, d, e, f){
d = d.replace("file://localhost","http://localhost:3000";);
...
}

After this open the app.html file in browser and make sure the server is already running. This way you would most of the application working.

However this is not how would you like to use it in your real application but with more changes it is possible to use the client side in Phonegap with server running somewhere else.

Edit

Meteor has a method connect to connect to a different meteor application which might resolve the above url replace call, although I have not tried that yet.

Solution 5 - Cordova

Here is simple steps to port Meteor app in mobile device using PhoneGap Meteor on Mobile Device using PhoneGap

Just change your stream_clientbf90.js to port to your domain.it works.

Solution 6 - Cordova

Here is live demo on phonegap + meteorjs + oauth2.
I created this app with meteor on google play.
https://play.google.com/store/apps/details?id=com.youiest.tapmatrix&hl=en
It's a private work so could not disclose source code.
Please feel free to ask questions on it.
There are multiple ways I tried to work with meteor + phonegap.
Thanks.

Solution 7 - Cordova

There is also this package: https://github.com/awatson1978/cordova-phonegap

I havn't tried it personally, but it seems the right approach.

Update: In the devshop of august, phonegap support has been announced from the core team with cool demos and stuff.

To play around with it:

meteor update --release CORDOVA-PREVIEW@3

Getting started: https://meteor.hackpad.com/Getting-Started-With-Cordova-Z5n6zkVB1xq

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMarcus EstesView Question on Stackoverflow
Solution 1 - CordovasnezView Answer on Stackoverflow
Solution 2 - CordovaMitja BezenšekView Answer on Stackoverflow
Solution 3 - Cordovathomasf1View Answer on Stackoverflow
Solution 4 - CordovadhavalView Answer on Stackoverflow
Solution 5 - CordovasnowflaxView Answer on Stackoverflow
Solution 6 - CordovanicolsondsouzaView Answer on Stackoverflow
Solution 7 - CordovaBenjamin CrouzierView Answer on Stackoverflow