Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70440

Ionic native audio not works in backgroundmode

$
0
0

playAudio(){
this.backgroundMode.enable();
this.backgroundMode.on(“activate”).subscribe(()=>{
// this.backgroundMode.disableWebViewOptimizations();
console.log(‘bg’)
this.audio.play(“audio1”);
});
this.audio.play(“audio1”);
}

}

pushObject.on(‘notification’).subscribe((notification: any) =>
{

this.audio.preload(‘audio1’, ‘assets/sound/gg.mp3’);

this.playAudio()

 console.log('Received a notification', notification);
 let noti: any = notification.additionalData.notify_id;
  if(notification.additionalData.notify_id){
    Swal.fire({
      title: 'Notification',
      text: 'New Qutation Received!',
      icon: 'warning',
      showCancelButton: true,
      confirmButtonText: 'View List',
      cancelButtonText: 'Ok'
    }).then((result) => {
      if (result.value) {
        let qutationList:any = '{"access_token":"'+this.accessToken+'","operation":"Update_notification","moduleType":"transactionapproval_quotation","api_type":"web","element_data":{"action":"Update_notification","userID":"'+this.userId+'","notify_id":"'+noti+'"}}';
        this.apiservice.sendServer(qutationList).then((response:any) => {
          console.log(response);
          this.nav.navigateRoot('/quotation');
        });
  
      }
    })
  }
});

pushObject.on(‘error’).subscribe(error => console.error(‘Error with Push plugin’, error));

}

  • I call this in background ,it not works*

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70440

Trending Articles