refactor: update OTP system to support user-specific verification tables with legacy encryption and multi-role authentication.
This commit is contained in:
@@ -28,7 +28,10 @@ class FcmService
|
||||
}
|
||||
|
||||
/**
|
||||
* Send FCM notification to a specific device token
|
||||
* Send localized FCM notification using translation keys (Best for multi-language support)
|
||||
*/
|
||||
/**
|
||||
* Send FCM notification to a specific device token (Raw Text)
|
||||
*/
|
||||
public function sendToDevice(string $token, string $title, string $body, array $data = [], string $category = ''): array
|
||||
{
|
||||
@@ -36,12 +39,10 @@ class FcmService
|
||||
return ['status' => 'error', 'message' => 'Empty token'];
|
||||
}
|
||||
|
||||
// Add category to data payload
|
||||
if ($category) {
|
||||
$data['category'] = $category;
|
||||
}
|
||||
|
||||
// Convert non-string data values
|
||||
$stringData = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$stringData[$key] = is_array($value) ? json_encode($value) : (string) $value;
|
||||
@@ -72,6 +73,53 @@ class FcmService
|
||||
return $this->sendRequest($payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send localized FCM notification using translation keys (Best for multi-language support)
|
||||
*/
|
||||
public function sendLocalizedToDevice(string $token, string $titleKey, string $bodyKey, array $data = [], string $category = ''): array
|
||||
{
|
||||
if (empty($token)) {
|
||||
return ['status' => 'error', 'message' => 'Empty token'];
|
||||
}
|
||||
|
||||
if ($category) {
|
||||
$data['category'] = $category;
|
||||
}
|
||||
|
||||
$stringData = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$stringData[$key] = is_array($value) ? json_encode($value) : (string) $value;
|
||||
}
|
||||
|
||||
$payload = [
|
||||
'message' => [
|
||||
'token' => $token,
|
||||
'data' => $stringData,
|
||||
'android' => [
|
||||
'priority' => 'high',
|
||||
'notification' => [
|
||||
'title_loc_key' => $titleKey,
|
||||
'body_loc_key' => $bodyKey,
|
||||
],
|
||||
],
|
||||
'apns' => [
|
||||
'payload' => [
|
||||
'aps' => [
|
||||
'sound' => 'default',
|
||||
'badge' => 1,
|
||||
'alert' => [
|
||||
'title-loc-key' => $titleKey,
|
||||
'loc-key' => $bodyKey,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $this->sendRequest($payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send to FCM topic
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user