b8ne / react-native-pusher-push-notifications

Manage pusher interest subscriptions and notification events in Javascript.
MIT License
96 stars 85 forks source link

Has anyone got this to work on Android? #90

Open jm90m opened 2 years ago

jm90m commented 2 years ago

Hello,

I've followed the setup exactly for android, not too sure what I am missing.

Project is here - https://github.com/snapshot-labs/snapshot-app

I can't seem to receive a notification on my android device. This function never gets called handleNotification

RNPusherPushNotifications.on("notification", handleNotification);

I know people are busy, so I can offer crypto for someones time on helping me with this issue.

Thavananthan commented 2 years ago

hi, you can try this methods..

RNPusherPushNotifications.on('notification',(notification) => { handleNotification(notification); });

const handleNotification = async (notification) => { screen.props.getNotifications(10, screen, screen.props.navigation); // iOS app specific handling if (Platform.OS === 'ios') { switch (notification.appState) { case 'inactive': // inactive: App came in foreground by clicking on notification. // Use notification.userInfo for redirecting to specific view controller case 'background': // background: App is in background and notification is received. // You can fetch required data here don't do anything with UI case 'active': // App is foreground and notification is received. Show a alert or something. default: break; } } else { // console.log("android handled notification..."); } };

gabrielbezerra81 commented 2 years ago

Using this lib with react-native-notifications helped a lot for Android, its working fine here with background and foreground notifications.

anastely commented 2 years ago

@gabrielbezerra81 How do you integrate it with pusher?