Skip to content

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

@sshanzel

Description

@sshanzel

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"}) .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions