Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function parking_push($data = null)
- {
- if (is_null($data)) {
- check_if_POST();
- $post = $this->input->post();
- } else {
- $post = $data;
- }
- if (isset($post['contact_id'])) {
- // Push уведомления
- $user = $this->db->where('id', $post['contact_id'])->get('users')->row_array();
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => 'https://fcm.googleapis.com/fcm/send',
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => '',
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 0,
- CURLOPT_FOLLOWLOCATION => true,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => 'POST',
- CURLOPT_POSTFIELDS => '{
- "notification": {
- "title": "Automobilul Dvs este incarcat! Va rugam sa eliberati statia",
- "body": "Tariful Neutilizarea serviciului de încărcare va fi activat peste 15 minute. Pentru a evita aplicarea tarifului, Vă rugăm să eliberați stația de încărcare. Vă mulțumim.",
- "icon": "https://cabinet.evpoint.md/img/logo_b.png?width=40&height=40"
- },
- "to": "' . $user["deviceToken"] . '"
- }',
- CURLOPT_HTTPHEADER => array(
- 'Authorization: Bearer AAAACji8Fk4:APA91bHjiQc4shnXUp8E_rv3Gko9hBL3Fh8BAqpXl4zBEBYUbNZ4uByrm8FYQgetWuQrp2eNkGPu4qGcNSnPqUcIM6vVp1dVnkgfLLN9Ww41xGzPb9Po7gRdDnngC6WpaIgCuiGhCui4',
- 'Content-Type: application/json'
- ),
- ));
- $response = curl_exec($curl);
- curl_close($curl);
- $websocket_db = $this->load->database('websocket', true);
- $data = array(
- 'deviceToken' => $user["deviceToken"],
- 'response' => $response,
- 'contact_id' => $post['contact_id'],
- );
- $websocket_db->insert('push_logs', $data);
- // Конец Push
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement