Open dosercz opened 7 months ago
@dosercz Thanks for reporting this! Responding to each question in the sections below.
I am able to reproduce the result you are seeing with the code you provided. We will look into accounting for this scenario so this isn't a problem in the future, in the meantime there is a work around:
window.OneSignalDeferred = window.OneSignalDeferred || [];
OneSignalDeferred.push(async function(OneSignal) {
await OneSignal.init({
appId: $appId,
autoResubscribe: true,
notifyButton: {
enable: true,
position: 'bottom-left'
}
});
OneSignal.User.addTags({
cart_update: '',
product_name: '',
product_image: ''
});
});
If the redirect location is on your same domain and is a page you also initialize OneSignal the SDK will send the tags once the new page has loaded. If you are redirecting to a different domain then the tags will only be sent once the user has revisited your page.
@jkasten2 thanks for help, 1. workaround works fine, but 2. seems it doesn't work for me, we have OneSignal initialized at all pages, but if tags were not sent to server at page, where they were added via OneSignal.User.addTags(), they are not sent after redirect/navigation (I'm not sure if never but in the most cases). Could you check it please?
How can we help?
I'm trying to addTags() in javascript web sdk v16. All User functions should be synchronous there. But added tags are not send to server in two cases: 1) Tags are added on page load and OneSignal is not init probably yet. 2) Tags are added before page redirect and redirect is done before tags are sent to server probably. It works fine, if page is loaded and there is only small delay before api request to server.
Loaded SDK https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.js with defer attribute. 1) Page load use case:
How can I wait for OneSignal init?
2 Redirect use case:
How can I wait to saving tags?