Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Push Notification is comming!

Push Notification is comming!

ChromeでPush通知が使えるようになったので、それを紹介してみた記事です〜。
HTML5 minitutes
第9回

Yohei Munesada

June 12, 2015
Tweet

More Decks by Yohei Munesada

Other Decks in Technology

Transcript

  1. ࣮૷Πϝʔδᶃߪಡॲཧ navigator.serviceWorker.ready.then(function (reg) { // ߪಡॲཧ reg.pushManager.subscribe({ userVisibleOnly: true }).then(function

    (subscription) { console.debug('ߪಡ੒ޭ!!'); // ServerʹߪಡIDΛ௨஌ sendSubscriptionIdToServer(subscription); }); }); 1BHF+BWB4DSJQU
  2. ࣮૷Πϝʔδᶄ164)ड͚औΓ self.addEventListener('push', function (event) { var title = 'Yay a

    message.'; var body = 'We have received a push message.'; var icon = './images/icon-192x192.png'; var tag = 'simple-push-demo-notification-tag'; event.waitUntil( self.registration.showNotification(title, { body: body, icon: icon, tag: tag })); }); 4FSWJDF8PSLFS