小编ami*_*ito的帖子

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

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

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

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: …
Run Code Online (Sandbox Code Playgroud)

firebase react-native firebase-cloud-messaging react-native-push-notification

7
推荐指数
1
解决办法
473
查看次数