Ionic does not receive token in the background, only in the foreground
While the application is open in HomePage
I get the notification by the alert, but when this application closes I do not get the notification
home.ts
setTokenPush(){
const options: PushOptions = {
android: {
},
ios: {
alert: 'true',
badge: true,
sound: 'true'
},
windows: {},
browser: {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
}
};
const pushObject: PushObject = this.push.init(options);
pushObject.on('notification').subscribe((notification: any) => {
alert(notification.message);
});
pushObject.on('registration').subscribe((registration: any) => {
this.configPushUser(registration.registrationId);
});
pushObject.on('error').subscribe(error => {
});
}
configPushUser(token){
this.webservice.configPushUser(token).subscribe(data=>{
});
}
Even sending by firebase cloud message I do not get …
Send Notification backend config(laravel+php)
$data = array(
"to" => $user->token_push,
"notification" => [
"title" =>'You receive '.$value.' Bitcoin' ,
"sound" => "default",
"body" => 'Tap to view',
],
"data" => [
"data" =>[
"datas" => [
"ethereum"=>$ethereum,
"bitcoin"=>$bitcoin,
"litecoin"=>$litecoin,
] ,
],
],
);
$data = json_encode($data);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://fcm.googleapis.com/fcm/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => array(
"Authorization: key=AAA*****...",
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);