Android 多个通知未分组或未单独显示
我是android编程的新手。我正在尝试将示例代码实现到我的项目中 当我成功地从远程服务器向设备发送多个通知时,当新通知出现时,当前通知将从android通知区域消失。多个通知未分组或未单独显示 我应该集中精力解决这种行为吗?先谢谢你 我的服务器php代码如下Android 多个通知未分组或未单独显示,android,google-cloud-messaging,Android,Google Cloud Messaging,我是android编程的新手。我正在尝试将示例代码实现到我的项目中 当我成功地从远程服务器向设备发送多个通知时,当新通知出现时,当前通知将从android通知区域消失。多个通知未分组或未单独显示 我应该集中精力解决这种行为吗?先谢谢你 我的服务器php代码如下 $Message = array ( 'message' => $ArrPushMessage["Message"],
$Message = array
(
'message' => $ArrPushMessage["Message"],
'title' => $ArrPushMessage["Title"],
);
$Fields = array
(
'registration_ids' => $RegistrationIds,
'data' => $Message
);
$Headers = array
(
'Authorization: key=' . GOOGLE_API_ACCESS_KEY,
'Content-Type: application/json'
);
$Curl = curl_init();
curl_setopt( $Curl,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
curl_setopt( $Curl,CURLOPT_POST, true );
curl_setopt( $Curl,CURLOPT_HTTPHEADER, $Headers );
curl_setopt( $Curl,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $Curl,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $Curl,CURLOPT_POSTFIELDS, json_encode( $Fields ) );
$GoogleResult = json_decode(curl_exec($Curl),true);
curl_close( $Curl );
Array ( [multicast_id] => 4.9523621355218E+18 [success] => 1 [failure] => 0 [canonical_ids] => 0 [results] => Array ( [0] => Array ( [message_id] => 0:1458493214513473%2d713a4ef9fd7ecd ) ) ) Array ( [multicast_id] => 8.963309427397E+18 [success] => 1 [failure] => 0 [canonical_ids] => 0 [results] => Array ( [0] => Array ( [message_id] => 0:1458493214608687%2d713a4ef9fd7ecd ) ) )
服务器结果如下
$Message = array
(
'message' => $ArrPushMessage["Message"],
'title' => $ArrPushMessage["Title"],
);
$Fields = array
(
'registration_ids' => $RegistrationIds,
'data' => $Message
);
$Headers = array
(
'Authorization: key=' . GOOGLE_API_ACCESS_KEY,
'Content-Type: application/json'
);
$Curl = curl_init();
curl_setopt( $Curl,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
curl_setopt( $Curl,CURLOPT_POST, true );
curl_setopt( $Curl,CURLOPT_HTTPHEADER, $Headers );
curl_setopt( $Curl,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $Curl,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $Curl,CURLOPT_POSTFIELDS, json_encode( $Fields ) );
$GoogleResult = json_decode(curl_exec($Curl),true);
curl_close( $Curl );
Array ( [multicast_id] => 4.9523621355218E+18 [success] => 1 [failure] => 0 [canonical_ids] => 0 [results] => Array ( [0] => Array ( [message_id] => 0:1458493214513473%2d713a4ef9fd7ecd ) ) ) Array ( [multicast_id] => 8.963309427397E+18 [success] => 1 [failure] => 0 [canonical_ids] => 0 [results] => Array ( [0] => Array ( [message_id] => 0:1458493214608687%2d713a4ef9fd7ecd ) ) )
您是否在每次通知中都使用了唯一的id?@RachitSolanki感谢您的评论。我用服务器端代码编辑了我的问题。请在android代码中添加通知NotificationManager=(NotificationManager)getSystemService(Context.notification_服务);manager.notify(uniqueid++,builder.build());您是否在每次通知中都使用了唯一的id?@RachitSolanki感谢您的评论。我用服务器端代码编辑了我的问题。请在android代码中添加通知NotificationManager=(NotificationManager)getSystemService(Context.notification_服务);manager.notify(uniqueid++,builder.build());