I have implemented FCM notification using PHP to send notification on mobile. Notification working properly but I want to add sound to the notification. I followed Ionic documentation for FCM.
this.fcm.getToken().then(token =>{
alert("token : "+token);
});
this.fcm.onNotification().subscribe(data => {
alert("data :"+ JSON.stringify(data));
if(data.wasTapped){
alert("Received in background : "+ JSON.stringify(data.msg));
} else {
alert("Received in foreground : "+ JSON.stringify(data.msg));
}
}, err =>{
alert("Received err : "+ err);
})
My php payload:
$message['msg'] = 'notification text';
$message['sound'] = 1;
$message['vibrate'] = 1;
$fields = array(
'registration_ids' => $tokenIds,
'data' => array('message' => $message)
);
i'm sending $fields
to notification plugin
Did anyone implement this kind of functionality?
In your push notification payload set following properties.
You need to set sound
property to default
"notification":{
"title":"Notification title",
"body":"Notification body",
"sound":"default",
"click_action":"FCM_PLUGIN_ACTIVITY",
"icon":"fcm_push_icon"
},