Код: Выделить всё
$url = "https://fcm.googleapis.com/v1/projects/{$project_id}/messages:send"; `
code":403,"message":"Permission 'cloudmessaging.messages.create' отклонен на ресурсе '//cloudresourcemanager.googleapis.com/projects/restaurant-b6abd' (или он может не существовать).","status":"PERMISSION_DENIED","details":[{" @type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"IAM_PERMISSION_DENIED","domain":"cloudresourcemanager.googleapis.com","metadata":{"resource":"projects/ Restaurant-b6abd","permission":"cloudmessaging.messages.create"
Если кто-то может понять, дайте решение.Как показано на изображении, я уже установил это разрешение для облака messages.messages.create для всех этих ролей.
Вот изображение с ролями и его разрешениями
Вот изображение с ролями и их разрешениями
Вот изображение с ролями и разрешениями
p>

Ниже приведен мой код для отправить push-уведомление
Код: Выделить всё
function sendPushNotification($fcmIdsArray, $notificationData, $dataPayload, $notificationConfig = ['click_action' => 'OrderDetailsActivity', 'icon' => 'ic_notification', 'color' => '#CD201F', 'tag' => 'general', 'sound' => 'sound.mp3'])
set_time_limit(0);
Код: Выделить всё
Log::info('push array');
Log::info($fcmIdsArray);
Log::info($notificationData);
Log::info($dataPayload);
//Loop for Every Sub Array and Send to FCM Server
foreach($fcmIdsArray as $fcmId){
$fields = [
'message' => [
'token' => $fcmId,
'data' => $dataPayload,
'apns' => [
'payload' => [
'aps' => [
'sound' => 'sound.mp3',
],
],
],
],
];
Log::info('notificationData count '.count($notificationData));
if(is_array($notificationData) && count($notificationData) > 0){
Log::info('inside notification count '.json_encode($notificationData));
$fields['message']['notification'] = $notificationData;
$fields['message']['android'] = ['notification' => $notificationConfig];
}
try {
// Attempt to send notification
$result = firebaseNotificationApiCall($fields, $dataPayload['firebase_project_id']);
Log::info('Firebase API Call Response: ' . json_encode($result));
if (isset($result["error"]["status"]) && $result["error"]["status"] == "NOT_FOUND") { // if that TOKEN NO LONGER EXISTS then delete
Log::info('deleted token: ' . $fcmId);
UserDevice::where("fcm_token", $fcmId)->delete();
}
} catch (Exception $e) {
// Log the error if the API call fails
Log::error('Failed to send notification: ' . $e->getMessage());
Log::channel('slack')->critical("Failed to send notification - sendPushNotification: ". $e->getMessage());
}
}
Подробнее здесь: https://stackoverflow.com/questions/788 ... sion-error
Мобильная версия