zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.76k stars 2.05k forks source link

Local Notification don't play sound or vibrate in background on IOS #2118

Closed faizanbuggy closed 1 month ago

faizanbuggy commented 3 years ago

I am using Firebase push notifications and they are working fine i.e with sound and vibration but when the app is in background mode then the notification is being received without vibration and sound. On Android, only sound is playing in all modes without vibration. My code is:

messaging().onMessage(async remoteMessage => {
      PushNotification.localNotification({
        vibrate: true,
        vibration: 300,
        playSound: true,
        soundName: 'default',
        importance:'high',
        invokeApp:true,
        allowWhileIdle: true,
        priority:'high',
        visibility:'public',
        /* Android Only Properties */
        title:remoteMessage.notification.title, // (optional)
        message:remoteMessage.notification.body, // (required)
        invokeApp: true,
      });
      // sendMessage(remoteMessage.notification.body, remoteMessage.notification.title)
    // Alert.alert('A new FCM message arrived!', JSON.stringify(remoteMessage));
})
jgalianoz commented 3 years ago

@faizanbuggy I have the same problem, you managed to solve it?

jgalianoz commented 3 years ago

@Dallas62

faizanbuggy commented 3 years ago

@jgalianoz Unfortunately No. Please reply with a solution if you get one. Thanks!

Dallas62 commented 3 years ago

I think the README speak about it:

  /* Android Only Properties */
  vibrate: true, // (optional) default: true

Key part: /* Android Only Properties */ And I don't see the mandatory parameter: channelId

For sound check the iOS repository or exemple project.

Regards

jgalianoz commented 3 years ago

@Dallas62 One question where I find the channelId and channelName

Dallas62 commented 3 years ago

You define it

jgalianoz commented 3 years ago
push_service.notify_multiple_devices(
 registration_ids=[registration_id_ios],
 message_body=message_body_ios,
 content_available=True,
  data_message={ },
  sound="default"
)

@faizanbuggy I resolved this by adding a sound="default" param in my service that sends the push notifications in the backend. Maybe you can try this.

github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.