-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-push.cjs
More file actions
28 lines (22 loc) · 767 Bytes
/
test-push.cjs
File metadata and controls
28 lines (22 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const admin = require("firebase-admin");
const serviceAccount = require("./storage/app/firebase-credentials.json");
console.log("Mulai inisialisasi...");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
const registrationToken = 'f3r50M6X2xDtwSMmPbyJES:APA91bG9DQi1YjSWkfKl6gLgYtNzVZ6AzY0mAo-DT0C4NGmBCzTJCuX12cREDXNJRYLLVWzZT2FkwIu85l7FpDgU0Erm3prAQNdzGFRmp1buNTeRgMlZS70';
const message = {
notification: {
title: 'Woi Dimas!',
body: 'Tes dari Backend nih!'
},
token: registrationToken
};
console.log("Sedang mengirim ke Firebase...");
admin.messaging().send(message)
.then((response) => {
console.log('BERHASIL! Response:', response);
})
.catch((error) => {
console.error('ERROR KIRIM:', error);
});