react-native-update 10.29.9 → 10.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -36,10 +36,18 @@ public class UpdateContext {
|
|
|
36
36
|
this.sp = context.getSharedPreferences("update", Context.MODE_PRIVATE);
|
|
37
37
|
|
|
38
38
|
String packageVersion = getPackageVersion();
|
|
39
|
-
|
|
39
|
+
String buildTime = getBuildTime();
|
|
40
|
+
String storedPackageVersion = this.sp.getString("packageVersion", null);
|
|
41
|
+
String storedBuildTime = this.sp.getString("buildTime", null);
|
|
42
|
+
|
|
43
|
+
boolean packageVersionChanged = !packageVersion.equals(storedPackageVersion);
|
|
44
|
+
boolean buildTimeChanged = !buildTime.equals(storedBuildTime);
|
|
45
|
+
|
|
46
|
+
if (packageVersionChanged || buildTimeChanged) {
|
|
40
47
|
SharedPreferences.Editor editor = sp.edit();
|
|
41
48
|
editor.clear();
|
|
42
49
|
editor.putString("packageVersion", packageVersion);
|
|
50
|
+
editor.putString("buildTime", buildTime);
|
|
43
51
|
editor.apply();
|
|
44
52
|
|
|
45
53
|
this.cleanUp();
|
package/ios/RCTPushy/RCTPushy.mm
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
static NSString *const keyPushyInfo = @"REACTNATIVECN_PUSHY_INFO_KEY";
|
|
18
18
|
static NSString *const paramPackageVersion = @"packageVersion";
|
|
19
|
+
static NSString *const paramBuildTime = @"buildTime";
|
|
19
20
|
static NSString *const paramLastVersion = @"lastVersion";
|
|
20
21
|
static NSString *const paramCurrentVersion = @"currentVersion";
|
|
21
22
|
static NSString *const paramIsFirstTime = @"isFirstTime";
|
|
@@ -70,20 +71,28 @@ RCT_EXPORT_MODULE(RCTPushy);
|
|
|
70
71
|
{
|
|
71
72
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
72
73
|
|
|
74
|
+
// Check for version changes first
|
|
75
|
+
NSString *curPackageVersion = [RCTPushy packageVersion];
|
|
76
|
+
NSString *curBuildTime = [RCTPushy buildTime];
|
|
77
|
+
NSString *storedPackageVersion = [defaults stringForKey:paramPackageVersion];
|
|
78
|
+
NSString *storedBuildTime = [defaults stringForKey:paramBuildTime];
|
|
79
|
+
|
|
80
|
+
BOOL packageVersionChanged = ![curPackageVersion isEqualToString:storedPackageVersion];
|
|
81
|
+
BOOL buildTimeChanged = ![curBuildTime isEqualToString:storedBuildTime];
|
|
82
|
+
|
|
83
|
+
if (packageVersionChanged || buildTimeChanged) {
|
|
84
|
+
// Clear all update data and store new versions
|
|
85
|
+
[defaults setObject:nil forKey:keyPushyInfo];
|
|
86
|
+
[defaults setObject:nil forKey:keyHashInfo];
|
|
87
|
+
[defaults setObject:@(YES) forKey:KeyPackageUpdatedMarked];
|
|
88
|
+
[defaults setObject:curPackageVersion forKey:paramPackageVersion];
|
|
89
|
+
[defaults setObject:curBuildTime forKey:paramBuildTime];
|
|
90
|
+
|
|
91
|
+
// ...need clear files later
|
|
92
|
+
}
|
|
93
|
+
|
|
73
94
|
NSDictionary *pushyInfo = [defaults dictionaryForKey:keyPushyInfo];
|
|
74
95
|
if (pushyInfo) {
|
|
75
|
-
NSString *curPackageVersion = [RCTPushy packageVersion];
|
|
76
|
-
NSString *packageVersion = [pushyInfo objectForKey:paramPackageVersion];
|
|
77
|
-
|
|
78
|
-
BOOL needClearPushyInfo = ![curPackageVersion isEqualToString:packageVersion];
|
|
79
|
-
if (needClearPushyInfo) {
|
|
80
|
-
[defaults setObject:nil forKey:keyPushyInfo];
|
|
81
|
-
[defaults setObject:nil forKey:keyHashInfo];
|
|
82
|
-
[defaults setObject:@(YES) forKey:KeyPackageUpdatedMarked];
|
|
83
|
-
|
|
84
|
-
// ...need clear files later
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
96
|
NSString *curVersion = pushyInfo[paramCurrentVersion];
|
|
88
97
|
|
|
89
98
|
BOOL isFirstTime = [pushyInfo[paramIsFirstTime] boolValue];
|
|
@@ -127,13 +136,11 @@ RCT_EXPORT_MODULE(RCTPushy);
|
|
|
127
136
|
NSDictionary *pushyInfo = [defaults dictionaryForKey:keyPushyInfo];
|
|
128
137
|
NSString *lastVersion = pushyInfo[paramLastVersion];
|
|
129
138
|
NSString *curVersion = pushyInfo[paramCurrentVersion];
|
|
130
|
-
NSString *curPackageVersion = [RCTPushy packageVersion];
|
|
131
139
|
if (lastVersion.length) {
|
|
132
140
|
// roll back to last version
|
|
133
141
|
[defaults setObject:@{paramCurrentVersion:lastVersion,
|
|
134
142
|
paramIsFirstTime:@(NO),
|
|
135
|
-
paramIsFirstLoadOk:@(YES)
|
|
136
|
-
paramPackageVersion:curPackageVersion}
|
|
143
|
+
paramIsFirstLoadOk:@(YES)}
|
|
137
144
|
forKey:keyPushyInfo];
|
|
138
145
|
}
|
|
139
146
|
else {
|
|
@@ -296,7 +303,6 @@ RCT_EXPORT_METHOD(setNeedUpdate:(NSDictionary *)options
|
|
|
296
303
|
newInfo[paramLastVersion] = lastVersion;
|
|
297
304
|
newInfo[paramIsFirstTime] = @(YES);
|
|
298
305
|
newInfo[paramIsFirstLoadOk] = @(NO);
|
|
299
|
-
newInfo[paramPackageVersion] = [RCTPushy packageVersion];
|
|
300
306
|
[defaults setObject:newInfo forKey:keyPushyInfo];
|
|
301
307
|
|
|
302
308
|
|
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -109,9 +109,16 @@ export const enhancedFetch = async (
|
|
|
109
109
|
url: string,
|
|
110
110
|
params: Parameters<typeof fetch>[1],
|
|
111
111
|
) => {
|
|
112
|
-
return fetch(url, params)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
return fetch(url, params)
|
|
113
|
+
.then(r => {
|
|
114
|
+
if (r.ok) {
|
|
115
|
+
return r;
|
|
116
|
+
}
|
|
117
|
+
throw new Error(`${r.status} ${r.statusText}`);
|
|
118
|
+
})
|
|
119
|
+
.catch(e => {
|
|
120
|
+
log('fetch error', url, e);
|
|
121
|
+
log('trying fallback to http');
|
|
122
|
+
return fetch(url.replace('https', 'http'), params);
|
|
123
|
+
});
|
|
117
124
|
};
|