현재 브라우저 Web Push Notification 기능을 제공하고 있지 않습니다.
Enable / Disable Push Notification
사용자가 Push Notification을 받을 지 여부를 설정할 수 있습니다.
// Enable push notification
await client.enablePushNotification();
// Disable push notification
await client.disablePushNotification();
SPA (Single Page Applications)
await client.registerFcmToken({fcmToken: '<YOUR_FCM_TOKEN>'});
FCM remote message를 읽기 위해서는 다음 코드 예제와 같이 추가 처리가 필요합니다.
const notification = await client.getNotification(fcmRemoteMessageData);
if (['message', 'messageDeleted'].includes(notification.type)) {
console.log(notification.data);
/*
{
type: 'message', // or 'messageDeleted'
data: {
channel: {<channel object>},
message: {<message object>},
},
}
*/
}
if (['channelAdded', 'channelChanged', 'channelRemoved'].includes(notification.type)) {
console.log(notification.data);
/*
{
type: 'channelAdded', // or 'channelChanged', 'channelRemoved'
data: {
channel: {<channel object>},
},
}
*/
}
if (['memberAdded', 'memberLeft', 'memberMuted', 'memberUnmuted', 'memberBanned', 'memberUnbanned'].includes(notification.type)) {
console.log(notification.data);
/*
{
type: 'memberAdded', // or 'memberLeft', 'memberMuted', 'memberUnmuted', 'memberBanned', 'memberUnbanned'
data: {
channel: {<channel object>},
users: [{<user object>}],
},
}
*/
}