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]: actionMessage doesn't appear to work in the initialization #1153

Open
Kikketer opened this issue Jan 11, 2024 · 2 comments
Open

[Bug]: actionMessage doesn't appear to work in the initialization #1153

Kikketer opened this issue Jan 11, 2024 · 2 comments

Comments

@Kikketer
Copy link

Kikketer commented Jan 11, 2024

What happened?

I'm setting the actionMessage during initialization but it continues to show the default message.

SDK: https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.js

Code:

window.OneSignalDeferred.push(async (OneSignal) => {
    await OneSignal.init({
      appId: import.meta.env.VITE_PUBLIC_PUSH_APP_ID,
      safari_web_id: import.meta.env.VITE_PUBLIC_PUSH_SAFARI_ID,
      allowLocalhostAsSecureOrigin: location.hostname === 'localhost',
      promptOptions: {
        actionMessage:
          'Would you like to be notified this is a test',
        acceptButton: 'Sure',
        slidedown: {
          prompts: [
            {
              type: 'push',
              autoPrompt: true,
              delay: { timeDelay: 5 },
            },
          ],
        },
      },
      welcomeNotification: {
        disable: true,
      },
    })
  })

The slidedown (which waits the proper 5 seconds) shows as:
image

Other adjustments I make to this initialize work properly (add/remove the notifyButton, alter the time delay, etc). I've tried placing the actionMessage in promptOptions, promptOptions.slidedown and promptOptions.slidedown.prompts[0] (the documentation isn't entirely clear where this should be placed). None of these seem to work.

What browsers are you seeing the problem on?

Chrome (Chromium)

What operating system are you running?

macOS Catalina + Chrome Version 120.0.6099.199 (Official Build) (x86_64)

Steps to reproduce?

See description.
The application is a SolidJS and it's initialized in a Provider using the code above.  Changes to that initialization object apply properly except the actionMessage.

What did you expect to happen?

The actionMessage (and button text) to be updated properly.

Relevant log output

N/A
@jkasten2
Copy link
Member

@Kikketer These prompting options can be also be set from the OneSignal dashboard, see OneSignal's Setup Slide Prompt documentation.

If you really need to set these options from code you will need to set "Custom Code" on the Choose Integration step.

The JSON structor to set actionMessage under promptOptions.slidedown.prompts[]. Example:

promptOptions: {
  slidedown: {
    prompts: [
      {
        type: "category",
        autoPrompt: true,
        text: {
          actionMessage: "We'd like to show you notifications for the latest news and updates.",
          acceptButton: "Allow",
          cancelButton: "Cancel",

          /* CATEGORY SLIDEDOWN SPECIFIC TEXT */
          negativeUpdateButton: "Cancel",
          positiveUpdateButton: "Save Preferences",
          updateMessage: "Update your push notification subscription preferences.",
        },
      }
    ]
  }
}

OneSignal init documentation for more details on init params:
https://documentation.onesignal.com/docs/web-sdk#init-notifybutton-parameters

However again, for these options to work with JS code you must have "Custom Code" on the Choose Integration step.

@Kikketer
Copy link
Author

I'll be able to re-verify later this month as I've currently POC'd the usecase of it and will actually implement it by the end of the month.

Thanks for the response. I'll post again here when/if I get it updated and it works.

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

2 participants