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

Commit b0b9580

Browse files
committed
clear updates on init
1 parent d0eb52c commit b0b9580

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ios/CodePush/CodePush.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,20 @@ - (instancetype)init
247247
*/
248248
- (void)initializeUpdateAfterRestart
249249
{
250+
dispatch_async(dispatch_get_main_queue(), ^{
251+
if ([_bridge.bundleURL.scheme hasPrefix:@"http"]) {
252+
NSError *error;
253+
NSString *binaryAppVersion = [[CodePushConfig current] appVersion];
254+
NSDictionary *currentPackageMetadata = [CodePushPackage getCurrentPackage:&error];
255+
if (currentPackageMetadata) {
256+
NSString *packageAppVersion = [currentPackageMetadata objectForKey:AppVersionKey];
257+
if (![binaryAppVersion isEqualToString:packageAppVersion]) {
258+
[CodePush clearUpdates];
259+
}
260+
}
261+
}
262+
});
263+
250264
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
251265
NSDictionary *pendingUpdate = [preferences objectForKey:PendingUpdateKey];
252266
if (pendingUpdate) {

0 commit comments

Comments
 (0)