Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: migration issue from v2 to v3 #125

Open
sshanzel opened this issue Oct 6, 2023 · 5 comments
Open

[Bug]: migration issue from v2 to v3 #125

sshanzel opened this issue Oct 6, 2023 · 5 comments

Comments

@sshanzel
Copy link

sshanzel commented Oct 6, 2023

What happened?

As recommended, we are migrating our existing implementation of v2 to v3.

I am receiving an error during initialization. Nothing was changed from my config so I am wondering why I'm getting this error.

I have also cleared the cache and deleted the service worker to start things clean.

Initialization config:

await OneSignalReact.init({
  appId: '04cddacf-5920-47a6-b567-9ae334d26681',
  allowLocalhostAsSecureOrigin: true,
  serviceWorkerParam: { scope: '/push/onesignal/' },
  serviceWorkerPath: '/push/onesignal/OneSignalSDKWorker.js',
});

What browsers are you seeing the problem on?

Chrome (Chromium)

What operating system are you running?

macOS Ventura 13.1

Steps to reproduce?

1. Create an app
2. Create a useEffect that runs once.
3. Initialize the config mentioned above.

What did you expect to happen?

Work as how it did before. Initialize as it used to be on v2.

Relevant log output

# Error log from the console:
TypeError: Cannot read properties of undefined (reading 'message')
    at Database.js:102:42
    at new Promise (<anonymous>)
    at P.<anonymous> (Database.js:101:26)
    at Generator.next (<anonymous>)
    at tslib.es6.js:121:71
    at new Promise (<anonymous>)
    at o (tslib.es6.js:117:12)
    at P.getAll (OneSignalSDK.page.es6.js?v=160002:1:300760)
    at P.<anonymous> (Database.js:591:49)
    at Generator.next (<anonymous>)
    at tslib.es6.js:121:71
    at new Promise (<anonymous>)
    at o (tslib.es6.js:117:12)
    at P.getAll (OneSignalSDK.page.es6.js?v=160002:1:314462)
    at Yi.<anonymous> (ModelCache.js:95:22)
    at Generator.next (<anonymous>)
    at tslib.es6.js:121:71
    at new Promise (<anonymous>)
    at o (tslib.es6.js:117:12)
    at Yi.getCachedEncodedModels (OneSignalSDK.page.es6.js?v=160002:1:238371)
    at Yi.<anonymous> (ModelCache.js:103:35)
    at Generator.next (<anonymous>)
    at tslib.es6.js:121:71
    at new Promise (<anonymous>)
    at o (tslib.es6.js:117:12)
    at Yi.getAndDecodeModelsWithModelName (OneSignalSDK.page.es6.js?v=160002:1:238544)
    at Yi.<anonymous> (ModelCache.js:67:47)
    at Generator.next (<anonymous>)
    at tslib.es6.js:121:71
    at new Promise (<anonymous>)
    at o (tslib.es6.js:117:12)
    at Yi.load (OneSignalSDK.page.es6.js?v=160002:1:237947)
    at new On (CoreModule.js:15:14)
    at Tn.<anonymous> (OneSignal.js:38:22)
    at Generator.next (<anonymous>)
    at tslib.es6.js:121:71
    at new Promise (<anonymous>)
    at o (tslib.es6.js:117:12)
    at Tn._initializeCoreModuleAndOSNamespaces (OneSignalSDK.page.es6.js?v=160002:1:267505)
    at Tn.<anonymous> (OneSignal.js:120:25)
    at Generator.next (<anonymous>)
    at r (tslib.es6.js:118:58)

# Logs with `Debug.setLogLevel('trace')`:
{
  "appId": "04cddacf-5920-47a6-b567-9ae334d26681",
  "subdomain": "localdailydev",
  "siteName": "Local daily.dev",
  "origin": "http://webapp.local.com:5002",
  "restrictedOriginEnabled": true,
  "metrics": {
    "enable": true,
    "mixpanelReportingToken": "7c2582e45a6ecf1501aa3ca7887f3673"
  },
  "safariWebId": "web.onesignal.auto.2b0cd0f2-3d64-4a96-b6d2-c215d89cc9e7",
  "vapidPublicKey": "modified",
  "onesignalVapidPublicKey": "modified",
  "userConfig": {
    "appId": "04cddacf-5920-47a6-b567-9ae334d26681",
    "autoRegister": false,
    "autoResubscribe": false,
    "path": "/",
    "serviceWorkerPath": "OneSignalSDKWorker.js",
    "serviceWorkerParam": {
      "scope": "/"
    },
    "subdomainName": "localdailydev",
    "promptOptions": {
      "autoPrompt": true,
      "native": {
        "enabled": false,
        "autoPrompt": false,
        "pageViews": 1,
        "timeDelay": 0
      },
      "slidedown": {
        "prompts": [
          {
            "icon": "",
            "text": {
              "acceptButton": "Subscribe",
              "cancelButton": "Later",
              "actionMessage": "Subscribe to our notifications for the latest news and updates. You can disable anytime.",
              "confirmMessage": "Thank You!",
              "customizationEnabled": false,
              "emailLabel": "Email Address",
              "smsLabel": "Phone Number",
              "negativeUpdateButton": "Cancel",
              "positiveUpdateButton": "Save Preferences",
              "updateMessage": "Update your push notification subscription preferences."
            },
            "type": "push",
            "delay": {
              "pageViews": 1,
              "timeDelay": 10
            },
            "enabled": true,
            "autoPrompt": true
          }
        ]
      },
      "fullscreen": {
        "enabled": false,
        "actionMessage": "Subscribe to our notifications for the latest news and updates. You can disable anytime.",
        "acceptButton": "Continue",
        "cancelButton": "No Thanks",
        "title": "example.com",
        "message": "This is an example notification message.",
        "caption": "You can unsubscribe anytime",
        "autoAcceptTitle": "Click Allow"
      },
      "customlink": {
        "enabled": false,
        "style": "button",
        "size": "medium",
        "unsubscribeEnabled": false,
        "text": {
          "explanation": "",
          "subscribe": "",
          "unsubscribe": ""
        },
        "color": {
          "button": "",
          "text": ""
        }
      }
    },
    "welcomeNotification": {
      "disable": false,
      "title": null,
      "message": null,
      "url": "http://webapp.local.com:5002/?_osp=do_not_open"
    },
    "notifyButton": {
      "enable": false,
      "displayPredicate": null,
      "size": "large",
      "position": "bottom-right",
      "showCredit": false,
      "offset": {
        "bottom": "15px",
        "left": "15px",
        "right": "15px"
      },
      "colors": {
        "circle.background": "#E12D30",
        "circle.foreground": "white",
        "badge.background": "black",
        "badge.foreground": "white",
        "badge.bordercolor": "black",
        "pulse.color": "white",
        "dialog.button.background.hovering": "#E12D30",
        "dialog.button.background.active": "#E12D30",
        "dialog.button.background": "#E12D30",
        "dialog.button.foreground": "white"
      },
      "text": {
        "tip.state.unsubscribed": "Subscribe to notifications",
        "tip.state.subscribed": "You're subscribed to notifications",
        "tip.state.blocked": "You've blocked notifications",
        "message.prenotify": "Subscribe to notifications",
        "message.action.subscribing": "Thanks for subscribing!",
        "message.action.subscribed": "Thanks for subscribing!",
        "message.action.resubscribed": "Thanks for subscribing!",
        "message.action.unsubscribed": "You won't receive notifications again",
        "dialog.main.title": "Manage Notifications",
        "dialog.main.button.subscribe": "Subscribe",
        "dialog.main.button.unsubscribe": "Unsubscribe",
        "dialog.blocked.title": "Unblock Notifications",
        "dialog.blocked.message": "Click here to learn how to unblock notifications."
      }
    },
    "persistNotification": true,
    "webhooks": {
      "cors": false,
      "notification.clicked": null,
      "notification.dismissed": null
    },
    "notificationClickHandlerMatch": "exact",
    "notificationClickHandlerAction": "navigate",
    "allowLocalhostAsSecureOrigin": false,
    "outcomes": {
      "direct": {
        "enabled": false
      },
      "indirect": {
        "enabled": false,
        "influencedTimePeriodMin": 60,
        "influencedNotificationsLimit": 10
      },
      "unattributed": {
        "enabled": false
      }
    }
  },
  "enableOnSession": false,
  "sessionThreshold": 30,
  "enableSessionDuration": true
}

# Additional logs:
Called ModelCache.load({    "modelNames": [        "identity",        "properties",        "pushSubscriptions",        "emailSubscriptions",        "smsSubscriptions"    ]}) .
OneSignalUtils.js:92 Called ModelCache.getAndDecodeModelsWithModelName({    "modelName": "identity"}) .
OneSignalUtils.js:92 Called ModelCache.getCachedEncodedModels({    "modelName": "identity"}) .

@oreoluwa-bs
Copy link

Also having the same issue

@jkasten2
Copy link
Member

@sshanzel I see your site is using HTTP instead of HTTPS. The major version of OneSignal SDK has dropped support for HTTP sites and your site must start with https:// to use v3 of this react-onesignal SDK.

  • In the OneSignal dashboard you must also uncheck "My site is not fully HTTPS".

@oreoluwa-bs let us know if they is also the same issue for you.

We will provide a better SDK error message to improve the DX (developer experience) here.

@sshanzel
Copy link
Author

In the OneSignal dashboard you must also uncheck "My site is not fully HTTPS".

This does not work anymore with v3 using HTTP (for local development).

@sshanzel I see your site is using HTTP instead of HTTPS. The major version of OneSignal SDK has dropped support for HTTP sites and your site must start with https:// to use v3 of this react-onesignal SDK.

Unfortunately, our app running locally for dev environment is hosted with a different local named domain. This means the option to uncheck "Treat HTTP localhost as HTTPS for testing" is not shown. This option should be available whether it is under localhost or not so long as it is for local development/testing.

@sshanzel
Copy link
Author

We've migrated to v3, and it is easier to manage the subscriptions and everything so thanks for that. Just on Safari now, we are getting the error below:

Ct: The Safari site URL, icon size, or push certificate is invalid, or Safari is in a private session

We are not in a private session, and the config stayed the same since v2. Does it ring a bell?

@mramzan18
Copy link

We've migrated to v3, and it is easier to manage the subscriptions and everything so thanks for that. Just on Safari now, we are getting the error below:

Ct: The Safari site URL, icon size, or push certificate is invalid, or Safari is in a private session

We are not in a private session, and the config stayed the same since v2. Does it ring a bell?

found any solution for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants