-
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 #745 from OneSignal/feat/remove_sw_page_control_re…
…quirement Remove ServiceWorker Page Control Requirement
- Loading branch information
Showing
30 changed files
with
350 additions
and
361 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
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 @@ | ||
importScripts("https://localhost:4001/sdks/Dev-OneSignalSDKWorker.js"); |
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 @@ | ||
importScripts("https://localhost:4001/sdks/Dev-OneSignalSDKWorker.js"); |
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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,24 @@ | ||
import Log from "../../libraries/Log"; | ||
|
||
export default class ServiceWorkerUtilHelper { | ||
// Get the service worker based on a scope as a domain can have none to many service workers. | ||
static async getRegistration(scope: string): Promise<ServiceWorkerRegistration | null | undefined> { | ||
try { | ||
return await navigator.serviceWorker.getRegistration(scope); | ||
} catch (e) { | ||
// This could be null in an HTTP context or error if the user doesn't accept cookies | ||
Log.warn("[Service Worker Status] Error Checking service worker registration", scope, e); | ||
return null; | ||
} | ||
} | ||
|
||
// A ServiceWorkerRegistration will have a ServiceWorker in 1 of 3 states, get which ever is available. | ||
static getAvailableServiceWorker(registration: ServiceWorkerRegistration): ServiceWorker | null { | ||
const availableWorker = registration.active || registration.installing || registration.waiting; | ||
// This never be null unless ServiceWorkerRegistration is pointing to a worker that is completely gone. | ||
if (!availableWorker) { | ||
Log.warn("Could not find an available ServiceWorker instance!"); | ||
} | ||
return availableWorker; | ||
} | ||
} |
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
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
Oops, something went wrong.