Can Meteor be used with PhoneGap?

Solution 1:

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:

  • Grab the latest copy of phonegap 2.2.* from https://github.com/phonegap/phonegap (2.1 has a bug that prevents this technique from working)
  • Create your phonegap project and whitelist your meteor server domain name using the instructions here: http://docs.phonegap.com/en/1.9.0/guide_whitelist_index.md.html
  • For iOS, find and open CordovaLib/Classes/CDVViewController.m and around line 175, overwrite appURL with appURL = [NSURL URLWithString:@"http://your-server.com"];

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:

As of 0.9.2 version of meteor it is easy to use Phonegap: https://www.meteor.com/blog/2014/09/15/meteor-092-iOS-Android-mobile-apps-phonegap-cordova

Solution 3:

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...