Reputation: 59
Hey I am trying to add a tag to my onesignal user if something happens in my app, but it doesn't work, I just get this warning:
TypeError: _reactNativeOnesignal.default.push is not a function
I am trying to do this from a different file, so I just import onesignal on top as usual and then my code looks like this:
OneSignal.push(function() {
OneSignal.sendTags({
userId: res.auth
})
.then(function(tagsSent) {
// Callback called when tags have finished sending
console.log("tag is set: ", tagsSent);
console.log("tag shit");
})
.catch(err => {
console.log("error", err);
});
});
and when the app hits this point i get that warning and the tag is not set. Why is that? other than that the notifications are working as expected
Upvotes: 2
Views: 3391
Reputation: 6794
.push it's for the web version, the react-native one doesn't need it, you can check it at the documentation
https://documentation.onesignal.com/docs/react-native-sdk
// Sending single tag
OneSignal.sendTag("key", "value");
// Sending multiple tags
OneSignal.sendTags({key: "value", key2: "value2"});
// Getting the tags from the server and use the received object
OneSignal.getTags((receivedTags) => {
console.log(receivedTags);
});
// Delete a tag
OneSignal.deleteTag("key");
// Sending single tag
OneSignal.sendTag("key", "value");
// Sending multiple tags
OneSignal.sendTags({key: "value", key2: "value2"});
// Getting the tags from the server and use the received object
OneSignal.getTags((receivedTags) => {
console.log(receivedTags);
});
// Delete a tag
OneSignal.deleteTag("key");
Upvotes: 3