Hi all,
I want to use Onesignal tags in order to send a push a subset of my users.
To register the user to receive the push notification, I use this code and it works successfully:
var notificationReceidedCallback = function (jsonData) {
console.log(jsonData);
console.log('notificationReceidedCallback: ' + JSON.stringify(jsonData));
};
var notificationOpenedCallback = function (jsonData) {
console.log(jsonData);
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
};
window["plugins"].OneSignal
.startInit(FIREBASE_APP_ID, FIREBASE_SENDER_ID)
//.InFocusDisplaying(OneSignal.OSInFocusDisplayOption.InAppAlert)
.handleNotificationOpened(notificationOpenedCallback)
.handleNotificationReceived(notificationReceidedCallback)
.endInit();
I don’t understand How add the register to specific tag. I read the official documentation https://documentation.onesignal.com/docs/web-push-sdk#section–sendtags- but I have problem at runtime:
OneSignal.push(function() {
OneSignal.sendTags({
key: 'value',
key2: 'value2',
}).then(function(tagsSent) {
// Callback called when tags have finished sending
});
});
In the console:
message: "Uncaught (in promise): TypeError: Cannot call method 'then' of undefined↵TypeError: Cannot call method 'then' of undefined↵ at MyApp.enablePush (http://localhost/build/main.js:2031:16)↵ at http://localhost/build/main.js:2090:31↵ at t.invoke (http://localhost/build/polyfills.js:3:14976)↵ at Object.zone._inner.zone._inner.fork.onInvoke (http://localhost/build/vendor.js:5396:33)↵ at t.invoke (http://localhost/build/polyfills.js:3:14916)↵ at r.run (http://localhost/build/polyfills.js:3:10143)↵ at http://localhost/build/polyfills.js:3:20242↵ at t.invokeTask (http://localhost/build/polyfills.js:3:15660)↵ at Object.zone._inner.zone._inner.fork.onInvokeTask (http://localhost/build/vendor.js:5387:33)↵ at t.invokeTask (http://localhost/build/polyfills.js:3:15581)"
Could you please support me?
Thanks in advance
Luca