-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFCMToken.php
More file actions
31 lines (28 loc) · 815 Bytes
/
Copy pathFCMToken.php
File metadata and controls
31 lines (28 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
namespace App;
use App\Services\FCMService;
use Illuminate\Database\Eloquent\Model;
class FCMToken extends Model
{
protected $table = 'fcm_tokens';
/**
* @param $user_id
* @return void
*/
public function sendNotification($user_id)
{
//https://dev.to/rabeeaali/send-push-notifications-from-laravel-to-ios-android-29b4
$fcm_tokens = $this->where('user_id', $user_id)->get();
foreach ($fcm_tokens as $fcm_token) {
$fcm_token->fcm_token = 'sdfds';
$response = FCMService::send(
$fcm_token->fcm_token,
[
'title' => 'Test',
'body' => 'I cannot believe this actually worked.',
]
);
dd($response->body());
}
}
}