2

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

5

1 Answer 1

3

.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");
Sign up to request clarification or add additional context in comments.

1 Comment

oh thanks a lot it worked :D I will accept this as answer asap

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.