firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.72k stars 3.97k forks source link

FCM custom sound notifications are not working on IOS #7039

Closed saveKenny closed 3 years ago

saveKenny commented 3 years ago

I'm developing a Flutter application for both Android and IOS. I'm sending to my users custom sound notifications using Firebase Cloud Messaging (FCM).

On Android everything is just fine, I'm receiving the notifications with custom sounds. However, on IOS I'm receiving notifications with default sound.

My Node.js notification payload:

    const payload = {             notification: {                 title: 'title message',                 body: body message,             },             android: {                 priority: "high",                 notification: {                     channel_id: 'ATTENTION',                     tag: groupId,                 },             },             apns: {                 payload: {                     aps: {                         sound: "sound_03.caf"                     }                 },                 headers: {                     "apns-priority": "10"                 }             },             priority: 10         }

I'm sending the notifications using the sendMulticast method.

I have configured my Xcode as the following:

remmina_screenshot-2021-9-22-8:16:9 499391

I'm using firebase_messaging: ^10.0.3. Here is my code:

Class PushNotificationsManager {
  PushNotificationsManager._();

  factory PushNotificationsManager() => _instance;

  static final PushNotificationsManager _instance =
      PushNotificationsManager._();

  final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance;
  bool _initialized = false;

  Future<void> init() async {
    if (!_initialized) {
      // For iOS request permission first.
      _firebaseMessaging.requestPermission();
      // _firebaseMessaging.configure();

      // For testing purposes print the Firebase Messaging token
      String token = await _firebaseMessaging.getToken();
      globals.newToken = token;
...

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.2.3, on Linux, locale en_IL)                                                                                                                                        [!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)     ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses [✓] Android Studio (version 4.0) [✓] VS Code (version 1.59.1) [!] Connected device     ! No devices available

! Doctor found issues in 2 categories.

What is wrong? Why are custom notifications not working on IOS?

saveKenny commented 3 years ago

https://stackoverflow.com/a/69282586/12695188 seems that the sound files are not located correctly.