Commit db3475ca by wong.peiyi

codepush集成完成

parent 96a5af79
...@@ -5,26 +5,58 @@ ...@@ -5,26 +5,58 @@
* @format * @format
* @flow * @flow
*/ */
import React, { Component } from 'react'; import React, { Component } from 'react'
import { Text, TextInput } from 'react-native'; import { Text, TextInput } from 'react-native'
import { Provider } from 'react-redux'; import { Provider } from 'react-redux'
import configureStore from './app/store/configureStore'; import CodePush from 'react-native-code-push'
import Router from './app/Router'; import configureStore from './app/store/configureStore'
const store = configureStore(); import Router from './app/Router'
import { show } from './app/utils/Utils'
const store = configureStore()
// 字体不随系统字体变化 首字母不大写 // 字体不随系统字体变化 首字母不大写
Text.defaultProps = Object.assign({}, Text.defaultProps, { allowFontScaling: false }) 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 // 避免 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() { render() {
return ( return (
<Provider store={store}> <Provider store={store}>
<Router /> <Router />
</Provider> </Provider>
); )
} }
} }
App = CodePush(codepushOptions)(App)
export default App
...@@ -119,6 +119,7 @@ android { ...@@ -119,6 +119,7 @@ android {
versionCode 1 versionCode 1
versionName appVersion versionName appVersion
missingDimensionStrategy 'react-native-camera', 'general' missingDimensionStrategy 'react-native-camera', 'general'
multiDexEnabled true
} }
splits { splits {
abi { abi {
...@@ -129,9 +130,20 @@ android { ...@@ -129,9 +130,20 @@ android {
} }
} }
buildTypes { buildTypes {
debug {
resValue "string", "CodePushDeploymentKey", '"OQxOHKC_pU5KPExPvQLLfeOdhO4_zss5pKduM"'
resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
}
release { release {
minifyEnabled enableProguardInReleaseBuilds minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 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 // applicationVariants are e.g. debug, release
...@@ -178,6 +190,7 @@ dependencies { ...@@ -178,6 +190,7 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"]) implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-code-push')
// implementation fileTree(dir: 'libs', include: ['*.jar']) // implementation fileTree(dir: 'libs', include: ['*.jar'])
// implementation "androidx.multidex:multidex:2.0.0" // implementation "androidx.multidex:multidex:2.0.0"
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false" android:allowBackup="false"
tools:replace="android:allowBackup" tools:replace="android:allowBackup"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
......
This diff could not be displayed because it is too large.
...@@ -3,6 +3,7 @@ package com.bonehouse_business_app; ...@@ -3,6 +3,7 @@ package com.bonehouse_business_app;
import android.app.Application; import android.app.Application;
import com.facebook.react.ReactApplication; import com.facebook.react.ReactApplication;
import com.microsoft.codepush.react.CodePush;
import com.RNFetchBlob.RNFetchBlobPackage; import com.RNFetchBlob.RNFetchBlobPackage;
import com.rnfs.RNFSPackage; import com.rnfs.RNFSPackage;
import com.henninghall.date_picker.DatePickerPackage; import com.henninghall.date_picker.DatePickerPackage;
...@@ -25,6 +26,11 @@ public class MainApplication extends Application implements ReactApplication { ...@@ -25,6 +26,11 @@ public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override @Override
protected String getJSBundleFile(){
return CodePush.getJSBundleFile();
}
@Override
public boolean getUseDeveloperSupport() { public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG; return BuildConfig.DEBUG;
} }
...@@ -33,6 +39,7 @@ public class MainApplication extends Application implements ReactApplication { ...@@ -33,6 +39,7 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() { protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList( return Arrays.<ReactPackage>asList(
new MainReactPackage(), new MainReactPackage(),
new CodePush(getResources().getString(R.string.CodePushDeploymentKey), getApplicationContext(), BuildConfig.DEBUG),
new RNFetchBlobPackage(), new RNFetchBlobPackage(),
new RNFSPackage(), new RNFSPackage(),
new DatePickerPackage(), 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' 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' include ':rn-fetch-blob'
project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android') project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android')
include ':react-native-fs' include ':react-native-fs'
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
</Testables> </Testables>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug" buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0" launchStyle = "0"
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
buildConfiguration = "Release"> buildConfiguration = "Release">
</AnalyzeAction> </AnalyzeAction>
<ArchiveAction <ArchiveAction
buildConfiguration = "Release" buildConfiguration = "Staging"
revealArchiveInOrganizer = "YES"> revealArchiveInOrganizer = "YES">
</ArchiveAction> </ArchiveAction>
</Scheme> </Scheme>
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import <React/RCTBridge.h> #import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h> #import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h> #import <React/RCTRootView.h>
#import "CodePush.h"
#import "RNSplashScreen.h" // 导入启动页组件库 #import "RNSplashScreen.h" // 导入启动页组件库
@implementation AppDelegate @implementation AppDelegate
...@@ -37,7 +38,8 @@ ...@@ -37,7 +38,8 @@
#if DEBUG #if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else #else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; // return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
return [CodePush bundleURL];
#endif #endif
} }
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string> <string>$(CURRENT_PROJECT_VERSION)</string>
<key>CodePushDeploymentKey</key>
<string>$(CODEPUSH_KEY)</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>NSAppTransportSecurity</key> <key>NSAppTransportSecurity</key>
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#endif /* RNToolsManager_h */ #endif /* RNToolsManager_h */
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h> //#import <React/RCTBridgeModule.h>
#import "RCTBridgeModule.h"
@interface RNToolsManager : NSObject <RCTBridgeModule> @interface RNToolsManager : NSObject <RCTBridgeModule>
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
"react-native": "0.59.9", "react-native": "0.59.9",
"react-native-audio": "4.3.0", "react-native-audio": "4.3.0",
"react-native-camera": "3.40.0", "react-native-camera": "3.40.0",
"react-native-code-push": "7.0.0",
"react-native-date-picker": "2.7.9", "react-native-date-picker": "2.7.9",
"react-native-fs": "2.14.1", "react-native-fs": "2.14.1",
"react-native-image-picker": "0.28.0", "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