@@ -403,7 +403,10 @@ static OSInAppMessageController getInAppMessageController() {
403
403
private static HashSet <String > postedOpenedNotifIds = new HashSet <>();
404
404
private static final ArrayList <OSGetTagsHandler > pendingGetTagsHandlers = new ArrayList <>();
405
405
406
- static DelayedConsentInitializationParameters delayedInitParams ;
406
+ private static DelayedConsentInitializationParameters delayedInitParams ;
407
+ static DelayedConsentInitializationParameters getDelayedInitParams () {
408
+ return delayedInitParams ;
409
+ }
407
410
408
411
// Start PermissionState
409
412
private static OSPermissionState currentPermissionState ;
@@ -730,9 +733,8 @@ synchronized private static void init(Context context) {
730
733
}
731
734
732
735
static void onRemoteParamSet () {
733
- if (delayedInitParams != null ) // Remote Params called from init
734
- reassignDelayedInitParams ();
735
- else if (inForeground ) // Remote Params called from onAppFocus
736
+ boolean initDelayed = reassignDelayedInitParams ();
737
+ if (!initDelayed && inForeground ) // Remote Params called from onAppFocus
736
738
onAppFocusLogic ();
737
739
}
738
740
@@ -983,17 +985,33 @@ public static void provideUserConsent(boolean consent) {
983
985
}
984
986
}
985
987
986
- private static void reassignDelayedInitParams () {
988
+ private static boolean reassignDelayedInitParams () {
989
+ String delayedAppId ;
990
+ Context delayedContext ;
991
+ if (delayedInitParams == null ) {
992
+ // Get the cached app id, if it exists
993
+ delayedAppId = getSavedAppId ();
994
+ delayedContext = appContext ;
995
+ logger .error ("Trying to continue OneSignal with null delayed params" );
996
+ } else {
997
+ delayedAppId = delayedInitParams .appId ;
998
+ delayedContext = delayedInitParams .context ;
999
+ }
1000
+
987
1001
logger .debug ("reassignDelayedInitParams with appContext: " + appContext );
988
- Context delayedContext = delayedInitParams .context ;
989
- String delayedAppId = delayedInitParams .appId ;
990
1002
991
1003
delayedInitParams = null ;
992
1004
setAppId (delayedAppId );
993
1005
994
1006
// Check to avoid extra initWithContext logging and logic
995
- if (!initDone )
1007
+ if (!initDone ) {
1008
+ if (delayedContext == null ) {
1009
+ logger .error ("Trying to continue OneSignal with null delayed params context" );
1010
+ return false ;
1011
+ }
996
1012
initWithContext (delayedContext );
1013
+ }
1014
+ return true ;
997
1015
}
998
1016
999
1017
static OneSignalRemoteParams .Params getRemoteParams () {
0 commit comments