Skip to content

Commit 6dbf0ca

Browse files
author
Rodrigo Gomez Palacio
committed
fixup! OSMessagingController Retry Logic
1 parent eb06720 commit 6dbf0ca

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.m

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -247,34 +247,37 @@ - (void)updateInAppMessagesFromCache {
247247
}
248248

249249
- (void)getInAppMessagesFromServer:(NSString *)subscriptionId {
250-
[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:@"getInAppMessagesFromServer"];
250+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
251+
[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:@"getInAppMessagesFromServer"];
251252

252-
if (!subscriptionId) {
253-
[self updateInAppMessagesFromCache];
254-
return;
255-
}
253+
if (!subscriptionId) {
254+
[self updateInAppMessagesFromCache];
255+
return;
256+
}
256257

257-
OSConsistencyManager *consistencyManager = [OSConsistencyManager shared];
258-
NSString *onesignalId = OneSignalUserManagerImpl.sharedInstance.onesignalId;
258+
OSConsistencyManager *consistencyManager = [OSConsistencyManager shared];
259+
NSString *onesignalId = OneSignalUserManagerImpl.sharedInstance.onesignalId;
259260

260-
if (!onesignalId) {
261-
[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:@"Failed to get in app messages due to no OneSignal ID"];
262-
return;
263-
}
261+
if (!onesignalId) {
262+
[OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:@"Failed to get in app messages due to no OneSignal ID"];
263+
return;
264+
}
264265

265-
OSIamFetchReadyCondition *condition = [OSIamFetchReadyCondition sharedInstanceWithId:onesignalId];
266-
NSString *rywToken = [consistencyManager registerCondition:condition forId:onesignalId];
266+
OSIamFetchReadyCondition *condition = [OSIamFetchReadyCondition sharedInstanceWithId:onesignalId];
267+
NSString *rywToken = [consistencyManager registerCondition:condition forId:onesignalId];
267268

268-
NSNumber *sessionDuration = @([OSSessionManager getTimeFocusedElapsed]);
269+
NSNumber *sessionDuration = @([OSSessionManager getTimeFocusedElapsed]);
269270

270-
// Initial request
271-
[self attemptFetchWithRetries:subscriptionId
272-
rywToken:rywToken
273-
sessionDuration:sessionDuration
274-
attempts:@0 // Starting with 0 attempts
275-
retryLimit:nil]; // Retry limit to be set dynamically on first failure
271+
// Initial request
272+
[self attemptFetchWithRetries:subscriptionId
273+
rywToken:rywToken
274+
sessionDuration:sessionDuration
275+
attempts:@0 // Starting with 0 attempts
276+
retryLimit:nil]; // Retry limit to be set dynamically on first failure
277+
});
276278
}
277279

280+
278281
- (void)attemptFetchWithRetries:(NSString *)subscriptionId
279282
rywToken:(NSString *)rywToken
280283
sessionDuration:(NSNumber *)sessionDuration

0 commit comments

Comments
 (0)