@@ -1598,20 +1598,40 @@ + (void)registerUser {
15981598 if ([self shouldLogMissingPrivacyConsentErrorWithMethodName: nil ])
15991599 return ;
16001600
1601- // We should delay registration if we are waiting on APNS
1602- // But if APNS hasn't responded within 30 seconds,
1603- // we should continue and register the user.
1604- if (waitingForApnsResponse && initializationTime && [[NSDate date ] timeIntervalSinceDate: initializationTime] < maxApnsWait) {
1601+ if ([self shouldRegisterUserAfterDelay ]) {
16051602 [self registerUserAfterDelay ];
16061603 return ;
16071604 }
16081605
1606+ [self registerUserNow ];
1607+ }
1608+
1609+ +(void )registerUserNow {
1610+ [OneSignal onesignal_Log: ONE_S_LL_VERBOSE message: @" registerUserNow" ];
1611+
16091612 if (!serialQueue)
16101613 serialQueue = dispatch_queue_create (" com.onesignal.regiseruser" , DISPATCH_QUEUE_SERIAL);
1611-
1612- dispatch_async (serialQueue, ^{
1614+
1615+ dispatch_async (serialQueue, ^{
16131616 [self registerUserInternal ];
1614- });
1617+ });
1618+ }
1619+
1620+ // We should delay registration if we are waiting on APNS
1621+ // But if APNS hasn't responded within 30 seconds (maxApnsWait),
1622+ // we should continue and register the user.
1623+ + (BOOL )shouldRegisterUserAfterDelay {
1624+ [OneSignal onesignal_Log: ONE_S_LL_VERBOSE message: [NSString stringWithFormat: @" registerUser:waitingForApnsResponse: %d " , waitingForApnsResponse]];
1625+ [OneSignal onesignal_Log: ONE_S_LL_VERBOSE message: [NSString stringWithFormat: @" registerUser:initializationTime: %@ " , initializationTime]];
1626+
1627+ // If there isn't an initializationTime yet then the SDK hasn't finished initializing so we should delay
1628+ if (!initializationTime)
1629+ return true ;
1630+
1631+ if (!waitingForApnsResponse)
1632+ return false ;
1633+
1634+ return [[NSDate date ] timeIntervalSinceDate: initializationTime] < maxApnsWait;
16151635}
16161636
16171637+ (void )registerUserInternal {
0 commit comments