Integrasi API Gateway
Selamat datang di dokumentasi pengiriman notifikasi FCM. Sistem ini menggunakan arsitektur message queue (RabbitMQ) untuk memastikan pengiriman pesan yang handal dan cepat.
Konfigurasi Dasar
Seluruh endpoint API dapat diakses melalui base URL berikut:
Gunakan header wajib berikut:
Content-Type: application/json
Single Device Notification
Gunakan mode ini untuk mengirim pesan personal ke satu pengguna tertentu menggunakan token unik mereka.
Request Payload
{
"to": "TOKEN_PERANGKAT_XYZ",
"notification": {
"title": "Halo!",
"body": "Ini adalah isi pesan notifikasi.",
"sound": "default"
},
"data": {
"key1": "value1",
"key2": "value2"
},
"android": {
"priority": "high"
},
"time_to_live": 3600
}
| Field | Type | Required | Description |
|---|---|---|---|
to |
String | Yes | Target token FCM perangkat. |
notification.title |
String | Yes | Judul pesan. |
notification.body |
String | Yes | Isi pesan. |
notification.sound |
String | No | Suara notifikasi (contoh: default). |
data |
Object | No | Payload kustom (Key-Value) untuk diolah aplikasi. |
android.priority |
String | No | Prioritas Android (high atau normal). |
time_to_live |
Number | No | Masa aktif pesan dalam detik (default 3600). |
Topic / Condition
Mengirim pesan ke sekelompok pengguna yang berlangganan topik tertentu secara spesifik.
Request Payload
{
"condition": "'promo' in topics || 'newsletter' in topics",
"notification": {
"title": "Berita Baru",
"body": "Ada berita terbaru nih!"
}
}
| Field | Type | Required | Description |
|---|---|---|---|
condition |
String | Yes | Logika pemilihan topik (contoh: 'weather' in topics). |
notification.title |
String | Yes | Judul pesan untuk target topik. |
notification.body |
String | Yes | Isi pesan untuk target topik. |
Note: Sintaks condition mendukung operator logika OR (||) dan AND (&&).
Multi Device Notification
Kirim pesan yang sama ke maksimal 1000 perangkat dalam satu kali request.
Request Payload
{
"registration_ids": ["TOKEN_1", "TOKEN_2", "TOKEN_3"],
"notification": {
"title": "Broadcast",
"body": "Pesan untuk banyak orang"
},
"collapse_key": "broadcast_update"
}
| Field | Type | Required | Description |
|---|---|---|---|
registration_ids |
Array | Yes | Daftar token perangkat (Maksimal 1000). |
notification.title |
String | Yes | Judul pesan. |
notification.body |
String | Yes | Isi pesan. |
collapse_key |
String | No | Grup notifikasi agar hanya pesan terbaru yang muncul. |
Platform Specific Config
Gunakan konfigurasi ini untuk memberikan visual dan perilaku berbeda antar Android dan iOS (APNS).
Request Payload
{
"to": "TOKEN_XYZ",
"notification": {
"title": "Notifikasi Keren",
"body": "Dengan fitur spesifik platform"
},
"android": {
"priority": "high",
"notification": {
"channel_id": "important_channel",
"color": "#FF0000",
"image": "https://example.com/image.jpg"
}
},
"apns": {
"headers": {
"apns-priority": "10"
},
"payload": {
"aps": {
"alert": {
"title": "Notifikasi Keren",
"body": "Untuk iOS"
},
"badge": 5,
"sound": "default"
}
}
}
}
| Field | Type | Required | Description |
|---|---|---|---|
android.notification.channel_id |
String | No | ID Channel notifikasi Android. |
android.notification.color |
String | No | Warna ikon notifikasi dalam format Hex. |
android.notification.image |
String | No | URL gambar untuk notifikasi Android. |
apns.headers.apns-priority |
String | No | Prioritas APNS (10 atau 5). |
apns.payload.aps.badge |
Number | No | Jumlah angka pada badge ikon aplikasi iOS. |
apns.payload.aps.alert.title |
String | No | Judul khusus untuk perangkat iOS. |
Topic Management
Endpoint untuk mendaftarkan atau menghapus token dari topik tertentu.
Request Payload
{
"topic": "berita",
"tokens": ["token_1", "token_2"]
}
| Field | Type | Required | Description |
|---|---|---|---|
topic |
String | Yes | Nama topik (contoh: berita). |
tokens |
Array | Yes | Daftar token perangkat yang ingin dikelola. |
Endpoints: