react-native-push-notification icon indicating copy to clipboard operation
react-native-push-notification copied to clipboard

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

Open faizanbuggy opened this issue 4 years ago • 8 comments

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

faizanbuggy avatar Aug 17 '21 12:08 faizanbuggy

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

jgalianoz avatar Oct 13 '21 16:10 jgalianoz

@Dallas62

jgalianoz avatar Oct 13 '21 17:10 jgalianoz

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

faizanbuggy avatar Oct 13 '21 17:10 faizanbuggy

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

Dallas62 avatar Oct 13 '21 17:10 Dallas62

@Dallas62 One question where I find the channelId and channelName

jgalianoz avatar Oct 13 '21 18:10 jgalianoz

You define it

Dallas62 avatar Oct 13 '21 19:10 Dallas62

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.

jgalianoz avatar Oct 14 '21 00:10 jgalianoz

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.

github-actions[bot] avatar Aug 17 '24 00:08 github-actions[bot]