From 7f66b8fa8fd9c50c5c98174eb40ed863152565e1 Mon Sep 17 00:00:00 2001 From: aryapradipta9 <aryapradipta9@gmail.com> Date: Thu, 19 Apr 2018 18:25:37 +0700 Subject: [PATCH] changing pengumuman --- addKmtBerita.php | 1 - addPengumuman.php | 8 +++++--- sendNotif.php | 10 ++++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/addKmtBerita.php b/addKmtBerita.php index df77405..dc63c07 100755 --- a/addKmtBerita.php +++ b/addKmtBerita.php @@ -23,7 +23,6 @@ $status = $stmt->execute(); $stmt->close(); $conn->close(); - if ($status) { echo "Sukses, komentar oleh user id " . $user_id ." pada pengumuman " . $pengumuman_id . " berhasil ditambahkan."; } else { diff --git a/addPengumuman.php b/addPengumuman.php index d71f5a0..9f73601 100755 --- a/addPengumuman.php +++ b/addPengumuman.php @@ -92,8 +92,10 @@ if ($fileAddr == "null") { $stmt->bind_param("siss", $judul, $kegiatan_id, $konten_text, $fileAddr); $stmt->execute(); $stmt->close(); -$stmt = $conn->query("SELECT SCOPE_IDENTITY()"); +$stmt = $conn->query("SELECT MAX(`id_pengumuman`) as max FROM `pengumuman`"); +$row = $stmt->fetch_assoc(); + $conn->close(); -// \pmotraining\FirebaseNotif::sendNotif("Ada pengumuman baru", $judul, 1, 1); -echo 'Sukses, pengumuman ' . $judul . ' berhasil ditambahkan.'; +\pmotraining\FirebaseNotif::sendNotif("Ada pengumuman baru", $judul, 0, $row["max"]); +echo 'Sukses, pengumuman ' . $judul . ' berhasil ditambahkan.' . $row["max"]; diff --git a/sendNotif.php b/sendNotif.php index 6b99dae..5ceeb00 100755 --- a/sendNotif.php +++ b/sendNotif.php @@ -27,17 +27,23 @@ class FirebaseNotif $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://fcm.googleapis.com/fcm/send"); curl_setopt($ch, CURLOPT_POST, 1); + $kodeClick = "beritaIntent"; + if ($kode == 0) { + // pengumuman + $kodeClick = "pengumumanIntent"; + } $vars = [ "to" => "/topics/all", "notification" => [ "title" => $title, "body" => $body, - "click_action" => "beritaIntent" + "click_action" => $kode ], "data" => [ - "id" => 1 + "id" => $id ] ]; + // $cat = $_POST["kategori"]; // if ($cat == "pengumuman" ) { $vars["notification"]["click_action"] = "mainActivity"; //testing -- GitLab