Звук уведомления не работает в реакции родного firebase v6? - PullRequest
0 голосов
/ 15 апреля 2020

Я отправляю уведомление пользователям, оно получено, но без звука "звук устройства по умолчанию"

Я добавляю sound: 'default' в полезную нагрузку уведомления, но все еще не работает!

вот моя функция

// Send notification for user when his order is accepted "status : pendding"
exports.acceptOrder = functions.database
  .ref('/Providers/ProvidersOrders/InProgress/{providerUid}/{orderId}')
  .onCreate(async (snapshot, context) => {
    console.log('snapshot', snapshot.val());
    const {userUID} = snapshot.val();

    const userRef = await admin
      .database()
      .ref(`/users/${userUID}`)
      .once('value');

    const {userToken, username} = userRef.val(); // FCM user app token

    try {
      const options = {
        priority: 'high',
        contentAvailable: true,
      };
      const payload = {
        notification: {
          title: 'Accepted order',
          body: `Hey! ${username}, your order has accepted we will contact with you as soon as possible.`,
          timestamp: Date.now().toString(),
          isRead: 'false',
          sound: 'default',
        },
      };

      let {sound, ...notification} = payload.notification;
      let uid = userUID;

      await admin
        .messaging()
        .sendToDevice(userToken, payload, options)
        .then(() => {
          return admin
            .database()
            .ref(`Notifications/${uid}`)
            .push({...notification});
        });
      console.log('message sent');

    } catch (error) {
      console.log('Error sending message:', error);
    }
    return null;
  });

Так что здесь не так?

...