Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29610

Default Sound notification from firebase not work in Android?

$
0
0

I'm trying to send a notification using cloud functions to android devices,

It's received well but without default notification sound it's silent.

although in sendToDevice option I send it like this

sound: 'default',

Code snippet

// Send notification for provider when his order is cancelled removed!exports.userCancelOrder = functions.database  .ref('/Providers/ProvidersOrders/InProgress/{providerUid}/{orderId}')  .onUpdate(async (snapshot, context) => {    const orderdata = snapshot.before.val();    const {username} = orderdata;    const {providerUid} = context.params;    const userRef = await admin      .database()      .ref(`/Providers/users/${providerUid}`)      .once('value');    console.log('userRef', userRef.val());    const {userToken} = userRef.val(); // FCM user app token    const providerName = userRef.val().name;    try {      const options = {        priority: 'high',        contentAvailable: true, // NOT content_available: true      };      const payload = {        notification: {          body: `hey, ${providerName}, your order canclled by ${username} :) `,          timestamp: Date.now().toString(),          isRead: 'false',          sound: 'default', // here's         },      };      let {sound, ...notification} = payload.notification;      let uid = providerUid;      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;  });

Viewing all articles
Browse latest Browse all 29610

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>