React native React本机获取firebase数据库推送令牌密钥

React native React本机获取firebase数据库推送令牌密钥,react-native,React Native,这是我的参考资料。每次在我的firebase数据库中调用此函数时,它都会在唯一令牌下创建一组新数据[如下]:。我想得到那个代币 let ref = firebase.database().ref('Products') let newProduct = ref.push(newProduct) newProduct.set({ color: color, time: Date.now(), }) 对!!我看到了一些类似的问题,但没有一个能

这是我的参考资料。每次在我的firebase数据库中调用此函数时,它都会在唯一令牌下创建一组新数据[如下]:。我想得到那个代币

let ref = firebase.database().ref('Products')
    let newProduct = ref.push(newProduct)
    newProduct.set({
        color: color,
        time: Date.now(),
    })
对!!我看到了一些类似的问题,但没有一个能帮到我。 一些请帮助

我想这就是你需要的:


在您当前的代码
newProduct.key
中,我认为应该已经正确设置了。

不清楚您在问什么。请更详细地更新您的问题。它已更新。请现在检查
// Generate a reference to a new location and add some data using push()
var newPostRef = postsRef.push();

// Get the unique key generated by push()
var postId = newPostRef.key;