-
Notifications
You must be signed in to change notification settings - Fork 114
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
[Question]: OneSignal.User.addTags() is not synchronous and tags are not send #1147
Comments
@dosercz Thanks for reporting this! Responding to each question in the sections below. 1. Tags are added on page load and OneSignal is not init probably yet.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: ''
});
}); 2. Tags are added before page redirect and redirect is done before tags are sent to server probably.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? |
We're experiencing the same problem. |
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:
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.
How can I wait for OneSignal init?
2 Redirect use case:
How can I wait to saving tags?
The text was updated successfully, but these errors were encountered: