Commit db3475ca by wong.peiyi

codepush集成完成

parent 96a5af79
......@@ -5,26 +5,58 @@
* @format
* @flow
*/
import React, { Component } from 'react';
import { Text, TextInput } from 'react-native';
import { Provider } from 'react-redux';
import configureStore from './app/store/configureStore';
import Router from './app/Router';
const store = configureStore();
import React, { Component } from 'react'
import { Text, TextInput } from 'react-native'
import { Provider } from 'react-redux'
import CodePush from 'react-native-code-push'
import configureStore from './app/store/configureStore'
import Router from './app/Router'
import { show } from './app/utils/Utils'
const store = configureStore()
// 字体不随系统字体变化 首字母不大写
Text.defaultProps = Object.assign({}, Text.defaultProps, { allowFontScaling: false })
TextInput.defaultProps = Object.assign({}, TextInput.defaultProps, { allowFontScaling: false, autoCapitalize: 'none' })
TextInput.defaultProps = Object.assign({}, TextInput.defaultProps, {
allowFontScaling: false,
autoCapitalize: 'none',
})
// 避免 three fingers screenshots reporting errors
console.reportErrorsAsExceptions = false;
console.reportErrorsAsExceptions = false
export default class App extends Component {
// 检查更新频率
const codepushOptions = {
// ON_APP_RESUME 后台到前台时
// ON_APP_START 开机时检测
// MANUAL 手动
checkFrequency: CodePush.CheckFrequency.ON_APP_RESUME,
installMode: CodePush.InstallMode.ON_NEXT_RESTART,
updateDialog: false,
}
class App extends Component {
constructor(prop) {
super(prop)
CodePush.disallowRestart()
this.syncImmediate()
}
componentDidMount() {
CodePush.allowRestart()
}
syncImmediate() {
CodePush.sync({})
}
render() {
return (
<Provider store={store}>
<Router />
</Provider>
);
)
}
}
App = CodePush(codepushOptions)(App)
export default App
......@@ -119,6 +119,7 @@ android {
versionCode 1
versionName appVersion
missingDimensionStrategy 'react-native-camera', 'general'
multiDexEnabled true
}
splits {
abi {
......@@ -129,9 +130,20 @@ android {
}
}
buildTypes {
debug {
resValue "string", "CodePushDeploymentKey", '"OQxOHKC_pU5KPExPvQLLfeOdhO4_zss5pKduM"'
resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
}
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
resValue "string", "CodePushDeploymentKey", '"KEzx1DMpvRIuGoORIyvnxdf9j8HD42NEQvj1z0"'
resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
}
releaseStaging.initWith(release)
releaseStaging {
resValue "string", "CodePushDeploymentKey", '"OQxOHKC_pU5KPExPvQLLfeOdhO4_zss5pKduM"'
matchingFallbacks = ['release']
}
}
// applicationVariants are e.g. debug, release
......@@ -178,6 +190,7 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-code-push')
// implementation fileTree(dir: 'libs', include: ['*.jar'])
// implementation "androidx.multidex:multidex:2.0.0"
......
......@@ -25,6 +25,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
tools:replace="android:allowBackup"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
......
This diff could not be displayed because it is too large.
......@@ -3,6 +3,7 @@ package com.bonehouse_business_app;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.microsoft.codepush.react.CodePush;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.rnfs.RNFSPackage;
import com.henninghall.date_picker.DatePickerPackage;
......@@ -25,6 +26,11 @@ public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected String getJSBundleFile(){
return CodePush.getJSBundleFile();
}
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
......@@ -33,6 +39,7 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new CodePush(getResources().getString(R.string.CodePushDeploymentKey), getApplicationContext(), BuildConfig.DEBUG),
new RNFetchBlobPackage(),
new RNFSPackage(),
new DatePickerPackage(),
......
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" overridePins="true" />
<certificates src="user" overridePins="true" />
</trust-anchors>
</base-config>
</network-security-config>
\ No newline at end of file
rootProject.name = 'BoneHouse_Business_APP'
include ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
include ':rn-fetch-blob'
project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android')
include ':react-native-fs'
......
......@@ -78,7 +78,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
......@@ -119,7 +119,7 @@
buildConfiguration = "Release">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
buildConfiguration = "Staging"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
......@@ -10,6 +10,7 @@
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "CodePush.h"
#import "RNSplashScreen.h" // 导入启动页组件库
@implementation AppDelegate
......@@ -37,7 +38,8 @@
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
// return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
return [CodePush bundleURL];
#endif
}
......
......@@ -22,6 +22,8 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>CodePushDeploymentKey</key>
<string>$(CODEPUSH_KEY)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
......
......@@ -13,7 +13,8 @@
#endif /* RNToolsManager_h */
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
//#import <React/RCTBridgeModule.h>
#import "RCTBridgeModule.h"
@interface RNToolsManager : NSObject <RCTBridgeModule>
......
......@@ -13,6 +13,7 @@
"react-native": "0.59.9",
"react-native-audio": "4.3.0",
"react-native-camera": "3.40.0",
"react-native-code-push": "7.0.0",
"react-native-date-picker": "2.7.9",
"react-native-fs": "2.14.1",
"react-native-image-picker": "0.28.0",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment