2

I am new to React Native and I have a task to implement push notifications in react native. I am using MS Azure Notification Hub for serving push notifications for my react native app. Both the local and remote notifications are working fine on my app but the problem is that I am receiving a very basic notification from the backend without actions and images. I managed to customize local notifications in my app but I am unable to customize remote notifications. I want to change its color, actions and add images. Please tell me how can I achieve my job? Even is it possible to customize remote push notifications in react native or must it be the MS Azure Notification Hub that will send all customization by itself? I have also tried to call a local notification in onNotification method so that the customizations of the local notification may override the style of remote push notification but it did not work because notifications get triggered as soon as they are received. Remember that I am using react-native-push-notification for the purpose. Below is my code.

 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',
             });

})
Flair
  • 2,609
  • 1
  • 29
  • 41
Abdul Ahad
  • 81
  • 1
  • 9

1 Answers1

-1

There is no options to customize "remote" notifications. But you can try to create your own service for sending notifications to your app.

Make a listener from app with headless api, send requests to your service, if there is new notifications for your user, create a "local" notification with images and smth else.

Check this: headless

And this: Firebase server

Also, if you have an firebase, you can create notifications with images in firebase console

Egor
  • 1
  • 2
  • A mere link to an off-site solution is not an acceptable answer on Stack Overflow. Please at least summarize what's behind the links. – tripleee Jan 31 '23 at 08:04