FCM flutter enable notification vibration

Viewed 938

I'm developing a Flutter application for Android and IOS. I have created notification channels for Android according to this article.

My node.js payload:

const payload = {
      notification: {
        title: "title",
      },
      android: {
        priority: "high",
        ttl: 60 * 60 * 1,
        notification: {
          channel_id: 'YO',
        },
      },
      apns: {
        payload: {
          aps: {
            sound: "sound_03.caf"
          }
        },
        headers: {
          "apns-collapse-id": "yo",
          "apns-priority": "10"
        }
      },
      priority: 10
    }

My notifications are working just fine, for both Android and IOS. The problem is that vibration is disabled by default.

How to enable notification vibration for Android and IOS?

1 Answers

You can set the sound property to default so it makes uses the default sound if sound is enabled and it vibrates if the device is on vibrate.

You can update your payload to this:

const payload = {
  notification: {
    title: "title",
    sound: "default"
  },
  android: {
    priority: "high",
    ttl: 60 * 60 * 1,
    notification: {
      channel_id: 'YO',
    },
  },
  apns: {
    payload: {
      aps: {
        sound: "default"
      }
    },
    headers: {
      "apns-collapse-id": "yo",
      "apns-priority": "10"
    }
  },
  priority: 10
}
Related