Skip to content

Commit

Permalink
improve DX by showing helpful iOS message
Browse files Browse the repository at this point in the history
  • Loading branch information
jkasten2 committed Nov 15, 2023
1 parent 9a73500 commit 2260364
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/page/utils/OneSignalShimLoader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { isPushNotificationsSupported } from './BrowserSupportsPush';
import {
isIosSafari,
isPushNotificationsSupported,
} from './BrowserSupportsPush';
// NOTE: Careful if adding imports, ES5 targets can't clean up functions never called.

// See sdk.ts for what entry points this handles
Expand Down Expand Up @@ -55,7 +58,16 @@ export class OneSignalShimLoader {
if (isPushNotificationsSupported()) {
OneSignalShimLoader.loadFullPageSDK();
} else {
console.log('OneSignal: SDK is not compatible with this browser.');
this.printEnvironmentNotSupported();
}
}

private static printEnvironmentNotSupported() {
let logMessage = 'OneSignal: SDK is not compatible with this browser.';
if (isIosSafari()) {
logMessage +=
' To support iOS please install as a Web App. See the OneSignal guide https://documentation.onesignal.com/docs/safari-web-push-for-ios';
}
console.log(logMessage);
}
}

0 comments on commit 2260364

Please sign in to comment.