Skip to content

digikala/digi-push

Repository files navigation

dkmobile/digi-push for React Native

dkmobile/digi-push is a derived from Code Push. Taking into account the solution to the problems of downloading and uploading the bundle and the desired changes for the users devices.

Platforms Supported

  • iOS
  • Android

Usage

Installation

npm i @dkmobile/digi-push

If you are familiar with CodePush, you already know how to use dkmobile/digi-push.

android

Override getJSBundleFile method in MainApplicaion:

@Override
protected String getJSBundleFile() {
    return DigiCodePush.INSTANCE.getJSBundleFilePath(MainApplication.this, super.getJSBundleFile());
}

ios

Override sourceURLForBridge method in AppDelegate

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
    #if DEBUG
        return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
    #else
        return  [DigiCodePush bundleURLWithDefaultUrl:[[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]];
    #endif
}

React Native

Import the DigiCodePush from @dkmobile/digi-push and use DigiCodePush.checkForUpdates to check and get if new version of bundle exist.

import { AppRegistry } from 'react-native'
import { name as appName } from './app.json'
import App from './src/App'
import DigiCodePush from '@dkmobile/digi-push'

DigiCodePush.checkForUpdates(
  server_url, //your desired server url
  request_options //your desired request options like headers and ...
)

AppRegistry.registerComponent(appName, () => App)

Warning The response of your desired server should be like this:

{
  "status": 200,
  "data": {
    "bundle": {
      "bundle_url": "platform specific bundle.zip"
    }
  }
}

CLI

Command Line Interface (CLI) for dkmobile/digi-push.

Bundle

To create the desired bundle to be set on the server, enter the following command in the root of the project:

npx digi-push bundle -o OUTPUT_PATH -p PLATFORM

Contributors

Thanks goes to these wonderful people:

Mostafa Taghipour
Mostafa Taghipour

Milad Bagheri
Milad Bagheri

Versioning

This project follows semantic versioning.

Upcoming:

Feature is coming :))))