1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-12-14 17:22:33 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

fix build time check

This commit is contained in:
sunnylqm
2025-11-25 14:19:48 +08:00
parent f941b93cb3
commit 48b9f7ab07
3 changed files with 15 additions and 11 deletions

View File

@@ -44,13 +44,17 @@ public class UpdateContext {
String storedPackageVersion = this.sp.getString("packageVersion", null);
String storedBuildTime = this.sp.getString("buildTime", null);
// If stored versions don't exist, write current versions first
if (storedPackageVersion == null || storedBuildTime == null) {
SharedPreferences.Editor editor = sp.edit();
SharedPreferences.Editor editor = this.sp.edit();
if (storedPackageVersion == null) {
editor.putString("packageVersion", packageVersion);
editor.putString("buildTime", buildTime);
editor.apply();
storedPackageVersion = packageVersion;
}
if (storedBuildTime == null) {
editor.putString("buildTime", buildTime);
editor.apply();
storedBuildTime = buildTime;
}
@@ -65,10 +69,7 @@ public class UpdateContext {
editor.clear();
editor.putString("packageVersion", packageVersion);
editor.putString("buildTime", buildTime);
// Use commit() instead of apply() to ensure synchronous write completion
// This prevents race condition where getBundleUrl() might read null values
// if called before apply() completes
editor.commit();
editor.apply();
}
}

View File

@@ -78,10 +78,13 @@ RCT_EXPORT_MODULE(RCTPushy);
NSString *storedBuildTime = [defaults stringForKey:paramBuildTime];
// If stored versions don't exist, write current versions first
if (!storedPackageVersion && !storedBuildTime) {
if (!storedPackageVersion) {
[defaults setObject:curPackageVersion forKey:paramPackageVersion];
[defaults setObject:curBuildTime forKey:paramBuildTime];
storedPackageVersion = curPackageVersion;
}
if (!storedBuildTime) {
[defaults setObject:curBuildTime forKey:paramBuildTime];
storedBuildTime = curBuildTime;
}

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-update",
"version": "10.36.0",
"version": "10.36.1",
"description": "react-native hot update",
"main": "src/index",
"scripts": {