Ionic framework 在后台收到的通知不会触发pushObject.on(';通知';)。当应用程序也是陈词滥调时
我使用php向ionic应用程序发送通知,pushObject.on('notification')仅在应用程序运行时执行,但当应用程序处于后台或关闭时,单击通知仅打开应用程序和我的pushObject.on('notification')。不叫 我已经在解决方案中做了很多有效负载版本的搜索 我的php代码是Ionic framework 在后台收到的通知不会触发pushObject.on(';通知';)。当应用程序也是陈词滥调时,ionic-framework,phonegap-pushplugin,Ionic Framework,Phonegap Pushplugin,我使用php向ionic应用程序发送通知,pushObject.on('notification')仅在应用程序运行时执行,但当应用程序处于后台或关闭时,单击通知仅打开应用程序和我的pushObject.on('notification')。不叫 我已经在解决方案中做了很多有效负载版本的搜索 我的php代码是 <?php #API access key from Google API's Console define( 'API_ACCESS_KEY', 'xxxxxxx' ); #pr
<?php
#API access key from Google API's Console
define( 'API_ACCESS_KEY', 'xxxxxxx' );
#prep the bundle
$msg = array
(
"notId"=> "test",
"body"=> "test",
"title"=> "Cabinet sahli : قرار جديد",
"vibrate"=> 1,
"sound"=>"default",
"case_number"=> "test",
"case_title"=>"test",
"case_id"=> 13,
"content-available"=> 1,
"priority"=> "high",
"additionalData"=> [
"surveyID" => "ewtawgreg-gragrag-rgarhthgbad",
]
);
$fields = array
(
//'registration_ids' => array('d7pT_z1pwYo:APA91bFK2KilUzZon1g4Yu5-bZgaqxeepcP0Owzn2a6QgGuK4HUsI-hQhRbAYANIYfl3xdDYq-k6lAsnNSFyRB4qgEH1wJqDRw6V4s3kKpg_OZHT4UZATZDo6hceZYiwzBS6eSXUfjYh'),
'registration_ids' => array('d1WrqmdONL0:APA91bFRlokdsFFOXygqnRaSuWwD7QnJIhFGoZj1wPGuWzSxFxkaEca4FPDsPxpDp1FmpZSQ6lCoTsepH2PP9KbJ7HbEGQBhT0ofx8gMbr9P-JPL8eZlff4rkY7uS3CWXAzmg0KkbChK'),
'data' => $msg,
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
#Send Reponse To FireBase Server
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
echo $result;
curl_close( $ch );
目前,该应用程序的一部分正在运行,并在
if(通知.附加数据.前台)
被执行
如果应用程序处于后台或已关闭,请单击通知仅打开应用程序
pushObject.on('notification').subscribe((notification: any) => {
let json = JSON.parse(JSON.stringify(notification.additionalData));
console.log(json);
this.storage.set('notifs',json);
console.log( this.storage.get('notifs'));
if (notification.additionalData.foreground) {
console.log('i got fired foreground');
let youralert = this.alertCtrl.create({
title: 'Nouvelle audience',
message: notification.message,
buttons: [
{
text: "تخطي التنبيه",
},
{
text: "التفاصيل",
handler: () => {
this.nav.push(CasedetailPage,{id:json.case_id,titre:json.case_title,numero:json.case_number});
}
}]
});
youralert.present();
}
else if(notification.additionalData.background) {
this.nav.push(CasedetailPage,{id:json.case_id,titre:json.case_title,numero:json.case_number});
console.log('back');
}
});