Simplify APNs payload for iOS visible notifications and fetch latest token
This commit is contained in:
@@ -59,10 +59,6 @@ class FcmService
|
||||
'token' => $token,
|
||||
'data' => $processedData,
|
||||
'android' => ['priority' => 'HIGH'],
|
||||
'apns' => [
|
||||
'headers' => ['apns-priority' => '10', 'apns-push-type' => 'background'],
|
||||
'payload' => ['aps' => ['content-available' => 1]],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -71,6 +67,25 @@ class FcmService
|
||||
'title' => $title,
|
||||
'body' => $body,
|
||||
];
|
||||
$payload['message']['apns'] = [
|
||||
'payload' => [
|
||||
'aps' => [
|
||||
'sound' => $tone === 'ding' ? 'default' : $tone
|
||||
]
|
||||
]
|
||||
];
|
||||
} else {
|
||||
$payload['message']['apns'] = [
|
||||
'headers' => [
|
||||
'apns-priority' => '5',
|
||||
'apns-push-type' => 'background'
|
||||
],
|
||||
'payload' => [
|
||||
'aps' => [
|
||||
'content-available' => 1
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$ch = curl_init($fcmUrl);
|
||||
@@ -94,6 +109,8 @@ class FcmService
|
||||
$curlErr = curl_errno($ch);
|
||||
curl_close($ch);
|
||||
|
||||
error_log("[FCM_DEBUG] Token: " . substr($token, 0, 10) . "... Payload: " . json_encode($payload, JSON_UNESCAPED_UNICODE) . " | Result: $httpCode - $result");
|
||||
|
||||
if ($curlErr) {
|
||||
return ['status' => 'error', 'message' => 'CURL error'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user