OneSignal / OneSignal-Website-SDK

OneSignal is a push notification service for web and mobile apps. This SDK makes it easy to integrate your website with OneSignal Push Notifications. https://onesignal.com
Other
388 stars 115 forks source link

[Fix] Improve error for sites using os.tc subdomain #1139

Closed jkasten2 closed 10 months ago

jkasten2 commented 10 months ago

Description

1 Line Summary

Replaces confusing "TypeError: Cannot read properties of undefined (reading 'message')" with a specific error that HTTP and the "My site is not fully HTTPS" option is no longer supported.

Details

Before this change the initialization process would get too far and would result a confusing undefined error.

Dead code will be cleaned up follow up PR.

Validation

Tests

Tested with Chrome 119 on Windows 11

Checklist

Programming Checklist Interfaces:

Functions:

Typescript:

Other:

Screenshots

Before

TypeError: Cannot read properties of undefined (reading 'message')
    at Dev-OneSignalSDK.page.es6.js?v=160004:19230:46
    at new Promise (<anonymous>)
    at Database.<anonymous> (Dev-OneSignalSDK.page.es6.js?v=160004:19229:30)
    at Generator.next (<anonymous>)
    at Dev-OneSignalSDK.page.es6.js?v=160004:22237:71
    at new Promise (<anonymous>)
    at __awaiter (Dev-OneSignalSDK.page.es6.js?v=160004:22233:12)
    at Database.getAll (Dev-OneSignalSDK.page.es6.js?v=160004:19227:65)
    at Database.<anonymous> (Dev-OneSignalSDK.page.es6.js?v=160004:19863:53)
    at Generator.next (<anonymous>)

After

Uncaught (in promise) 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.
    at OneSignalUtils.internalIsUsingSubscriptionWorkaround (Dev-OneSignalSDK.page.es6.js?v=160004:21219:23)
    at ConfigHelper.getMergedConfig (Dev-OneSignalSDK.page.es6.js?v=160004:12008:109)
    at ConfigHelper.<anonymous> (Dev-OneSignalSDK.page.es6.js?v=160004:11956:40)
    at Generator.next (<anonymous>)
    at fulfilled (Dev-OneSignalSDK.page.es6.js?v=160004:22224:58)

Info

Checklist


Related Tickets



This change is Reviewable