Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function sendPushNotification($devices, $pushData, $partner = false) {
- $android = $devices->where('type', 2)->pluck('token')->all();
- if (!empty($android)) {
- $push = new PushNotification('fcm');
- $push->setMessage(
- [
- 'data' => $pushData,
- ]
- )
- ->setDevicesToken($android)
- ->send();
- }
- $ios = $devices->where('type', 1)->pluck('token')->all();
- if (!empty($ios)) {
- $push = new PushNotification('apn');
- $feedback = $push->setMessage(
- [
- 'aps' => [
- 'alert' => [
- 'title' => $pushData['title'],
- 'body' => $pushData['body'],
- ],
- 'sound' => 'default',
- 'badge' => 1
- ],
- 'data' => $pushData
- ]
- )->setDevicesToken($ios)->send()->getFeedback();
- }
- $web = $devices->where('type', 3)->pluck('token')->all();
- if (!empty($web)) {
- $push = new PushNotification('fcm');
- $push->setMessage($pushData)->setDevicesToken($web)->send();
- }
- }
Add Comment
Please, Sign In to add comment