FCM을 사용하여 Android에 푸시 알림을 보내는 이상한 문제가 있습니다.FCM 푸시 알림 문제 : - "오류": "등록되지 않음"
목표 : - 푸시 알림 아래
를 전송하는 동안 오류를 갖는 언제 내가
public static function SendMultipleNotificationAndroid($groups)
{
//your api key SERVER API KEY
$apiKey = Yii::$app->params['android_api_key'];
$url = 'https://fcm.googleapis.com/fcm/send';
$headers = array(
'Authorization:key=' . $apiKey,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
foreach($groups as $resG){
$users = $resG['users'];
$msg = $resG['message'];
$type = $resG['notification_type'];
$notification_data = $resG['notification_data'];
$deviceTokens = [];
foreach($users as $resUser){
$deviceTokens[] = $resUser['device_token'];
//Add Friend badge count +1
Common::AddRemoveBadgeCount($resUser['user_id']);
}
if(!empty($deviceTokens)){
$fields = array(
'registration_ids' => $deviceTokens,
'priority' => 'high',
'collapse_key' => $resG['notification_type'],
'time_to_live' => 2419200,
"click_action" =>"NotificationListingActivity",
'data' => [
"title" => "ProjectName",
"body" => $resG['message'],
"action_tag" => $resG['notification_type'],
"message" => $resG['message'],
'notification_type' => $type,
'notification_data' => $notification_data,
'sound' => 'default',
]
);
//Print result
p($ch,0);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
curl_exec($ch);
}
}
curl_close($ch);
}
을 안드로이드 푸시 알림을 전송하는 기능을 수행 시나리오는 그래서 문제입니다 하나의 알림을 보내 잘 작동하지만 여러 알림을 보낼 때마다 오류가 발생했습니다.
<pre>Resource id #5</pre>{"multicast_id":4818908994630396118,"success":1,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"},{"message_id":"0:1487136045570022%c3bae3c6002e9358"}]}
<pre>Resource id #5</pre>{"multicast_id":5218359780835228544,"success":1,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"},{"message_id":"0:1487136046618669%c3bae3c6002e9358"}]}
코드를 디버깅 할 때 우리 데이터베이스에는 푸시 알림을 보내지 않는 방화벽이없는 장치 토큰이 있습니다. 어떤 도움을 주시면 감사하겠습니다
"NotRegistered"
내가 기능 이상으로 호출 할 때마다 나는
"오류"가되었다.
미리 감사드립니다.
는
문제를 살펴보고 시도해 볼 수 있습니다! 나는 곧 너에게 다시 돌아갈 것이다! 감사! –
브라보! 일! –
@maddy 이것은 나를 위해 일하지 않았다. 요청을 만들 때 서버 키를 변경했지만 여전히 동일한 오류가 발생합니다. – AIon