File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Examples/OneSignalDemo/app/src/main/java/com/onesignal/sdktest/application
OneSignalSDK/onesignal/core/src/main/java/com/onesignal/common/modeling Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 1
1
package com .onesignal .sdktest .application ;
2
2
3
3
import android .annotation .SuppressLint ;
4
+ import android .os .Handler ;
5
+ import android .os .Looper ;
4
6
import android .os .StrictMode ;
5
7
import android .util .Log ;
6
8
import androidx .annotation .NonNull ;
@@ -61,6 +63,17 @@ public void onCreate() {
61
63
62
64
OneSignal .initWithContext (this , appId );
63
65
66
+
67
+ final Handler handler = new Handler (Looper .getMainLooper ());
68
+ handler .postDelayed (new Runnable () {
69
+ @ Override
70
+ public void run () {
71
+ // addTag after 100 ms to reliably accessing the operation model store AFTER the loading
72
+ OneSignal .getUser ().removeTag ("tag" );
73
+ OneSignal .getUser ().addTag ("tag" , "test" );
74
+ }
75
+ }, 100 );
76
+
64
77
// Ensure calling requestPermission in a thread right after initWithContext does not crash
65
78
// This will reproduce result similar to Kotlin CouroutineScope.launch{}, which may potentially crash the app
66
79
ExecutorService executor = Executors .newSingleThreadExecutor ();
Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ package com.onesignal.common.modeling
2
2
3
3
import com.onesignal.common.events.EventProducer
4
4
import com.onesignal.common.events.IEventNotifier
5
+ import com.onesignal.debug.LogLevel
6
+ import com.onesignal.debug.internal.logging.Logging
7
+ import com.onesignal.user.internal.operations.LoginUserOperation
5
8
import org.json.JSONArray
6
9
import org.json.JSONObject
7
10
import java.math.BigDecimal
@@ -81,6 +84,11 @@ open class Model(
81
84
fun initializeFromJson (jsonObject : JSONObject ) {
82
85
synchronized(data) {
83
86
data.clear()
87
+ if (this is LoginUserOperation ) {
88
+ // loading operationModelStore will get stuck for 15 seconds while locking data
89
+ Logging .log(LogLevel .DEBUG , " initializeFromJson LoginUserOperation" )
90
+ Thread .sleep(15000 )
91
+ }
84
92
for (property in jsonObject.keys()) {
85
93
val jsonValue = jsonObject.get(property)
86
94
if (jsonValue is JSONObject ) {
You can’t perform that action at this time.
0 commit comments