fclose($fp); } catch (Exception $e) { echo $e->getMessage(); } } function sendPushNotification($registration_id) { try { $message = 'You are not connected to personnel Tracker! Connect with tracker to continue the service.'; $url = 'https://android.googleapis.com/gcm/send'; $fields = array('registration_ids' => $registration_id, 'data' => array('message' => $message)); define('GOOGLE_API_KEY', 'AIzaSyBm0y_zo-4jFvDBlrrxaIRy7bcsZ1xQNnk'); $headers = array('Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === false) { die('Curl failed ' . curl_error()); } curl_close($ch); return $result; } catch (Exception $e) { echo $e->getMessage(); } } $admin->setTrackingUpdate($allUsers);