08-12-2017, Saat: 22:09
Merhabalar,
Bir süredir Android & Delphi işbirliği ile geliştiriyorum bildirim bölümüne geldi sıra.
Android tarafında Firebase bağlantılarını hallettim, firebase'in konsolundan mesaj attığımda telefona düşüyor.
Ama benim bu mesajları elbette Delphi tarafından göndermem gerekiyor. Bir kaç deneme yaptım ama beceremedim kafama takıldı
Böyle bir url'imiz var "https://fcm.googleapis.com/fcm/send"
Bu url'e aşağıdaki gibi bir json post etmem gerekiyor.
Post ederken Header'im de bu bilgilerin bulunması gerekiyor.
Bunu tecrübe eden oldu mu ?
Bu şekilde php kodu buldum ama php hiç bilmiyorum .
Bir süredir Android & Delphi işbirliği ile geliştiriyorum bildirim bölümüne geldi sıra.
Android tarafında Firebase bağlantılarını hallettim, firebase'in konsolundan mesaj attığımda telefona düşüyor.
Ama benim bu mesajları elbette Delphi tarafından göndermem gerekiyor. Bir kaç deneme yaptım ama beceremedim kafama takıldı

Böyle bir url'imiz var "https://fcm.googleapis.com/fcm/send"
Bu url'e aşağıdaki gibi bir json post etmem gerekiyor.
{
"to": "Android cihazın token bilgisi",
"notification": {
"body": "Merhaba Burası Delphican",
"title": "http://www.delphican.com"
},
"data": {
"site_adi": "delphican",
"link": "http://www.delphican.com"
}
}
Post ederken Header'im de bu bilgilerin bulunması gerekiyor.
'Authorization:key=UYGULAMAFİREBASEAPİKEYİ' 'Content-Type:application/json'
Bunu tecrübe eden oldu mu ?
Bu şekilde php kodu buldum ama php hiç bilmiyorum .
PHP Kod:
$firebase_url = 'https://fcm.googleapis.com/fcm/send';
$fields = array(
'to' => $token,
'notification' => array('title' => 'delphican', 'body' => 'delphican.com'),
'data' => array('site_adi' => 'delphican','linki'=>'http://www.delphican.com/')
);
$headers = array(
'Authorization:key='.UYGULAMAFİREBASEAPİKEYİ,
'Content-Type:application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $firebase_url);
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_IPRESOLVE, CURL_IPRESOLVE_V4 );
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
curl_close($ch);
