/meteor-cordova-loader

Meteor cordova asset compiler and loader (phonegap). It makes working with cordova easy.

Primary LanguageJavaScript

Cordova Asset Compiler & Loader

Introduction

Cordova Loader's goal is to make using Meteor with Cordova as easy as using Meteor itself. The compiler interprets the provided Cordova project directory and compiles the assets into minified, platform-specific JavaScript which is stored in memory. When the client loads, it automatically pulls in the platform-specific cordova code for that device. The Cordova API can be used from Meteor the same as it is from vanilla JS apps. Enjoy!

demo

This package aims to solve the shortcomings of the other meteor + cordova packages.

Note: Currently only tested with iOS. Will test the other platforms asap.

Installation / Setup

Requirements

================

Package Installation
mrt add cordova-loader

Note: I would also suggest adding the appcache-extra package. It will cache the cordova/platform file after it is loaded once and gives you a way to handle appcache reloads with better UX.

================

What does this do?

It compiles all the files your meteor application needs to be compatible with cordova and it's plugins. You absolutely must run it in development before deploying to see changes reflected in production.

GETTING STARTED (iOS)

Step 1: Create a Cordova project in your meteor project (so where you run mrt you run this)

cordova create .project_name

*Note: Start the name of your project with a dot (".") so that meteor ignores it

Step 2: Modify config.xml

Open .project_name/config.xml and adjust settings to what you want them to be. This is where you change the apps name, description, etc. You absolutely must have this:

	<content src="" />
	<access origin="*" />

Step 3: Add platforms and build

cd .project_name
cordova platform add ios
cordova build

Step 4: Point the app to your server

Go to /.project_name/platforms/ios/Project.xcodeproject and open it in xcode In xcode, open: CordovaLib.xcodeproj/Classes/Cleaver/CDVViewController.m

Around line 210, modify self.wwwFolderName to point to your server and self.startPage to an empty string like this:

	//For local testing on a mac
    self.wwwFolderName = @"http://mycomputername.local:3000";
    self.startPage = delegate.startPage;
    if (self.startPage == nil) {
        self.startPage = @"";
    }

Step 5: Set up meteor and initialize the loader. SERVER SIDE

CordovaLoader.settings({
		cordovaProjectPath: ".project_name",
		platforms: ["ios"],
		logging: true
})

CordovaLoader.init()

*Notes: cordovaProjectPath can be relative or absolute. A relative path starts without a slash (ex: "folder/inside/meteor" or "../../outside"), an absolute path starts with a slash (ex: "/folder/outside/meteor")

Compiled files are saved to the /private directory and served via this package to make sure the correct cordova.js file is served for the correct platform

The compiler will only run once due to live reload loop. If you want to rerun the compiler after adding a plugin just delete any of the public/cordova/ files.

Step 6: Add packages to cordova

Add packages to cordova via the cordova command in the cordova project you made

cd .project_name
cordova plugin add org.apache.cordova.device
cordova build

Build cordova after any changes you make (cordova build).

================

Comparison of Meteor + Cordova methods/packages

Cordova Setup Guide

  • Cordova Setup Guide - Instructions on how to setup the basic Cordova project needed to get started. (coming soon).

Recommended Cordova Plugins

  • Cordova Plugin Guide - Plugins necessary to make the Meteor app feel native. Also, an overview of optional plugins like setting up push notificaitons and geolocation.

Platform Setup Guides

  • iOS Setup Guide - Detailed walkthrough of steps to setup the iOS Cordova project.
  • Android Setup Guide - Detailed walkthrough of steps to setup Android Cordova project. (coming soon).

Facebook Native SDK

  • accounts-facebook-cordova - Works with the cordova plugin to use facebook single sign on when it exists otherwise use standar oauth package.

Famo.us Integration

  • celestial - Package to make using Famo.us with Meteor easier.

Example Apps

  • Meteor Cordova Todo - Just started working on this. This will eventually be a working app as an example.

================

If you want more features than this provides, file an issue. Feature requests/contributions are welcome.

Contributors

Marcelo Reyna