Skip to content

Commit

Permalink
Merge pull request #1139 from OneSignal/fix/show_http_no_longer_suppo…
Browse files Browse the repository at this point in the history
…rted_error

[Fix] Improve error for sites using os.tc subdomain
  • Loading branch information
jkasten2 authored Nov 21, 2023
2 parents f03bb4f + fdd667e commit 1d5d116
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/shared/utils/OneSignalUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,26 @@ export class OneSignalUtils {
}

const windowEnv = SdkEnvironment.getWindowEnv();
return (

const isHttp = location.protocol === 'http:';
const useSubdomain =
(windowEnv === WindowEnvironmentKind.Host ||
windowEnv === WindowEnvironmentKind.CustomIframe) &&
(!!subdomain || location.protocol === 'http:')
);
(!!subdomain || isHttp);

if (useSubdomain) {
if (isHttp) {
throw new Error(
"OneSignalSDK: HTTP sites are no longer supported starting with version 16 (User Model), your public site must start with https://. Please visit the OneSignal dashboard's Settings > Web Configuration to find this option.",
);
} else {
throw new Error(
'OneSignalSDK: The "My site is not fully HTTPS" option is no longer supported starting with version 16 (User Model) of the OneSignal SDK. Please visit the OneSignal dashboard\'s Settings > Web Configuration to find this option.',
);
}
}

return false;
}

public static redetectBrowserUserAgent(): IBowser {
Expand Down

0 comments on commit 1d5d116

Please sign in to comment.