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

[Question]: Adding tag to user not working? #1177

Closed
LelvProgrammer opened this issue May 26, 2024 · 1 comment
Closed

[Question]: Adding tag to user not working? #1177

LelvProgrammer opened this issue May 26, 2024 · 1 comment

Comments

@LelvProgrammer
Copy link

LelvProgrammer commented May 26, 2024

I created a new one signal app, followed the steps of configuring the web script, copy-pasting the configuration added + calling the method for adding a tag, on the head of the index file

<script src="https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.js" defer></script>
<script>
	window.OneSignalDeferred = window.OneSignalDeferred || [];
	OneSignalDeferred.push(function(OneSignal) {
		OneSignal.init({
			appId: "XXXXXXXXXXXXXXXXXXXX",
		});
		OneSignal.User.addTag("test-tag", "whatever")
	});
</script>

When I go to the onesignal dashboard, I see the new client registered, but no tags assigned to him. If I were to send a message filtering for tag, the person doesn't receive the message. I feel like I'm probably just missing something silly but can't put my finger onto what that is. Anyone can help?

@shepherd-l
Copy link
Contributor

OneSignal.init({}) is an asynchronous method and you need to call await.
Try updating your code to this:

	OneSignalDeferred.push(async function(OneSignal) {
		await OneSignal.init({
			appId: "XXXXXXXXXXXXXXXXXXXX",
		});
		OneSignal.User.addTag("test-tag", "whatever")
	});

Thanks for bringing attention to this, our documentation needs to be updated
Hope this helps. Let us know if you have any issues

@emawby emawby closed this as completed Jun 18, 2024
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

3 participants