Membuat Desktop Notifikasi Via Javascript
Hari ini saya iseng – iseng belajar membuat desktop notifikasi seperti gambar di bawah ini :
Bagus ya, waah berarti jika kita punya aplikasi berbasis website, kita bisa munculkan pesan notifikasi walaupun pengguna aplikasi kita aktif di tab browser yang lainnya atau di window lain. Contoh kalo di aplikasi gmail, saat kita sudah login gmail tapi kita sibuk melakukan aktifitas diwindow atau tab yang lain, dan ada yang chat kita, maka akan muncul dekstop notifikasinya ya kira – kira seperti ini :
Sekarang kita juga bisa membuat notifikasi seperti itu dengan cara yang mudah lo. Untuk contoh hasilnya temen – temen bisa mencobanya di SINI.
Berikut adalah tabel browser yang support untuk desktop notifikasi :
Berdasarkan dokumentasi mozilla, sintak javascript untuk menampilkan notifikasi seperti ini :
var notification = new Notification(title, options)
Options yang dapat kita berikan diantaranya lang, body, tag, icon. Temen – temen bisa melihat detailnya pada link sumber di bawah.
Berikut adalah contoh fungsi javascript yang dapat menampilkan notifikasi desktop :
<script type="text/javascript"> function notifyMe(msg_title, msg_body, redirect_onclick) { var granted = 0; // Let's check if the browser supports notifications if (!("Notification" in window)) { alert("This browser does not support desktop notification"); } // Let's check if the user is okay to get some notification else if (Notification.permission === "granted") { granted = 1; } // Otherwise, we need to ask the user for permission else if (Notification.permission !== 'denied') { Notification.requestPermission(function (permission) { // If the user is okay, let's create a notification if (permission === "granted") { granted = 1; } }); } if (granted == 1) { var notification = new Notification(msg_title, { body: msg_body, icon: 'notif-icon.png' }); if (redirect_onclick) { notification.onclick = function() { window.location.href = redirect_onclick; } } } } </script>
Temen – temen cukup memanggil fungsi di atas seperti contoh button berikut ini :
<button onclick="notifyMe('Title Notif', 'Body Notif')">Notify me!</button>
Button untuk code diatas jika di klik, maka browser akan menampilkan permintaan untuk permission seperti gambar berikut :
Notifikasi bisa tidak muncul jika anda menekan tombol Block.
Sekian tutorial kali ini, simple ya.. semoga dapat mencerahkan buat temen – temen yang sedang membutuhkannya,
Terimakasih, salam hangat
Sumber : https://developer.mozilla.org/en-US/docs/Web/API/notification
Category: Javascript
handika
May 5, 2015 - 3:38 pm
pak tolong saya minta source codenya. tolong kirim ke email saya [email protected] saya mau ngembangin buat notifikasi pengingat pembayaran kredit di bank. tolong pak buat tugas saya.. terima kasih banyak sebelumnya
handika
May 5, 2015 - 7:36 pm
tolong bantuannya ma pencerahannya pak.. aplikasi yang mau saya kembangin gini, setiap h-3 dari tanggal jatuh tempo maka notifikasinya akan muncul dan memberitahukan nama orang yang akan ditagih kreditnya… kira2 bisa kan pak? saya sudah pusing pak nyari tutorial nggak ketemu2.. :(.. tolong bantuannya pak..
Almazari
June 17, 2015 - 2:56 pm
Bisa mas, pake cron saja.. jadi ada service yang dijalankan di background untuk ngecek apakah sudah jatuh tempo atau belum.. ketika sudah tinggal dipanggil notifikasinya. Keywordnya ini : https://www.google.co.id/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=cronjob%20php
base war coc
April 6, 2016 - 6:18 pm
Kalau mau membuat notifikasi untuk web jika ada posting baru gimana caranya om?
Zulmy Eve
May 1, 2016 - 12:19 pm
dalam waktu yang sama ketika browser menujukkan notif, jika kita ingin menambahkan audio itu bagai mana om? terima kasih
Firni Grosir
February 27, 2017 - 3:22 pm
terima kasih mas ALMAZARI , mau tanya nih, Itu notification nanti bisa nggak yah, misal untuk munculkan promo di web, produk terbaru yang baru di uploaddll
Almazari
February 27, 2017 - 3:50 pm
Ya bisa aja mas, biasanya ada background proses (ajax) untuk ngecek ada produk baru tidak, kalo ada tampilkan notifnya…
Sang Semot Hitam
March 8, 2017 - 1:36 pm
Bagaimana Notifikasi tetap aktif walaupun browser sudah ditutup ?
Almazari
March 8, 2017 - 2:28 pm
Wah kalo yang seperti itu saya juga belum tau mas, nanti kalo sudah tau caranya saya posting jg…
husinalmahdi
July 6, 2022 - 5:50 pm
k
slinginly
January 7, 2024 - 10:13 pm
Where there is no suitable substitute for breast milk, no safe water, and no safe place for the baby to be apart from mom, weaning as a necessity must occur late cialis generic
Maggiet
January 23, 2024 - 5:37 pm
The offer is still valid. Details https://zetds.seychellesyoga.com/jml
Heathert
January 24, 2024 - 7:15 pm
Content for your website https://zetds.seychellesyoga.com/info
Janicet
January 25, 2024 - 1:41 am
Web Development Wizards https://zetds.seychellesyoga.com/info
Murielt
January 25, 2024 - 7:10 am
Can provide a link mass to your website https://zetds.seychellesyoga.com/info
Scarlett
January 25, 2024 - 12:48 pm
Your site’s position in the search results https://zetds.seychellesyoga.com/info
Mariat
January 25, 2024 - 7:26 pm
Free analysis of your website https://zetds.seychellesyoga.com/info
Dorothyt
January 25, 2024 - 9:44 pm
Content for your website https://zetds.seychellesyoga.com/info
Maryt
January 26, 2024 - 11:12 am
Can provide a link mass to your website https://zetds.seychellesyoga.com/info
Annt
January 26, 2024 - 5:57 pm
Your site’s position in the search results https://zetds.seychellesyoga.com/info
Mayt
January 26, 2024 - 11:41 pm
Free analysis of your website https://zetds.seychellesyoga.com/info
Samanthat
January 27, 2024 - 5:36 am
SEO Optimizers Team https://zetds.seychellesyoga.com/info
Norat
January 27, 2024 - 11:31 am
I offer mutually beneficial cooperation https://zetds.seychellesyoga.com/info
Jennyt
January 27, 2024 - 5:25 pm
Cool website. There is a suggestion https://zetds.seychellesyoga.com/info
Ginat
January 27, 2024 - 11:34 pm
I really liked your site. Do you mind https://zetds.seychellesyoga.com/info
Susant
January 28, 2024 - 5:37 am
Here’s what I can offer for the near future https://zetds.seychellesyoga.com/info
Priscillat
January 28, 2024 - 11:32 am
You will definitely like it https://zetds.seychellesyoga.com/info
Wendyt
January 28, 2024 - 4:35 pm
Content for your website https://ztd.bardou.online/adm
Debrat
January 28, 2024 - 10:38 pm
Web Development Wizards https://ztd.bardou.online/adm
Gwent
January 29, 2024 - 4:43 am
Can provide a link mass to your website https://ztd.bardou.online/adm
Amandat
January 29, 2024 - 10:48 am
Your site’s position in the search results https://ztd.bardou.online/adm
Reginat
January 29, 2024 - 2:38 pm
Your site’s position in the search results https://ztd.bardou.online/adm
Jocelynt
January 29, 2024 - 5:02 pm
Free analysis of your website https://ztd.bardou.online/adm
tstoto
January 29, 2024 - 10:27 pm
Very good information. Lucky me I came across your site by
chance (stumbleupon). I’ve book-marked it for later!
Rutht
January 29, 2024 - 11:13 pm
SEO Optimizers Team https://ztd.bardou.online/adm
Kellyt
January 30, 2024 - 5:21 am
I offer mutually beneficial cooperation https://ztd.bardou.online/adm
Pollyt
January 30, 2024 - 11:27 am
Cool website. There is a suggestion https://ztd.bardou.online/adm
Pamelat
January 30, 2024 - 5:35 pm
I really liked your site. Do you mind https://ztd.bardou.online/adm
Zoet
January 30, 2024 - 11:54 pm
Here’s what I can offer for the near future https://ztd.bardou.online/adm
Elizabetht
January 31, 2024 - 4:22 am
Content for your website https://ztd.bardou.online/adm
Candyt
January 31, 2024 - 10:10 am
Web Development Wizards https://ztd.bardou.online/adm
Juliett
January 31, 2024 - 4:01 pm
Can provide a link mass to your website https://ztd.bardou.online/adm
Evat
January 31, 2024 - 10:02 pm
Your site’s position in the search results https://ztd.bardou.online/adm
Janet
February 1, 2024 - 3:56 am
Free analysis of your website https://ztd.bardou.online/adm
Cassandrat
February 1, 2024 - 9:43 am
SEO Optimizers Team https://ztd.bardou.online/adm
Louiset
February 1, 2024 - 3:26 pm
I offer mutually beneficial cooperation https://ztd.bardou.online/adm
Valeryt
February 1, 2024 - 9:14 pm
Cool website. There is a suggestion https://ztd.bardou.online/adm
Susannat
February 2, 2024 - 12:32 am
Content for your website http://myngirls.online/
Gracet
February 2, 2024 - 6:23 am
Web Development Wizards http://myngirls.online/
Normat
February 2, 2024 - 12:07 pm
Can provide a link mass to your website http://myngirls.online/
Battyt
February 2, 2024 - 5:53 pm
Your site’s position in the search results http://myngirls.online/
Kimberlyt
February 3, 2024 - 7:40 am
Free analysis of your website http://myngirls.online/
Stellat
February 3, 2024 - 9:22 pm
SEO Optimizers Team http://myngirls.online/
Ginat
February 4, 2024 - 11:08 am
I offer mutually beneficial cooperation http://myngirls.online/
Susannat
February 4, 2024 - 4:41 pm
Content for your website http://fertus.shop/info/
Gracet
February 5, 2024 - 12:33 am
Web Development Wizards http://fertus.shop/info/
Normat
February 5, 2024 - 8:23 am
Can provide a link mass to your website http://fertus.shop/info/
Battyt
February 5, 2024 - 4:12 pm
Your site’s position in the search results http://fertus.shop/info/
Kimberlyt
February 6, 2024 - 6:03 am
Free analysis of your website http://fertus.shop/info/
Stellat
February 6, 2024 - 7:52 pm
SEO Optimizers Team http://fertus.shop/info/
Ginat
February 7, 2024 - 9:41 am
I offer mutually beneficial cooperation http://fertus.shop/info/
Nicolet
February 7, 2024 - 11:32 pm
Cool website. There is a suggestion http://fertus.shop/info/
Averyt
February 8, 2024 - 1:23 pm
I really liked your site. Do you mind http://fertus.shop/info/
Katherinet
February 9, 2024 - 3:12 am
Here’s what I can offer for the near future http://fertus.shop/info/
Sophiat
February 9, 2024 - 4:57 pm
You will definitely like it http://fertus.shop/info/
Florancet
February 10, 2024 - 6:42 am
The best prices from the best providers http://fertus.shop/info/
Tucker Carlson Putin
February 10, 2024 - 8:29 pm
Tucker Carlson Putin Tucker Carlson Full Putin Interview.
Putin Interview Summary.
Ashleyt
February 11, 2024 - 10:08 am
Analytics of your website http://fertus.shop/info/
Junet
February 11, 2024 - 11:53 pm
I would like to post an article http://fertus.shop/info/
Evelynt
February 13, 2024 - 3:56 am
Shall we exchange links? My website http://fertus.shop/info/
Murielt
February 13, 2024 - 5:47 pm
The offer is still valid. Details http://fertus.shop/info/
소닉카지노 링크
February 14, 2024 - 9:11 am
this-is-a-small-world.com
멘토로서 가끔 자랑하는 것은 당연하다.
Juliat
February 14, 2024 - 9:28 pm
Content for your website http://fertus.shop/info/
소닉카지노 링크
February 15, 2024 - 6:50 am
binsunvipp.com
Xiao Jing은 일어 서서 손을 등 뒤로하고 앞뒤로 서성 거리며 “서둘러 말하세요.”
Estert
February 16, 2024 - 12:50 am
Can provide a link mass to your website http://fertus.shop/info/
에그벳슬롯
February 16, 2024 - 4:35 am
amruthaborewells.com
“놀고 있지 않아, 뭐야?” Chen Yan은 Fang Jifan을 응시했습니다.
Gracet
February 17, 2024 - 7:16 am
Web Development Wizards http://fertus.shop/info/
???소닉카지노 사이트
February 17, 2024 - 1:20 pm
binsunvipp.com
Fang Jifan은 단호한 얼굴로 “괜찮습니다. 먼저 조카가 천천히 생각할 수 있습니다. “라고 말했습니다.
Battyt
February 18, 2024 - 9:53 am
Your site’s position in the search results http://fertus.shop/info/
Stellat
February 19, 2024 - 12:30 pm
SEO Optimizers Team http://fertus.shop/info/
Ginat
February 20, 2024 - 1:47 am
I offer mutually beneficial cooperation http://fertus.shop/info/
온라인 슬롯 사이트
February 20, 2024 - 6:07 am
doeaccforum.com
따라서 희귀한 것일수록 몸에 더 유용합니다.
소닉카지노
February 21, 2024 - 2:21 am
strelkaproject.com
Xishan의 경험은 계율과 행위만큼 단순하지 않습니다.
소닉카지노
February 24, 2024 - 4:59 am
dota2answers.com
진작에 알았더라면 왕관을 쓰고 제복을 입고 여기 왔어야 했는데.
lfchungary.com
February 24, 2024 - 5:07 am
pragmatic-ko.com
잘려나갔으니 전하… 정말 마음 놓고 가세요.
smcasino-game.com
February 28, 2024 - 5:14 am
sm-slot.com
눈에서 눈물을 닦고 가마에서 내려 큰 집을 바라보니…
lfchungary.com
February 28, 2024 - 9:08 am
lfchungary.com
Zhu Houzhao는 “어떻게 생각하세요?”
pragmatic-ko.com
February 29, 2024 - 3:16 pm
pragmatic-ko.com
진정한 전쟁 기술은 결코 36가지 전략만큼 단순하지 않기 때문입니다.
에그벳 먹튀
March 1, 2024 - 5:57 pm
windowsresolution.com
Zhu Houzhao와 Fang Jifan은 초조하게 중국군에 도착했습니다.
pragmatic-ko.com
March 1, 2024 - 7:22 pm
pragmatic-ko.com
Fang Jifan은 한숨을 쉬었습니다. “장시에 대해 확신하십니까?”
pragmatic-ko.com
March 2, 2024 - 11:11 pm
lfchungary.com
다른 궁전에서도 많은 수리가 있습니다.
pragmatic-ko.com
March 4, 2024 - 3:55 am
pragmatic-ko.com
그는 또 “소식 있으면 빨리 말해, 공사장 가서 봐야겠어”라며 입술을 삐죽였다.
smcasino-game.com
March 5, 2024 - 3:14 am
mega-casino66.com
“아버지가 말씀하시길, 경계를 강화할 방법을 찾도록 하라.”
fire138 login
March 5, 2024 - 3:21 am
Every weekend i used to pay a quick visit
this site, because i wish for enjoyment, since this this
web site conations truly fastidious funny data too.
khasiss.com
March 5, 2024 - 9:07 pm
parrotsav.com
왕수인: “스승님, 잊으십시오. 다른 사람을 용서하고 다른 사람을 용서해야 합니다.”
eggc
March 6, 2024 - 1:59 am
jbustinphoto.com
Zhu Houzhao는 “아버지, Fang Jifan의 말도 안되는 말을 듣지 마십시오. “라고 외쳤습니다.
khasiss.com
March 7, 2024 - 12:08 am
twichclip.com
그러자 그는 머리에 심한 통증을 느끼며 기절했습니다.
sm-slot.com
March 7, 2024 - 4:53 am
mega-slot77.com
적어도 하늘의 아들 자신은 절대적으로 불안합니다.
sm-slot.com
March 7, 2024 - 10:15 pm
chutneyb.com
즉, 사고가 났을 때 생명을 구할 수 있는지 여부는 전적으로 하나님의 뜻에 달려 있습니다.
khasiss.com
March 8, 2024 - 5:15 am
manzanaresstereo.com
Fang Jifan은 피부가 두껍고 어쨌든 익숙하다고 느꼈지만 제지되지 않았습니다.
khasiss.com
March 9, 2024 - 8:56 am
shopanho.com
Fang Jifan은 멀리서 그를 보았을 때 귀신을 본 것 같았고 빨리 숨고 싶었습니다.
메가슬롯
March 9, 2024 - 8:24 pm
smcasino-game.com
Zhu Houzhao는 여전히 행복할 수 없다는 듯 눈을 가늘게 떴습니다.Zhu Houzhao는 눈을 가늘게 떴습니다. “당신을 대신하여 당신을 고용하겠습니다.”
khasiss.com
March 10, 2024 - 11:12 am
mojmelimajmuea.com
급하게 결정한 것 뿐인데 요 며칠 비가 안 오면 어쩌지?
???메가슬롯 조작
March 10, 2024 - 2:31 pm
chutneyb.com
그것은 여전히 큰 배에 집중하는 명나라 배의 옛 스타일입니다.
khasiss.com
March 10, 2024 - 6:25 pm
khasiss.com
Wang Shouren은 감히 한 단어도 놓치지 않고 귀를 쫑긋 세웠습니다.
www.binance.com註冊
March 15, 2024 - 5:00 pm
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
에그슬롯
March 17, 2024 - 12:15 pm
madridnortehoy.com
전체 오스만 제국은 예상보다 훨씬 빠르게 무너졌습니다.
메가슬롯 게임
March 18, 2024 - 9:39 pm
mega-slot1.com
그림에서 Zhu Houzhao는 말을 타고 활로 화살을 당깁니다.
에그슬롯
March 21, 2024 - 1:59 am
ttbslot.com
Fang Jifan은 손을 흔들고 그의 아들 Fang Zhengqing을 올려다 보았습니다.
Link Alternatif jeeptoto
March 21, 2024 - 6:56 pm
Awesome article.
eggc
March 22, 2024 - 4:08 am
ttbslot.com
후속 튤립 구근도 속속 발송됩니다.
에그벳슬롯
March 23, 2024 - 3:51 pm
qiyezp.com
그는 수업을 받고있는 Zuodu Yushi를 무기력하게 바라보며 매우 부끄러워 보였습니다.
에그벳도메인
March 24, 2024 - 9:07 pm
qiyezp.com
잠시 후 누군가 짐을 지고 땀을 뻘뻘 흘리며 절뚝거리며 들어왔다.
sandyterrace.com
March 28, 2024 - 1:47 pm
animehangover.com
오늘 내일의 빚을 갚아 앞으로 늦게까지 자지 않겠다.
에그벳
April 4, 2024 - 6:31 pm
sandyterrace.com
Fang Jifan은 마음 속으로 한숨을 쉬었습니다. 물론 개는 식습관을 바꿀 수 없습니다.
에그벳슬롯
April 6, 2024 - 1:45 am
sandyterrace.com
Fang Jifan은 눈을 들어 Zhu Houzhao를 바라보고 Zhu Houzhao는 “무엇을보고 있습니까? “라고 자신있게 말했습니다.
sandyterrace.com
April 9, 2024 - 12:37 am
ihrfuehrerschein.com
다른 황제라면 그런 왕자를 수용할 수 있을까, 그리고 아래의 후계자를 수용할 수 있을까?
에그벳 슬롯
April 9, 2024 - 9:12 am
qiyezp.com
Qi Zhiyuan은 “잊어버려, 내 스승을 직접 방문해야 한다”고 말했다.
슬롯사이트
April 10, 2024 - 3:35 pm
sandyterrace.com
홀에 있는 모든 군주와 장관들은 나를 보고, 나도 보고, 그들은 모두 조금 혼란스러워합니다.
sandyterrace.com
April 10, 2024 - 6:26 pm
game1kb.com
Wen Yansheng의 얼굴에서 미소가 점차 사라졌습니다.
qiyezp.com
April 11, 2024 - 1:00 am
sandyterrace.com
Fang Jifan은 Zhu Houzhao의 목에 손을 대고 의도적으로 그를 질식시킵니다.
fpparisshop.com
April 19, 2024 - 11:36 pm
donmhomes.com
非常に興味深い記事でした。新たな知識をありがとう。
sandyterrace.com
April 20, 2024 - 3:39 am
thebuzzerpodcast.com
“예.” 혼란스러워하는 장마오는 “개가…?”라고 물었다.
sandyterrace.com
April 23, 2024 - 4:51 am
nikontinoll.com
그러나 Liu Jin은 “전하, 그들은 … 집을 털기 위해 여기에 있습니다. “라고 말했습니다.
sandyterrace.com
April 24, 2024 - 7:47 pm
animehangover.com
Zhu Zaimo는 눈살을 찌푸리고 매우 주의 깊게 들었습니다.