【问题标题】:react native render push notification android反应原生渲染推送通知android
【发布时间】:2017-08-10 16:25:15
【问题描述】:

我正在使用 react-native-push-notification 库向 android 推送通知。 我使用 GCM 从我的服务器收到通知。 我得到了“onNotification”功能,当我控制台它时,我在控制台中看到消息通知。 如何呈现通知并向用户显示每个通知,包括按钮?我尝试通过状态或调用函数保存接收到的通知,但它不起作用,似乎不知道外部函数。

这是代码-

 componentDidMount(){
        PushNotification.configure({

            onNotification: function(notification) {
                console.log( 'NOTIFICATION:', notification );
            },
           
            senderID: "********",
            popInitialNotification: true,


        });
    }



render() {
            return(
                <View>
                    <Text>Notification</Text>
                </View>

            );

        }

}

谢谢!

【问题讨论】:

    标签: android react-native push-notification


    【解决方案1】:

    对于 Android,我建议使用 FCM(Firebase 云消息传递)。此外,react-native-push-notification 包很难在 Android 上配置和使用。我会推荐使用 react-native-firebase。

    我已经发布了一个关于如何使用FCM and react-native-firebase 的教程。

    【讨论】:

      【解决方案2】:

      如果您想要通知按钮并单击该按钮运行特定功能,那么您应该尝试

      react-native-notifications

      它允许您为应用程序之外的用户提供额外的功能,例如操作按钮。

      【讨论】:

        猜你喜欢
        • 2017-12-18
        • 2016-05-29
        • 2018-01-17
        • 1970-01-01
        • 2020-05-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多