mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-10 15:49:36 +08:00
remove failed updates
This commit is contained in:
12
CodePush.m
12
CodePush.m
@@ -109,6 +109,7 @@ static NSString *const PackageIsPendingKey = @"isPending";
|
||||
{
|
||||
[CodePushPackage clearUpdates];
|
||||
[self removePendingUpdate];
|
||||
[self removeFailedUpdates];
|
||||
}
|
||||
|
||||
|
||||
@@ -270,6 +271,17 @@ static NSString *const PackageIsPendingKey = @"isPending";
|
||||
[preferences synchronize];
|
||||
}
|
||||
|
||||
/*
|
||||
* This method is used to clear away failed updates in the event that
|
||||
* a new app store binary is installed.
|
||||
*/
|
||||
+ (void)removeFailedUpdates
|
||||
{
|
||||
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
|
||||
[preferences removeObjectForKey:FailedUpdatesKey];
|
||||
[preferences synchronize];
|
||||
}
|
||||
|
||||
/*
|
||||
* This method is used to register the fact that a pending
|
||||
* update succeeded and therefore can be removed.
|
||||
|
||||
@@ -238,6 +238,11 @@ public class CodePush {
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFailedUpdates() {
|
||||
SharedPreferences settings = applicationContext.getSharedPreferences(CODE_PUSH_PREFERENCES, 0);
|
||||
settings.edit().remove(FAILED_UPDATES_KEY).commit();
|
||||
}
|
||||
|
||||
private void removePendingUpdate() {
|
||||
SharedPreferences settings = applicationContext.getSharedPreferences(CODE_PUSH_PREFERENCES, 0);
|
||||
settings.edit().remove(PENDING_UPDATE_KEY).commit();
|
||||
@@ -310,6 +315,7 @@ public class CodePush {
|
||||
public void clearUpdates() {
|
||||
codePushPackage.clearUpdates();
|
||||
removePendingUpdate();
|
||||
removeFailedUpdates();
|
||||
}
|
||||
|
||||
private class CodePushNativeModule extends ReactContextBaseJavaModule {
|
||||
|
||||
Reference in New Issue
Block a user