@@ -58,36 +58,38 @@ - (void)cancelRollbackTimer
58
58
}
59
59
60
60
- (void )checkForPendingUpdate : (BOOL )isAppStart {
61
- NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults ];
62
- NSDictionary *pendingUpdate = [preferences objectForKey: PendingUpdateKey];
63
-
64
- if (pendingUpdate)
65
- {
66
- NSError *error;
67
- NSString *pendingHash = pendingUpdate[@" hash" ];
68
- NSString *currentHash = [CodePushPackage getCurrentPackageHash: &error];
61
+ dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
62
+ NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults ];
63
+ NSDictionary *pendingUpdate = [preferences objectForKey: PendingUpdateKey];
69
64
70
- // If the current hash is equivalent to the pending hash, then the app
71
- // restart "picked up" the new update, but we need to kick off the
72
- // rollback timer and ensure that the necessary state is setup.
73
- if ([pendingHash isEqualToString: currentHash]) {
74
- // We only want to initialize the rollback timer in two scenarios:
75
- // 1) The app has been restarted, and therefore, the pending update is already applied
76
- // 2) The app has been resumed, and the pending update indicates it supports being restarted on resume
77
- if (isAppStart || (!isAppStart && [pendingUpdate[@" allowRestartOnResume" ] boolValue ]))
78
- {
79
- int rollbackTimeout = [pendingUpdate[@" rollbackTimeout" ] intValue ];
80
-
81
- // If the app wasn't restarted "naturally", then we need to restart it manually
82
- BOOL needsRestart = !isAppStart;
83
- [self initializeUpdateWithRollbackTimeout: rollbackTimeout needsRestart: needsRestart];
84
-
85
- // Clear the pending update and sync
86
- [preferences removeObjectForKey: PendingUpdateKey];
87
- [preferences synchronize ];
65
+ if (pendingUpdate)
66
+ {
67
+ NSError *error;
68
+ NSString *pendingHash = pendingUpdate[@" hash" ];
69
+ NSString *currentHash = [CodePushPackage getCurrentPackageHash: &error];
70
+
71
+ // If the current hash is equivalent to the pending hash, then the app
72
+ // restart "picked up" the new update, but we need to kick off the
73
+ // rollback timer and ensure that the necessary state is setup.
74
+ if ([pendingHash isEqualToString: currentHash]) {
75
+ // We only want to initialize the rollback timer in two scenarios:
76
+ // 1) The app has been restarted, and therefore, the pending update is already applied
77
+ // 2) The app has been resumed, and the pending update indicates it supports being restarted on resume
78
+ if (isAppStart || (!isAppStart && [pendingUpdate[@" allowRestartOnResume" ] boolValue ]))
79
+ {
80
+ int rollbackTimeout = [pendingUpdate[@" rollbackTimeout" ] intValue ];
81
+
82
+ // If the app wasn't restarted "naturally", then we need to restart it manually
83
+ BOOL needsRestart = !isAppStart;
84
+ [self initializeUpdateWithRollbackTimeout: rollbackTimeout needsRestart: needsRestart];
85
+
86
+ // Clear the pending update and sync
87
+ [preferences removeObjectForKey: PendingUpdateKey];
88
+ [preferences synchronize ];
89
+ }
88
90
}
89
91
}
90
- }
92
+ });
91
93
}
92
94
93
95
- (void )checkForPendingUpdateDuringResume {
0 commit comments