response-native-firebase не показывает уведомление - PullRequest
0 голосов
/ 21 января 2019

Я использую react-native-firebase в своем приложении. Я следовал этому руководству и следовал всем шагам как в консоли Firebase, так и в моем App.js, но не получил никакого уведомления. Я получил токен для своего Симулятора и iPad.

Мой код

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import firebase, {Notification} from 'react-native-firebase';

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
  android:
    'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

type Props = {};
export default class App extends Component<Props> {
    componentDidMount() {
        firebase.messaging().hasPermission()
        .then(enabled => {
            if (enabled) {
                firebase.messaging().getToken().then(token => {
                    console.warn("LOG: ", token);
                })
                // user has permissions
            } else {
                firebase.messaging().requestPermission()
                .then(() => {
                    console.warn("User Now Has Permission")
                })
                .catch(error => {
                    console.warn("Error", error)
                    // User has rejected permissions  
                });
            }
        });

        this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification: Notification) => {
            console.warn('notification displayed', notification)
        // Process your notification as required
        });
        this.notificationListener = firebase.notifications().onNotification((notification: Notification) => {
            console.warn('notification', notification)
            // Process your notification as required
        });
    }

    componentWillUnmount() {
        this.notificationDisplayedListener();
        this.notificationListener();
    }

    render() {
        return (
            <View style={styles.container}>
                <Text style={styles.welcome}>Welcome to React Native!</Text>
                <Text style={styles.instructions}>To get started, edit App.js</Text>
                <Text style={styles.instructions}>{instructions}</Text>
            </View>
        );
    }
}

Любая помощь приветствуется. Спасибо.

...