Skip to content

Commit

Permalink
Added more logging to the ServiceWorkerManager
Browse files Browse the repository at this point in the history
  • Loading branch information
jkasten2 committed Feb 19, 2021
1 parent 2a06b81 commit 03713a3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/managers/ServiceWorkerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,16 @@ export class ServiceWorkerManager {
// notification permissions are enabled we should install.
// This prevents an unnessary install which saves bandwidth
const workerState = await this.getActiveState();
Log.debug("[shouldInstallWorker] workerState", workerState);
if (workerState === ServiceWorkerActiveState.None || workerState === ServiceWorkerActiveState.ThirdParty) {
const permission = await OneSignal.context.permissionManager.getNotificationPermission(
OneSignal.config!.safariWebId
);
return permission === "granted";
const notificationsEnabled = permission === "granted";
if (notificationsEnabled) {
Log.info("[shouldInstallWorker] Notification Permissions enabled, will install ServiceWorker");
}
return notificationsEnabled;
}

// 5. We have a OneSignal ServiceWorker installed, but did the path or scope of the ServiceWorker change?
Expand Down Expand Up @@ -291,6 +296,7 @@ export class ServiceWorkerManager {
}

public async establishServiceWorkerChannel() {
Log.debug('establishServiceWorkerChannel');
const workerMessenger = this.context.workerMessenger;
workerMessenger.off();

Expand Down

0 comments on commit 03713a3

Please sign in to comment.