, , , iOS -.
firebase , , , .
, .
...
firebase https://console.firebase.google.com/.
firebase, . https://console.firebase.google.com/project/project-[your_project_number]/overview.
, , https://console.firebase.google.com/project/project-[your_project_number]/database/rules https://console.firebase.google.com/project/project-[your_project_number]/storage/rules.
...
{
"rules": {
".read": true,
".write": true
}
}
...
service firebase.storage {
match /b/project-[your_project_number].appspot.com/o {
match /{allPaths=**} {
allow read, write;
}
}
}
, , firebase. - , https://console.firebase.google.com/project/project-[your_project_number]/authentication/providers.
SERVER to WEB APPLICATION. , , FCM ( ) Android, iOS - ( Google Chrome). firebase.
js. - , .
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase.js"></script>
<script>
var config = {
apiKey: "your_api_key",
authDomain: "project-[your_project_number].firebaseapp.com",
databaseURL: "https://project-[your_project_number].firebaseio.com",
storageBucket: "project-[your_project_number].appspot.com",
};
firebase.initializeApp(config);
</script>
CURL. , Node.js, https://firebase.google.com/docs/server/setup#add_firebase_to_your_app .
, CURL PHP CodeIgniter. . CURL https://firebase.google.com/docs/database/rest/save-data#section-put
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
function booking_notification($notif_arr, $notif_type)
{
$CI =& get_instance();
$url = 'put_your_firebase_database_url_here';
$key = 'put_firebase_key';
$notif_arr = {'Key':'values'};
$notif_type = 'notification';
$headers = array(
'Authorization: key=' . $key,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url."/".$notif_type.".json");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($notif_arr));
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
curl_close($ch);
return FALSE;
}
else
{
curl_close($ch);
return TRUE;
}
}
, , .
JAVASCRIPT
var fireBaseJSONref = firebase.database().ref().child("notification");
fireBaseJSONref.on('child_added', function(snapshot) {
if (!ignoreItems) {
console.log(snapshot.val());
}
});
fireBaseJSONref.once('value', function(snapshot) {ignoreItems = false});
, . , , Android iOS.