嘿,如果我的应用中发生了一些事情,我想尝试向我的onesignal用户添加标签,但是它不起作用,我只是收到以下警告:
TypeError:_reactNativeOnesignal.default.push不是函数
我正在尝试从其他文件中执行此操作,因此我像往常一样只是将onesignal导入到顶部,然后我的代码如下所示:
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);
});
});
,当应用程序达到此点时,我会收到警告,并且未设置标签。 这是为什么?除了通知可以按预期运行
答案 0 :(得分:1)
.push为网络版本,本机版本不需要它,您可以在文档中查看
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");