@param array $devices
@param array $notification

@return string
194498
protected function getNotificationBody(array $devices, array $notification)
    {
        $body = array(
            'profile' => $this->getProfile(),
            'tokens'       => $devices,
            'notification' => $notification
        );

        return json_encode($body);
    }
1161450
protected function formatNotificationData($notifications)
    {
        return collect($notifications)->map(function ($notification) {
            $notification->data = json_decode($notification->data);
            return $notification;
        });
    }
1318957
public function render(array $notifications)
    {
        $sweetAlerts = '';

        foreach ($notifications as $notification) {
            $message = $this->escapeMessage($notification['message']);
            $type    = $notification['type'];
            $title   = is_null($notification['title']) ? ucfirst($type) : $this->escapeTitle($notification['title']);

            $sweetAlerts = <<<TAG
    swal({
        title: '{$title}',
        text: '{$message}',
        type: '{$type}'
    });\n
TAG;
        }

        return $this->renderOutput($sweetAlerts);
    }
808491
public function show(Notification $notification)
    {
        $this->authorize('view', $notification);

        $notification->markAsRead();

        return view('laralum_notifications::show', ['notification' => $notification]);
    }
104227
public function sendAll($notification) {
		$pushEntity = $this->prepareSend($notification);
		
		$usersList = \App::$domain->account->fireUser->all();
		$targetTokens = [];
		foreach($usersList as $users) {
			if(!empty($users->device_token)) {
				$targetTokens[] = $users->device_token;
			}
		}
		$fireBase = new FireBaseSend();
		return $fireBase->sendMultiple($targetTokens, $pushEntity->toArray());
	}
1211523
private function checkMessageResult($message, \ArrayIterator $recipients)
    {
        $hasDeviceError = false;

        $recipientCount = $recipients->count();

        for ($i = 0; $i <= $recipientCount; $i++) {
            if (isset($message->results[$i]['registration_id'])) {
                $hasDeviceError = true;
                $recipients->offsetGet($i)->setIdentifierToReplaceTo($message->results[$i]['registration_id']);
            }

            if (isset($message->results[$i]['error'])) {
                $hasDeviceError = true;
                $error = $message->results[$i]['error'];
                $this->processError($error, $recipients->offsetGet($i));
            }
        }

        if ($hasDeviceError) {
            throw new InvalidRecipientException("Device identifier error status", $recipients);
        }
    }
309438
private function handleNotification(Notification $notification)
    {
        if (empty($notification->targetTypes())) {
            return;
        }
        $objectsByTypes = [];
        $numTotal = 0;
        foreach ($notification->targetTypes() as $objType) {
            $objType = trim($objType);
            $objects = $this->updatedObjects($objType);
            $num = count($objects);
            if ($num == 0) {
                continue;
            }
            $obj = [];
            $obj['objects'] = $objects;
            $obj['num'] = $num;
            $obj['type'] = $objType;
            $obj['typeLabel'] = isset($objects[0]['targetTypeLabel']) ? $objects[0]['targetTypeLabel'] : $objType;

            $objectsByTypes[$objType] = $obj;
            $numTotal += $num;
        }
        $this->sendEmail($notification, $objectsByTypes, $numTotal);
    }
1131943
public function send($notifiable, Notification $notification)
    {
        $message = $this->getData($notifiable, $notification);

        $event = new BroadcastNotificationCreated(
            $notifiable, $notification, is_array($message) ? $message : $message->data
        );

        if ($message instanceof BroadcastMessage) {
            $event->onConnection($message->connection)
                  ->onQueue($message->queue);
        }

        return $this->events->dispatch($event);
    }
371537
public function toDevice($device)
    {
        if (is_array($device)) {
            $this->devices = array_merge($device, $this->devices);

            return $this;
        }
        $this->devices[] = $device;

        return $this;
    }
618288
public function removeNotification($notification)
    {
        $ids = clone $this->notificationIds;
        $ids->offsetUnset($notification->id);
        $this->set('notificationIds', $ids);

        $ids = clone $this->newNotificationIds;
        $ids->offsetUnset($notification->id);
        $this->set('newNotificationIds', $ids);

        $notification->removeSubscribers(array($this->_mixer));
    }
139315
public static function make($notifiable, Notification $notification, $targeting): array
    {
        $payload = $notification->toOneSignal($notifiable)->toArray();

        if (static::isTargetingEmail($targeting)) {
            $payload['filters'] = collect([['field' => 'email', 'value' => $targeting['email']]]);
        } elseif (static::isTargetingTags($targeting)) {
            $array = $targeting['tags'];
            $res = count($array) == count($array, COUNT_RECURSIVE);
            if ($res) {
                $payload['tags'] = collect([$targeting['tags']]);
            } else {
                $payload['tags'] = collect($targeting['tags']);
            }
        } elseif (static::isTargetingIncludedSegments($targeting)) {
            $payload['included_segments'] = collect($targeting['included_segments']);
        } elseif (static::isTargetingExcludedSegments($targeting)) {
            $payload['excluded_segments'] = collect($targeting['excluded_segments']);
        } elseif (static::isTargetingExternalUserIds($targeting)) {
            $payload['include_external_user_ids'] = collect($targeting['include_external_user_ids']);
        } else {
            $payload['include_player_ids'] = collect($targeting);
        }

        return $payload;
    }
560266
public function send($id, $notification) {
		$pushEntity = $this->prepareSend($notification);
		$fireUser = \App::$domain->account->fireUser->oneById($id);
		$fireBase = new FireBaseSend();
		return $fireBase->send('dYxtWvqaR1A:APA91bEIhkotwlCtW0ld-7A22U3bMM5kMI4MPd8lahQkmo95hpO_zukxDrKY9fwcYutud5DufyeE-g-9L9BoWycXJC1CravdFNR-wTUnYjvTyAtuJBKOmL4vgd2LD1FIGUtbuCwiokaR'
			, $pushEntity->toArray());
	}
906549
public function notify(NotifyRequest $notification): Response
    {
        if ($this->appID !== null) {
            $notification->setApplicationIdentification($this->appID);
        }

        $response = $this->sendRequest($notification);
        return $response;

    }
798100
public function sendNotification($notification)
    {
        $subscriberIds = $notification->subscriberIds->toArray();
        $query = $this->getService('repos:people.person')
                       ->getQuery(true)
                       ->id($subscriberIds);

        $people = $query->fetchSet();

        $settings = $this->getService('repos:notifications.setting')
                         ->getQuery(true, array('actor.id' => $notification->target->id))
                         ->fetchSet();

        $settings = AnHelperArray::indexBy($settings, 'person.id');

        $mails = $this->_renderMails(array(
                        'notification' => $notification,
                        'people' => $people,
                        'settings' => $settings
                    ));

        $this->mail($mails);
    }
524619
public function viewedNotifications($notifications)
    {
        $notifications = (array) $notifications;

        $ids = clone $this->newNotificationIds;

        foreach ($notifications as $notification) {
            $ids->offsetUnset($notification->id);
        }

        $this->set('newNotificationIds', $ids);

        $this->save();
    }
132771
public function deserialize($data, PlannedNotification $notification, array $options)
    {
        if (!in_array(Options::REFRESH_UUID, $options)) {
            $notification->setUuid($data['id']);
        }

        $this->sipe('parameters.action', 'setAction', $data, $notification);
        $this->sipe('parameters.interval', 'setInterval', $data, $notification);
        $this->sipe('parameters.byMail', 'setByMail', $data, $notification);
        $this->sipe('parameters.byMessage', 'setByMessage', $data, $notification);

        if (isset($data['message']['id'])) {
            $message = $this->messageRepo->findOneBy(['uuid' => $data['message']['id']]);

            if (!empty($message)) {
                $notification->setMessage($message);
            }
        }
        if (isset($data['workspace']['uuid'])) {
            $workspace = $this->workspaceRepo->findOneBy(['uuid' => $data['workspace']['uuid']]);

            if (!empty($workspace)) {
                $notification->setWorkspace($workspace);
            }
        }
        $notification->emptyRoles();

        if (isset($data['roles'])) {
            foreach ($data['roles'] as $roleData) {
                $role = $this->roleRepo->findOneBy(['uuid' => $roleData['id']]);

                if (!empty($role)) {
                    $notification->addRole($role);
                }
            }
        }

        return $notification;
    }
22314
public function withNotification($notification): self
    {
        $new = clone $this;
        $new->notification = $notification instanceof Notification ? $notification : Notification::fromArray($notification);

        return $new;
    }