react-native-apphub
v0.1.3
Published
React Native AppHub JS Wrapper
Downloads
11
Maintainers
Readme
A react-native module that wraps the native Apphub SDK (https://apphub.io/). Currently, only support iOS.
Why?
AppHub is a great tool to dynamically update react native apps, and it provides very clean APIs. However, since the majority of development (including logging) should be done in JS, it will be nice to control this updating function also in JS.
How?
This RN library provides APIs including initAppHub, fetchNewBuild (Promise), and setServer (for self host).
Installing The Library
npm install --save react-native-apphub
Installing The Dependency
npm install --save apphub
Automatic Installation
react-native link apphub
ornpm install -g rnpm && rnpm link apphub
react-native link ract-native-apphub
ornpm install -g rnpm && rnpm link react-native-apphub
Configuration (AppHub Native SDK)
Connect Your App to AppHub (Example: AppDelegate.m)
Import AppHub at the beginning of AppDelegate.m (in Swift, add this line to your bridging header)
#import "AppHub.h"
Add the following before creating an RCTRootView (most likely in AppDelegate.m). Leave this code commented while you are developing your app. Uncomment it when you are ready to distribute to test users and deploy to the App Store
/**
* OPTION 3 - AppHub
*
* Load cached code and images from AppHub.
*
*/
AHBuild *build = [[AppHub buildManager] currentBuild];
jsCodeLocation = [build.bundle URLForResource:@"main"
withExtension:@"jsbundle"];
Usage
import RNAppHub from 'react-native-apphub'; // Import package from node modules
// Init AppHub
// For self hosted app
// RootURL: AppHub Server
// ApplicationID: Unique app id
RNAppHub.initAppHubWithServer('RootURL', 'ApplicationID');
// For using AppHub service
// RNAppHub.initAppHub('ApplicationID');
// Poll New app bundle
RNAppHub.fetchBuild();