Closed Kikketer closed 2 weeks ago
@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.
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.
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:
The slidedown (which waits the proper 5 seconds) shows as:![image](https://github.com/OneSignal/OneSignal-Website-SDK/assets/958042/097b660c-25f2-4c0b-9a5d-28d89c63c872)
Other adjustments I make to this initialize work properly (add/remove the notifyButton, alter the time delay, etc). I've tried placing the
actionMessage
inpromptOptions
,promptOptions.slidedown
andpromptOptions.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?
What did you expect to happen?
The actionMessage (and button text) to be updated properly.
Relevant log output