添加buildTime
This commit is contained in:
parent
6eb731b6fb
commit
c638cd45ac
@ -337,7 +337,7 @@ SPEC CHECKSUMS:
|
||||
React-jsi: 32285a21b1b24c36060493ed3057a34677d58d09
|
||||
React-jsiexecutor: 8909917ff7d8f21a57e443a866fd8d4560e50c65
|
||||
React-jsinspector: 111d7d342b07a904c400592e02a2b958f1098b60
|
||||
react-native-update: 5c1c198cf30994de21e05bfff431814f3722948c
|
||||
react-native-update: dd1ae7615b2281c9f2cd842ab672593074999549
|
||||
React-RCTActionSheet: 89b037c0fb7d2671607cb645760164e7e0c013f6
|
||||
React-RCTAnimation: e3cefa93c38c004c318f7ec04b883eb14b8b8235
|
||||
React-RCTBlob: d26ac0e313fbf14e7203473fd593ccaaeee8329e
|
||||
|
@ -70,10 +70,6 @@ export default class App extends Component {
|
||||
};
|
||||
|
||||
checkUpdate = async () => {
|
||||
if (__DEV__) {
|
||||
// 开发模式不支持热更新,跳过检查
|
||||
return;
|
||||
}
|
||||
let info;
|
||||
try {
|
||||
info = await checkUpdate(appKey);
|
||||
|
@ -1,3 +1,5 @@
|
||||
int MILLIS_IN_MINUTE = 1000 * 60
|
||||
int minutesSinceEpoch = System.currentTimeMillis() / MILLIS_IN_MINUTE
|
||||
|
||||
def safeExtGet(prop, fallback) {
|
||||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
||||
@ -22,6 +24,17 @@ android {
|
||||
jniLibs.srcDirs = ['./lib']
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
buildConfigField("String", "PUSHY_BUILD_TIME", "\"${minutesSinceEpoch}\"")
|
||||
resValue("string", "pushy_build_time", "${minutesSinceEpoch}")
|
||||
}
|
||||
debug {
|
||||
buildConfigField("String", "PUSHY_BUILD_TIME", "\"0\"")
|
||||
resValue("string", "pushy_build_time", "0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -59,6 +59,10 @@ public class UpdateContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getBuildTime() {
|
||||
return BuildConfig.PUSHY_BUILD_TIME;
|
||||
}
|
||||
|
||||
public interface DownloadFileListener {
|
||||
void onDownloadCompleted();
|
||||
void onDownloadFailed(Throwable error);
|
||||
|
@ -41,6 +41,7 @@ public class UpdateModule extends ReactContextBaseJavaModule{
|
||||
constants.put("downloadRootDir", updateContext.getRootDir());
|
||||
constants.put("packageVersion", updateContext.getPackageVersion());
|
||||
constants.put("currentVersion", updateContext.getCurrentVersion());
|
||||
constants.put("buildTime", updateContext.getBuildTime());
|
||||
boolean isFirstTime = updateContext.isFirstTime();
|
||||
constants.put("isFirstTime", isFirstTime);
|
||||
if (isFirstTime) {
|
||||
|
@ -152,6 +152,7 @@ RCT_EXPORT_MODULE(RCTHotUpdate);
|
||||
NSMutableDictionary *ret = [NSMutableDictionary new];
|
||||
ret[@"downloadRootDir"] = [RCTHotUpdate downloadDir];
|
||||
ret[@"packageVersion"] = [RCTHotUpdate packageVersion];
|
||||
ret[@"buildTime"] = [RCTHotUpdate buildTime];
|
||||
ret[@"isRolledBack"] = [defaults objectForKey:keyRolledBackMarked];
|
||||
ret[@"isFirstTime"] = [defaults objectForKey:keyFirstLoadMarked];
|
||||
NSDictionary *updateInfo = [defaults dictionaryForKey:keyUpdateInfo];
|
||||
@ -464,4 +465,15 @@ RCT_EXPORT_METHOD(markSuccess)
|
||||
return version;
|
||||
}
|
||||
|
||||
+ (NSString *)buildTime
|
||||
{
|
||||
#if DEBUG
|
||||
return @"0";
|
||||
#else
|
||||
// To be replaced by scripts/generateiOSBuildTime.sh
|
||||
NSString *pushy_build_time = 1570370091
|
||||
return pushy_build_time;
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -8,6 +8,7 @@ export const packageVersion = HotUpdate.packageVersion;
|
||||
export const currentVersion = HotUpdate.currentVersion;
|
||||
export const isFirstTime = HotUpdate.isFirstTime;
|
||||
export const isRolledBack = HotUpdate.isRolledBack;
|
||||
export const buildTime = HotUpdate.buildTime;
|
||||
|
||||
/*
|
||||
Return json:
|
||||
@ -49,8 +50,9 @@ export async function checkUpdate(APPKEY) {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
packageVersion: packageVersion,
|
||||
packageVersion,
|
||||
hash: currentVersion,
|
||||
buildTime,
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -17,6 +17,8 @@ Pod::Spec.new do |s|
|
||||
s.vendored_libraries = 'RCTHotUpdate/libRCTHotUpdate.a'
|
||||
s.pod_target_xcconfig = { 'USER_HEADER_SEARCH_PATHS' => '"$(SRCROOT)/../node_modules/react-native-update/ios"' }
|
||||
|
||||
s.script_phase = { :name => 'Generate build time', :script => '../../node_modules/react-native-update/scripts/generateiOSBuildTime.sh', :execution_position => :before_compile }
|
||||
|
||||
s.dependency 'React'
|
||||
s.dependency 'SSZipArchive'
|
||||
|
||||
|
9
scripts/generateiOSBuildTime.sh
Executable file
9
scripts/generateiOSBuildTime.sh
Executable file
@ -0,0 +1,9 @@
|
||||
|
||||
#!/bin/bash
|
||||
set -x
|
||||
# DEST=$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH
|
||||
# date +%s > "$DEST/pushy_build_time.txt"
|
||||
OLD_TEXT="NSString \*pushy_build_time"
|
||||
NEW_TEXT=" NSString \*pushy_build_time = $(date +%s)"
|
||||
TARGET_FILE="../../node_modules/react-native-update/ios/RCTHotUpdate/RCTHotUpdate.m"
|
||||
sed -i '' -e "s/.*$OLD_TEXT.*/$NEW_TEXT/" "$TARGET_FILE"
|
Loading…
x
Reference in New Issue
Block a user