question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
Dallas62commented, Oct 13, 2021

You define it

0reactions
jgalianozcommented, Oct 14, 2021
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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Local notification sound not playing while app in background
In short, the local notification will not be playing the sound, but instead, the app will play it (while in the background).
Read more >
Running Background Tasks | Apple Developer Forums
I simply want to notify the user by playing a sound or vibrating or both. The only way to trigger this sort of...
Read more >
Get Sound Notifications on your phone - Google Help
How to use Sound Notifications. Sound Notifications never send audio or background conversations to Google without your consent. All audio is processed locally...
Read more >
Behaviour - Notifee
By default, notifications will use the device's default notification sound, or whatever the user has chosen as the device default. If required, you...
Read more >
can we stop vibrate and play sound when push notification ...
Long answer: when the phone is set on vibrate, it is not possible to set it so that it will play a sound....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found