当应用程序在后台或关闭时,本机推送通知不显示横幅(在屏幕上弹出)

时间:2019-04-06 13:26:39

标签: firebase react-native firebase-cloud-messaging react-native-push-notification

我正在使用react-native-push-notification并关注其文档。当应用程序位于前台时,它运行良好,但是当应用程序位于后台时,我尝试从Firebase控制台发送通知,只是在状态栏中显示了该应用程序的一个小图标,但未显示横幅

我试图添加一个新频道,但仍然无法正常工作 aaa

componentDidMount() {

        NetInfo.isConnected.addEventListener('connectionChange', this.handleConnectivityChange);

        PushNotification.configure({

            // (optional) Called when Token is generated (iOS and Android)
            onRegister: function(token) {
                console.log( 'TOKEN:', token );
            },

            // (required) Called when a remote or local notification is opened or received
            onNotification: function(notification) {
                console.log( 'NOTIFICATION:', notification );

                Platform.OS === 'ios' ? notification.finish(PushNotificationIOS.FetchResult.NoData) : null;
            },

            // ANDROID ONLY: GCM or FCM Sender ID (product_number) (optional - not required for local notifications, but is need to receive remote push notifications)
            senderID: Variables.GCM_SENDER_ID,

            // IOS ONLY (optional): default: all - Permissions to register.
            permissions: {
                alert: true,
                badge: true,
                sound: true
            },

            visibility: 'public',

            popInitialNotification: true,

            requestPermissions: true,
        });
    }

0 个答案:

没有答案