@@ -4,6 +4,7 @@ import android.content.Context
4
4
import com.onesignal.IOneSignal
5
5
import com.onesignal.common.IDManager
6
6
import com.onesignal.common.OneSignalUtils
7
+ import com.onesignal.common.exceptions.BackendException
7
8
import com.onesignal.common.modeling.ModelChangeTags
8
9
import com.onesignal.common.modules.IModule
9
10
import com.onesignal.common.safeString
@@ -254,7 +255,7 @@ internal class OneSignalImp : IOneSignal, IServiceProvider {
254
255
Logging .log(LogLevel .DEBUG , " login(externalId: $externalId , jwtBearerToken: $jwtBearerToken )" )
255
256
256
257
if (! isInitialized) {
257
- throw Exception ( " Must call 'initWithContext' before use " )
258
+ Logging .log( LogLevel . ERROR , " Must call 'initWithContext' before using Login " )
258
259
}
259
260
260
261
var currentIdentityExternalId: String? = null
@@ -306,28 +307,29 @@ internal class OneSignalImp : IOneSignal, IServiceProvider {
306
307
)
307
308
308
309
if (! result) {
309
- throw Exception (" Could not login user" )
310
+ Logging .log(LogLevel .ERROR , " Could not login user" )
311
+ } else {
312
+ // enqueue a RefreshUserOperation to pull the user from the backend and refresh the models.
313
+ // This is a separate enqueue operation to ensure any outstanding operations that happened
314
+ // after the createAndSwitchToNewUser have been executed, and the retrieval will be the
315
+ // most up to date reflection of the user.
316
+ _operationRepo !! .enqueueAndWait(
317
+ RefreshUserOperation (
318
+ _configModel !! .appId,
319
+ _identityModelStore !! .model.onesignalId,
320
+ ),
321
+ true ,
322
+ )
310
323
}
311
-
312
- // enqueue a RefreshUserOperation to pull the user from the backend and refresh the models.
313
- // This is a separate enqueue operation to ensure any outstanding operations that happened
314
- // after the createAndSwitchToNewUser have been executed, and the retrieval will be the
315
- // most up to date reflection of the user.
316
- _operationRepo !! .enqueueAndWait(
317
- RefreshUserOperation (
318
- _configModel !! .appId,
319
- _identityModelStore !! .model.onesignalId,
320
- ),
321
- true ,
322
- )
323
324
}
324
325
}
325
326
326
327
override fun logout () {
327
328
Logging .log(LogLevel .DEBUG , " logout()" )
328
329
329
330
if (! isInitialized) {
330
- throw Exception (" Must call 'initWithContext' before use" )
331
+ Logging .log(LogLevel .ERROR , " Must call 'initWithContext' before using Login" )
332
+ return
331
333
}
332
334
333
335
// only allow one login/logout at a time
0 commit comments