[Bug]: `actionMessage` doesn't appear to work in the initialization
Closed this issue · 2 comments
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:
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
@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.