¼ø¼
1. shownotification()ÄÚ½º Ãß°¡
sw.jsÀÇ Äڵ带 ¾Æ·¡¿Í °°ÀÌ º¯°æÇÕ´Ï´Ù.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | console.log( 'Started' , self); self.addEventListener( 'install' , function (event) { self.skipWaiting(); console.log( 'Installed' , event); }); self.addEventListener( 'activate' , function (event) { console.log( 'Activated' , event); }); self.addEventListener( 'push' , function (event) { console.log( 'Push message' , event); var title = 'Push message' ; event.waitUntil( self.registration.showNotification(title, { body: 'The Message' , icon: 'images/icon.png' , tag: 'my-tag' })); }); // TODO |
event.waitUntil() ÇÔ¼ö´Â À̺¥Æ® Çڵ鷯ÀÇ ¶óÀÌÇÁ ŸÀÓÀ» showNotification()ÇÔ¼ö°¡ È®Àεɶ§±îÁö ¿¬Àå½Ãŵ´Ï´Ù.
°¢ ÅÂ±× °ª¸¶´Ù ÇϳªÀÇ ¾Ë¸²ÀÌ º¸¿©Áý´Ï´Ù. ¸¸¾à »õ·Î¿î ¸Þ½ÃÁö¸¦ ¹Þ°ÔµÇ¸é ÀÌÀü ¾Ë¸²Àº ´ëüµË´Ï´Ù. ¿©·¯°³ÀÇ ¾Ë¸²À» µ¿½Ã¿¡ º¸¿©Áö°Ô ÇÏ·Á¸é ´Ù¸¥ ÅÂ±× °ªÀ» °¢°¢ÀÇ showNotification() ÇÔ¼ö·Î È£ÃâÇÏ¿©¾ß ÇÕ´Ï´Ù.
2. GCM¿¡°Ô ¾Ë¸² ¿äû Çϱâ
cURL Ä¿¸Çµå ȤÀº XHR ¿äûÀ» ½ÇÇàÇÕ´Ï´Ù.