Skip to content

Commit

Permalink
Merge pull request #1194 from OneSignal/fix/logout_without_push_sub_2…
Browse files Browse the repository at this point in the history
…024-09-19

Fix logout() when push subscription doesn't exists
  • Loading branch information
jkasten2 authored Sep 20, 2024
2 parents 1f64c20 + 76d018a commit 24895d0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/page/managers/LoginManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,20 @@ export default class LoginManager {
const pushSubModel =
await OneSignal.coreDirector.getPushSubscriptionModel();
await OneSignal.coreDirector.resetModelRepoAndCache();

// Initialize as a local User, as we don't have a push subscription to create a remote anonymous user.
if (pushSubModel === undefined) {
await UserDirector.initializeUser(true);
return;
}

// add the push subscription model back to the repo since we need at least 1 sub to create a new user
OneSignal.coreDirector.add(
ModelName.PushSubscriptions,
pushSubModel as OSModel<SupportedModel>,
false,
);
// Initialize as non-local, make a request to OneSignal to create a new anonymous user
await UserDirector.initializeUser(false);
}

Expand Down

0 comments on commit 24895d0

Please sign in to comment.