-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[notification] Implements message firebase notifications
- Loading branch information
1 parent
62366c0
commit 3012a6c
Showing
6 changed files
with
161 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
application/controllers/Schemas/NotificationRegistryAdd.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"type": "object", | ||
"properties": { | ||
"registration_token_firebase": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"registration_token_firebase" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
defined('BASEPATH') OR exit('No direct script access allowed'); | ||
|
||
class FirebaseUtil{ | ||
public static function sendMessageMulticast($ids, $data){ | ||
$key = "key=".FirebaseUtil::GOOGLE_SERVER_KEY(); | ||
|
||
$cURL = curl_init('https://fcm.googleapis.com/fcm/send'); | ||
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); | ||
|
||
$body = [ | ||
"registration_ids" => $ids, | ||
"data" => $data | ||
]; | ||
|
||
curl_setopt($cURL, CURLOPT_POST, true); | ||
curl_setopt($cURL, CURLOPT_HTTPHEADER, ["Content-Type:application/json", "Authorization:{$key}"]); | ||
curl_setopt($cURL, CURLOPT_POSTFIELDS, json_encode($body)); | ||
curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, false);//adds this to work com google security | ||
|
||
$result = curl_exec($cURL); | ||
curl_close($cURL); | ||
|
||
return $result; | ||
} | ||
private static function GOOGLE_SERVER_KEY(){ | ||
global $BusTrackerConfig; | ||
return $BusTrackerConfig["GOOGLE_SERVER_KEY"]; | ||
} | ||
} |
Binary file not shown.