react-native-in-app-notification icon indicating copy to clipboard operation
react-native-in-app-notification copied to clipboard

Passing type prop ('success', 'error', 'info' etc) to showNotification

Open albertkai opened this issue 4 years ago • 7 comments

Got any ideas on how i can pass additional props to showNotification function, in order to be able to customise the appearance, depending on the notification type. For example, i want to show green background for success notifications, and red for error etc.

albertkai avatar Jul 15 '19 00:07 albertkai

Hey @albertkai , I created a pull request showing how to achieve what you are looking for. You can take a look here. Hope it helps 🤓

VitaliiK91 avatar Sep 19 '19 01:09 VitaliiK91

Hi @VitaliiK91 , I think the documentation might be wrong, as passing additionalProps={{ type: 'error' }} will result in an error. That being said, the PR you created with instructions on how to use it does not match the documentation in the readme anyways, and trying to use it that way yields no results. Any help would be appreciated, thanks!

DrySoldier avatar May 02 '20 00:05 DrySoldier

@DrySoldier what type of error are you getting? Could you share the code snippet? As you can see in PR comments, the merged code is slightly different and README has the proper instructions, basically passProps has been renamed to additionalProps

VitaliiK91 avatar May 21 '20 15:05 VitaliiK91

@VitaliiK91 your readme has this

{
              title: 'You pressed it!',
              message: 'The notification has been triggered',
              onPress: () => Alert.alert('Alert', 'You clicked the notification!')
              additionalProps={{ type: 'error' }}
            }

and if you look at the additionalProps line, you'll see that it's incorrect JSON structure with the = sign. But looking at your code with the PR you mentioned above, I tried

{
              title: 'You pressed it!',
              message: 'The notification has been triggered',
              onPress: () => Alert.alert('Alert', 'You clicked the notification!')
              additionalProps: { type: 'error' }
            }

and the notification doesn't change in color or style whatsoever. There is no error either. It would be great if you could update the Readme with the right structure and (maybe?) one other example with all the options passed in so we understand how extensible it is.

stonebinox avatar Jul 24 '20 06:07 stonebinox

@stonebinox Hi, yes you absolutely correct, I will open a new PR for README fix. As for color or style change I am not sure what you mean? This prop will just pass additional props to the notificationBodyComponent where you can access them and style notification body. Could you share your NotificationBody component? Thank you!

VitaliiK91 avatar Aug 05 '20 22:08 VitaliiK91

@VitaliiK91 actually i figured out the NotificationBody bit so no worries. Maybe, updating the Readme with what I pointed out should be enough.

stonebinox avatar Aug 06 '20 02:08 stonebinox

@stonebinox Glad it worked for you. Yeah I opened a PR with a README fix, hopefully that would help! Cheers!

VitaliiK91 avatar Aug 06 '20 15:08 VitaliiK91