Penerjemahan ini sedang berlangsung.
This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
Properti pushManager
dari interface ServiceWorkerRegistration
Mengembalikan sebuah referensi ke Interface PushManager
untuk mengatur push subscriptions; termasuk dukungan untuk berlangganan, mendapatkan langganan yang aktif, dan mengakses izin status push.
Sintaks
myPushManager = ServiceWorker.pushManager
Value
Objek PushManager
.
Contoh
this.onpush = function(event) { console.log(event.data); // Dari sini kita bisa menyimpan data ke IndexedDB, mengirimnya ke setiap // jendela yang terbuka, menampilkan notifikasi, dsb. } navigator.serviceWorker.register('serviceworker.js').then( function(serviceWorkerRegistration) { serviceWorkerRegistration.pushManager.subscribe().then( function(pushSubscription) { console.log(pushSubscription.subscriptionId); console.log(pushSubscription.endpoint); // Detail langganan push dibutuhkan aplikasi // server kini tersedia, dan dapat di kirimkan menggunakan, // XMLHttpRequest misalnya. }, function(error) { // Pada saat pengembangan menampilkan log ke konsole sangatlah membantu // Di lingkungan produksi juga dapat bermanfaat untuk mengirimkan // informasi error kembali ke aplikasi server. console.log(error); } ); });
Spesifikasi
Specification | Status | Comment |
---|---|---|
Push API The definition of 'PushManager' in that specification. |
Working Draft | Initial definition. |
Kompabilitas Browser
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 42.0 | 44.0 (44.0)[1] | No support | ? | No support |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | No support | No support | No support | No support | No support | No support | No support | 42.0 |
[1] Service workers (dan Push) telah dinonaktifkan di Firefox 45 Extended Support Release (ESR.)