【问题标题】:Is there a way to customize remote push notifications in react native before they are showing up on frontend?有没有办法在远程推送通知出现在前端之前自定义远程推送通知?
【发布时间】:2022-07-19 12:32:53
【问题描述】:

我是 React Native 的新手,我的任务是在 React Native 中实现推送通知。我正在使用 MS Azure Notification Hub 为我的 react native 应用程序提供推送通知。本地和远程通知在我的应用程序上都可以正常工作,但问题是我从后端收到了一个非常基本的通知,没有操作和图像。我设法在我的应用程序中自定义本地通知,但我无法自定义远程通知。我想改变它的颜色、动作和添加图像。请告诉我如何才能完成我的工作?甚至可以在本机反应中自定义远程推送通知,还是必须是 MS Azure 通知中心才能自行发送所有自定义?我还尝试在 onNotification 方法中调用本地通知,以便本地通知的自定义可能会覆盖远程推送通知的样式,但它不起作用,因为一旦收到通知就会触发。请记住,我为此目的使用了 react-native-push-notification。下面是我的代码。

 PushNotification.configure({
        onRegister: (token) => {
            console.log("TOKEN", token);
        }

        onNotification: (notification) => {
            console.log('NOTIFICATION:', notification);

            PushNotification.localNotification({
                  channelId: 'demo-channel',
                  title: 'You tapped on Fruit',
                  ticker: 'Tcker',
                  message: 'Hey you got 1 Fruit',
                  bigText: 'Congratulations',
                  bigLargeIcon:
                   'https://cdn.pixabay.com/photo/2021/01/05/05/30/grapes-5889697__340.jpg',
                  bigPictureUrl:
                    'https://cdn.pixabay.com/photo/2021/01/05/05/30/grapes-5889697__340.jpg',
                  largeIconUrl:
                    'https://cdn.pixabay.com/photo/2021/01/05/05/30/grapes-5889697__340.jpg',
                  smallIcon:
                     'https://cdn.pixabay.com/photo/2021/01/05/05/30/grapes-5889697__340.jpg',
             });

})

【问题讨论】:

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


    【解决方案1】:

    如果可能,我也想知道这个答案。谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多