push
Pengembang dapat menggunakan fungsi pada push untuk melakukan manajemen notifikasi dengan firebase.
ctx.moco.push;
Push methods
config(configuration)
Membuat configuration untuk firebase client.
Arguments
| name | type | description |
|---|---|---|
| configuration | object | data global configuration |
send(target, payload, option)
Berfungsi untuk mingirim notifikasi.
Arguments
| name | type | description |
|---|---|---|
| target | string / array | target notifikasi |
| payload | object | pesan dalam notifikasi berserta data nya |
| payload.notification | object | data notifikasi |
| payload.notification.title | string | judul notifikasi |
| payload.notification.body | string | body dari notifikasi |
| payload.notification.icon | string | url icon untuk notifikasi |
| payload.data | object | data notifikasi |
| options | object | opsi untuk notifikasi |
| options.priority | string | prioritas notifikasi |
| options.timeToLive | number | time valid notification |
Return
Promise<Object>
Respon dari firebase function.
subscribed(token, topic)
Subscribe token sesuai topic yang dikirim.
Arguments
| name | type | description |
|---|---|---|
| token | string / array | target token |
| topic | string | topic untuk subscribe |
Return
Promise<Object>
Balasan dari firebase atas kondisi subscribe yang telah dilakukan.
unsubscribed(token, topic)
Unsubscribe terhadap topic.
Arguments
| name | type | description |
|---|---|---|
| token | string / array | target token |
| topic | string | topic untuk subscribe |
Return
Promise<Object>
Balasan dari firebase atas kondisi subscribe yang telah dilakukan.
sendWithTopic(payload)
Mengirim notifikasi berdasarkan topic.
Arguments
| name | type | description |
|---|---|---|
| payload | object | pesan dalam notifikasi berserta data nya |
| payload.notification | object | data notifikasi |
| payload.notification.title | string | judul notifikasi |
| payload.notification.body | string | body dari notifikasi |
| payload.notification.icon | string | url icon untuk notifikasi |
| payload.data | object | data notifikasi |
| payload.topic | string | topic target notifikasi |
Return
Promise<Object>
Respon status notifikasi.
sendTemplate(target, templateName, context, options)
Mengirim pesan menggunakan template.
Arguments
| name | type | description |
|---|---|---|
| target | string / array | target notifikasi |
| templateName | string | nama template |
| context | object | berisi values dan data |
| context.values | object | value yang dimasukkan ke dalam template |
| context.data | object | data yang dikirim untuk kebutuhan notifikasi |
| options | object | opsi untuk notifikasi |
| options.priority | string | prioritas notifikasi |
| options.timeToLive | number | time valid notification |
Return
Promise<Object>
Respon status pengiriman notifikasi.
getClient()
Berfungsi untuk mendapatkan client firebase.
Return
Instance client firebase.