-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1079 from OneSignal/fix/sw-click-and-confirm-deli…
…very-calls [User Model] [Fix] Notification Open & Confirm Delivery REST API calls failing
- Loading branch information
Showing
2 changed files
with
36 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import EncodedModel from "../../core/caching/EncodedModel"; | ||
import { ModelName } from "../../core/models/SupportedModels"; | ||
import Database from "../../shared/services/Database"; | ||
|
||
/** | ||
* WARNING: This is a temp workaround for the ServiceWorker context only! | ||
* PURPOSE: CoreModuleDirector doesn't work in the SW context. | ||
* TODO: This is duplicated logic tech debt to address later | ||
*/ | ||
export class ModelCacheDirectAccess { | ||
static async getPushSubscriptionIdByToken(token: string): Promise<string | undefined> { | ||
const pushSubscriptions = await Database.getAll<EncodedModel>(ModelName.PushSubscriptions); | ||
for(const pushSubscription of pushSubscriptions) { | ||
if (pushSubscription["token"] === token) { | ||
return pushSubscription["id"] as string; | ||
} | ||
} | ||
return undefined; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters