Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 077e9f4

Browse files
committed
remove failed updates
1 parent 78fe939 commit 077e9f4

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

CodePush.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ + (void)clearUpdates
109109
{
110110
[CodePushPackage clearUpdates];
111111
[self removePendingUpdate];
112+
[self removeFailedUpdates];
112113
}
113114

114115

@@ -270,6 +271,17 @@ - (void)saveFailedUpdate:(NSString *)packageHash
270271
[preferences synchronize];
271272
}
272273

274+
/*
275+
* This method is used to clear away failed updates in the event that
276+
* a new app store binary is installed.
277+
*/
278+
+ (void)removeFailedUpdates
279+
{
280+
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
281+
[preferences removeObjectForKey:FailedUpdatesKey];
282+
[preferences synchronize];
283+
}
284+
273285
/*
274286
* This method is used to register the fact that a pending
275287
* update succeeded and therefore can be removed.

android/app/src/main/java/com/microsoft/codepush/react/CodePush.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ private boolean isPendingUpdate(String packageHash) {
238238
}
239239
}
240240

241+
private void removeFailedUpdates() {
242+
SharedPreferences settings = applicationContext.getSharedPreferences(CODE_PUSH_PREFERENCES, 0);
243+
settings.edit().remove(FAILED_UPDATES_KEY).commit();
244+
}
245+
241246
private void removePendingUpdate() {
242247
SharedPreferences settings = applicationContext.getSharedPreferences(CODE_PUSH_PREFERENCES, 0);
243248
settings.edit().remove(PENDING_UPDATE_KEY).commit();
@@ -310,6 +315,7 @@ public static void setUsingTestConfiguration(boolean shouldUseTestConfiguration)
310315
public void clearUpdates() {
311316
codePushPackage.clearUpdates();
312317
removePendingUpdate();
318+
removeFailedUpdates();
313319
}
314320

315321
private class CodePushNativeModule extends ReactContextBaseJavaModule {

0 commit comments

Comments
 (0)