푸시알림 전송
(구버전 로직) sendToDevice
Node.js
- 단일 디바이스, 멀티 디바이스 다 이 API 하나로 가능.
- 단일 디바이스로 전송이라면 배열 안써도 됨.
// These registration tokens come from the client FCM SDKs. var registrationTokens = [ 'bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...', // ... 'ecupwIfBy1w:APA91bFtuMY7MktgxA3Au_Qx7cKqnf...' ]; // See the "Defining the message payload" section below for details // on how to define a message payload. var payload = { data: { score: '850', time: '2:45' } }; // Send a message to the devices corresponding to the provided // registration tokens. admin.messaging().sendToDevice(registrationTokens, payload) .then(function(response) { // See the MessagingDevicesResponse reference documentation for // the contents of response. console.log('Successfully sent message:', response); }) .catch(function(error) { console.log('Error sending message:', error); });