npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

expo-ota

v0.0.1-alpha.0

Published

ExpoOta standalone module

Downloads

4

Readme

expo-ota

Provides Over The Air updates feature for your react-native app, highly customizable with out of the box support for Expo infrastructure based updates.

Supports Android and iOS platform.

Installation

Make sure you have unimodules installed as described in here

If you do, just type add expo-ota to you npm dependencies.

#Either with npm
npm add expo-ota

#Or yarn
yarn add expo-ota

Basic configuration

OTA module requires some basic configuration in your app's native code. Please locate your MainApplication.java or MainApplication.kt for Android application, and AppDelegate.m for iOS.

Android

Make sure following code is present in your MainApplication.java

private ExpoOTA expoOTA;

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        ...
        @Nullable
        @Override
        protected String getJSBundleFile() {
            return expoOTA.getBundlePath();
        }
        ...
    }

 @Override
    public void onCreate() {
        super.onCreate();
        SoLoader.init(this, /* native exopackage */ false);
        expoOTA = ExpoOTA.init(this, BuildConfig.DEBUG);
    }

iOS

Make sure following code is present in your AppDelegate.m


@implementation AppDelegate {
  EXOta *ota;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ota = [EXOta new]; // This must be firs instruction within this method
  ...
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
#ifdef DEBUG
    return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  NSString *persistedBundle = [ota bundlePath];
  if(persistedBundle != nil)
  {
    return [NSURL fileURLWithPath:persistedBundle];
  } else
  {
    return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  }
#endif
}

app.json

You also need to create app.json file in root folder of your react-native application (alongside root package.json). If you've ejected from Expo, file should already be there. Example file looks like following:

{
  "name": "OTA",
  "displayName": "expo-ota-template",
  "expo": {
    "name": "OTA Example",
    "slug": "expo-template-ota",
    "sdkVersion": "1.0.0",
    "version": "1.0.121",
    "entryPoint": "index.tsx",
    "releaseChannel": "channel", // optional
    "platforms": ["ios", "android"],
    "updates": {
      "enabled": true,
      "checkAutomatically": "ON_ERROR_RECOVERY", // optional
      "versionComparison": "NEWEST", // optional
    }
  }
}
  • slug unique identifier for your project
  • sdkVersion version of your native code. Bump it every time you or any of your dependencies make changes to native code
  • version version of you React-Native app
  • checkAutomativcally determines, whether updates should be downloaded automatically. ON_ERROR_RECOVERY disables auto updates, ON_LOAD enables it.
  • versionComparison determines which algorithm should be used to decide, whether downloaded javascipt code should be used to replace current. Will be explained in details later.

Expo-cli

Make sure you have expo-cli installed and configured and that you are logged in.

Whenever you are buildng new native archives, make sure to predeed this with expo publish. You should include files it creates in your version control system. On iOS, make sure they are included in your app bundle.

Publishing

The only command you will use from expo-cli is expo publish. You MUST use it before building your release builds. Otherwise, they might crash on startup.

You can use it any time you want to publish new version of your javascript code.

Advances configuration

Expo ota comes with multiple configuration options. Some of them are available via app.json fields, others require changes in native code.

Release channels

One of the mose useful features of expo-ota are release channels.

When publishing your native application, you can decide which releaseChannel to use by setting proper field in your 'app.json' file before executing expo publish. The commant will make sure bundle is published to proper release channel.

Upgrading algorithm

There are four versioning algorithms available in expo-ota, each described by other value of versionComparison field in app.json:

  • REVISION Update if application is different than current
  • NEWEST Update only if server provides version published after current version
  • VERSION Update only if server provides application with newer version defined in app.json. Version are compared according to Semver 2.0
  • ANY Always update

Updates happens only, if sdkVersion and releaseChannel of currently used and provided by server applications are equal.

Automatic vs. manual

You can decide whether updates will be queried and downloaded automatically, according to configuration, or handle it manually.

Automatic

If checkAutomatically value is set to ON_LOAD expo-ota takes care for updates on its own. On every startup of application it checks whether there is newer version of application available, downloads it of so, and makes sure new version is used on next startup.

Manual

If checkAutomatically value is set to ON_ERROR_RECOVERY it will download update only in rare cases, leaving the decision whether to query for update entirely to you. However, you can still query for an update manually, even if automatic updates are enabled.

API reference

For manually handling updates, there are several methods exposed to JavaScript by expo-ota module.