I have a web view app with OneSignal integrated into it. All I'm trying to do is add tags to that user when clicked on a button in OneSignal using the below code :
<button onclick="buttonclicked()" >some</button>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async=""></script>
<script>
window.OneSignal = window.OneSignal || [];
OneSignal.push(function() {
OneSignal.init({
appId: "xxxxx",
});
});
function buttonclicked() {
console.log("click");
OneSignal.push(function() {
OneSignal.sendTags({sub_url:window.location.href, topic:'tags'}).then(function(tagsSent) {
console.log("tagssent:" + JSON.stringify(tagsSent));
});
});
}
</script>
I followed exactly the same procedure as in the documentation
Not sure what went wrong, when I trigger the function through the app, the data is not being posted to OneSignal's tags field.
Any help is greatly appreciated.