0
我试图通过令牌ID从Firebase控制台向我的ios设备发送推送通知。我正在使用react-native-firebase来允许应用根据通知事件执行操作。我跟着指示,将SDK整合,并成立了APNS证书等:无法使用react-native-firebase从Firebase控制台发送推送通知
http://invertase.io/react-native-firebase/#/installation-ios
我firebase.js
配置文件看起来是这样的:
import RNFirebase from 'react-native-firebase';
const configurationOptions = {
debug: true
};
const firebase = RNFirebase.initializeApp(configurationOptions);
export default firebase;
我的主要阵营组成部分看起来是这样的:
import React, { Component } from 'react'
import {
Text,
View,
Alert,
Platform
} from 'react-native'
import firebase from './firebase'
export default class extends Component {
constructor(props) {
super(props)
this.state = {
token: ''
}
}
componentDidMount() {
firebase.messaging().getToken()
.then((token) => {
this.setState({ token })
console.log('token: ', token)
})
firebase.messaging().getInitialNotification()
.then((notification) => {
console.log('Notification which opened the app: ', notification)
})
firebase.messaging().onMessage((message) => {
console.log('messaging', message)
})
firebase.messaging().onTokenRefresh((token) => {
console.log('Refreshed FCM token: ', token)
})
}
render() {
return (
<View style={{ marginTop: 22 }}>
<Text>{this.state.token}</Text>
</View>
)
}
}
我在组件装入后成功获取令牌,然后在Firebase控制台中使用该令牌发送通知,但未收到通知。我正在使用真实设备,而不是iPhone。我正在使用启用了推送通知的开发资源调配配置文件,并成功启用了移除通知背景权利以及已上传到Firebase控制台的相应开发APN证书。
为什么我没有收到设备上的通知?