1.0.1 • Published 5 years ago

react-native-ygzykj-bundle-update v1.0.1

Weekly downloads
9
License
-
Repository
-
Last release
5 years ago

react-native-ygzykj-bundle-update

Getting started

$ npm install react-native-ygzykj-bundle-update --save

Mostly automatic installation

$ react-native link react-native-ygzykj-bundle-update

Manual installation

iOS

1、报错 Build input file cannot be found: '/Users/dentsukasa/Desktop/last/sunsoftJyif/node_modules/react-native/third-party/double-conversion-1.1.6/src/fixed-dtoa.cc' 解决方案: 打开终端之间运行 cd node_modules/react-native/third-party/glog-0.3.5/ && ../../scripts/ios-configure-glog.sh 2、AppDelegate.h replace

 /**
 * Copyright (c) 2015-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
 
 #import <UIKit/UIKit.h>
 #import <React/RCTBundleURLProvider.h>
 #import <React/RCTRootView.h>
 #import "SSManager.h"
 #import "Util.h"
 @interface AppDelegate : UIResponder <UIApplicationDelegate,SSRNOperationDelegate>
 
 @property (nonatomic, strong) UIWindow *window;
 @property (nonatomic, strong) RCTRootView *rootView;
 @property(nonatomic,strong)NSDictionary * launchOptions;
 @end
 

3、AppDelegate.m replace

 /**
 * Copyright (c) 2015-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
 
 #import "AppDelegate.h"
 
 #import "RNSplashScreen.h"
 @implementation AppDelegate
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
 self.launchOptions = launchOptions;
 //接收到成功回调通知
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadRN:) name:@"reloadRN" object:nil];
 //处理AppStore后数据更新
 [Util dealWithAppStoreUpdateWithVersion:@"1.0.0" bundleVersion:@"1.0"];
 //获取本地RN的地址
 [SSManager sharedManager].delegate = self;
 [[SSManager sharedManager] checkLocalFileExists];
 [[SSManager sharedManager] beginBundleOperation:nil];
 //加载RN
 [self reloadRN];
 
 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
 UIViewController *rootViewController = [UIViewController new];
 rootViewController.view = self.rootView;
 self.window.rootViewController = rootViewController;
 [self.window makeKeyAndVisible];
 [RNSplashScreen show];
 return YES;
 }
 
 -(void)loadRN:(NSNotification *)noti{
 [[SSManager sharedManager] checkLocalFileExists];
 [[SSManager sharedManager] beginBundleOperation:nil];
 //  [self reloadRN];
 
 }
 
 -(void)reloadRN{
 
 NSURL *jsCodeLocation;
 
 jsCodeLocation = [NSURL URLWithString:[SSManager sharedManager].jsLocation];
 
 self.rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
 moduleName:@"sunsoftJyjf"
 initialProperties:nil
 launchOptions:self.launchOptions];
 self.rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
 }
 
 @end

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
    • Add import com.reactlibrary.RNSunsoftBundlePackage; to the imports at the top of the file
    • Add new RNSunsoftBundlePackage() to the list returned by the getPackages() method
  2. Append the following lines to android/settings.gradle:
    include ':react-native-ygzykj-bundle-update'
    project(':react-native-ygzykj-bundle-update').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-ygzykj-bundle-update/android')
  3. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-ygzykj-bundle-update')
  4. MainApplication override
    @Override
    protected String getJSMainModuleName() {
      return BundleInfoUtil.getBundlePath(getApplicationContext());
    }
    @Nullable
    @Override
    protected String getJSBundleFile() {
      return BundleInfoUtil.getBundlePath(getApplicationContext());
    }
    and override
    @Override
    public void onCreate() {
      super.onCreate();
       BundleInfoUtil.unzipBundle(this,"zip name");
      SoLoader.init(this, /* native exopackage */ false);
    }
    zip name must equals to the filaname under assets.

Windows

Read it! :D

  1. In Visual Studio add the RNSunsoftBundle.sln in node_modules/react-native-ygzykj-bundle-update/windows/RNSunsoftBundle.sln folder to their solution, reference from their app.
  2. Open up your MainPage.cs app
  • Add using React.Native.Sunsoft.Bundle.Test2.RNSunsoftBundle; to the usings at the top of the file
  • Add new RNSunsoftBundlePackage() to the List<IReactPackage> returned by the Packages method

Usage

import RNSunsoftBundle from 'react-native-ygzykj-bundle-update';

// TODO: What to do with the module?
RNSunsoftBundle;