Ionic Push custom sound not works!


#1

Ionic 2 Push custom sound not works!

Please help how to do?


#2

What did you do? What code did you write?


#3

I am using FCM as backend and trying to recieve push using cordova FCM plugin. Push receved but no custom cound.

Use push plugin too. Same for it.


#4

Please show some code for implementation.


#5
   const options: PushOptions = {
          android: {
              senderID: 'Here is my send id',
              sound: true,
              vibrate: true,
              clearBadge: true,
              icon: 'icon',
              clearNotifications: true,
          },
          ios: {
              alert: true,
              badge: true,
              sound: true,
              clearBadge: true
          },
          windows: {}
      };

      const pushObject: PushObject = this.push.init(options);

      pushObject.on('notification').subscribe((notification: any) => {
          console.log('message', notification.message);
          let self = this;
          if (notification.additionalData.foreground) {
              // if application open, show popup
              let confirmAlert = this.alertCtrl.create({
                  title: 'Notification...',
                  message: JSON.stringify(notification),
                  buttons: [{
                      text: 'Ignore',
                      role: 'cancel'
                  }, {
                          text: 'View',
                          handler: () => {
                              //TODO: Your logic here
                              //self.nav.push(DetailsPage, {message: data.message});
                          }
                      }]
              });
              confirmAlert.present();
          } else {
              //if user NOT using app and push notification comes
              //TODO: Your logic on click of push notification directly
            //  this.nav.push(Contact, { message: notification.message });
          }
      });

      pushObject.on('registration').subscribe((registration: any) =>
      {
          console.log("Registration Id : " + registration);
      });

      pushObject.on('error').subscribe((error: any) => {
          console.log("Error : " + error);
      });

#6

I am sending push messages from Firebase Cloud Messaging notifications.

I am receiving messages but I don’t know how to play custom sound there.

I have placed mp3 Preformatted textsound file in res>>raw folder but nothing works.


#7

I would recommend you check on this, I hope it helps.

https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#sound

#8

I already read that documents. I have fixed the issue. I was using old version of push plugin.


#9

Anyways, Thank you so much.


#10

Hi, did u somehow tried on ios device yet? i’m facing problems on playing custom sound on ios, hope someone could help