Giter VIP home page Giter VIP logo

meteor-cordova-runtime's Introduction

Cordova Runtime

This package is for serving device specific cordova.js files to a Cordova app using Meteor on remote url.

##Features:

  • Ligth footprint
  • Only serves one cordova.js but contents depends on the device
  • Appcache in automaticly enabled
  • The cordova.js is cached in appcache

##Concept We use Meteor on a remote url and use appcache to make it work offline. This way we have all the goodness of Meteor and the connectivity of Cordova + fast load due to appcache. For faster Meteor subscriptions consider GroundDB or Offline data

##Howto use Simply add this package and load your remote app in cordova by using http://myApp.com?platform=android&cordova=3.0.0

Add the cordova files to your app private folder and add them to the CordovaRuntime:

  var cordovaRuntime = new CordovaRundtime(Assets);

  // Add the specific cordova file for android on cordova version 3.0.0
  cordovaRuntime.addFile('android', '3.0.0', 'cordova-3.0.0-android.js');
  // cordovaRuntime.addFile('android', '3.0.0', 'plugin-3.0.0-android.js');

As the example shows its possible to add multiple files pr. platform and version - eg. adding plugin code pr. platform if needed

##Fallback We have to have a native fallback on initial load or if something goes wrong loading. Try using the following code: Stackoverflow ref

###iOS

  - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
  {
     // here you can either check for the error type or for the url that has failed to load
     NSString *failingURL = [error.userInfo objectForKey:@"NSErrorFailingURLStringKey"];
     // This should be the local HTML file that you want to load when failing, by default we use www/index.html
     NSString *localPath = [[NSBundle mainBundle] pathForResource:@"index.html" ofType:nil inDirectory:@"www"];
     if([failingURL isEqualToString:@"your_remote_url"])
     {
        NSURL *url = [NSURL fileURLWithPath:localPath];
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
        [webView loadRequest:request];
     }
  }

Using and Creating Error Objects SO Connection check webview SO didLoadWithError

###Android

  // On error show default message page...
  public void onReceivedError( int errorCode, String description, String failingUrl)
  {
      super.loadUrl("file:///android_asset/www/index.html");
      return;
  }

##Contributions Feel free to send issues, pull requests all is wellcome,

Kind regards Morten

meteor-cordova-runtime's People

Contributors

tanis2000 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.