Klat
  • Klat SDK
  • Android
    • Getting Started
    • Callback
    • User
      • 사용자 생성 / 로그인
      • 사용자 정보 업데이트
      • 사용자 차단 목록 관리
      • 사용자 로그아웃
      • 사용자 삭제
    • Channel
      • 채널 생성 / 삭제
      • 채널 조회
      • 채널 정보 업데이트
      • 채널 목록 조회
      • 채널 사용자 관리
      • 채널 참여 / 나가기
      • 채널 내 메시징
      • 채널 숨기기 / 보이기
      • 채널 Freeze / Unfreeze
      • 채널 주인 변경
      • 채널 푸시알림 설정
      • 채널별 개인 데이터 설정
    • Push Notification
    • Sample Application
    • What's New
  • iOS
    • Getting Started
    • Callback
    • User
      • 사용자 생성 / 로그인
      • 사용자 정보 업데이트
      • 사용자 차단 목록 관리
      • 사용자 로그아웃
      • 사용자 삭제
    • Channel
      • 채널 생성 / 삭제
      • 채널 조회
      • 채널 정보 업데이트
      • 채널 목록 조회
      • 채널 사용자 관리
      • 채널 참여 / 나가기
      • 채널 내 메시징
      • 채널 숨기기 / 보이기
      • 채널 Freeze / Unfreeze
      • 채널 주인 변경
      • 채널 푸시알림 설정
      • 채널별 개인 데이터 설정
    • Push Notification
    • Sample Application
    • What's New
  • Unity
    • Getting Started
    • Callback
    • User
      • 사용자 생성 / 로그인
      • 사용자 정보 업데이트
      • 사용자 차단 목록 관리
      • 사용자 로그아웃
      • 사용자 삭제
    • Channel
      • 채널 생성 / 삭제
      • 채널 조회
      • 채널 정보 업데이트
      • 채널 목록 조회
      • 채널 사용자 관리
      • 채널 참여 / 나가기
      • 채널 내 메시징
      • 채널 숨기기 / 보이기
      • 채널 Freeze / Unfreeze
      • 채널 주인 변경
      • 채널 푸시알림 설정
      • 채널별 개인 데이터 설정
    • Push Notification
    • Sample Application
  • JavaScript
    • Getting Started
    • Realtime Event
    • Pagination
    • User
      • 사용자 생성 / 로그인
      • 사용자 정보 업데이트
      • 사용자 차단 목록 관리
      • 사용자 로그아웃
      • 사용자 삭제
    • Channel
      • 채널 생성 / 삭제
      • 채널 조회
      • 채널 정보 업데이트
      • 채널 목록 조회
      • 채널 사용자 관리
      • 채널 참여 / 나가기
      • 채널 내 메시징
      • 채널 숨기기 / 보이기
      • 채널 Freeze / Unfreeze
      • 채널 주인 변경
      • 채널 푸시알림 설정
      • 채널별 개인 데이터 설정
    • Push Notification (FCM)
    • Sample Application
    • What's New
  • Flutter
    • Getting Started
    • Callback
    • User
      • 사용자 생성 / 로그인
      • 사용자 정보 업데이트
      • 사용자 차단 목록 관리
      • 사용자 로그아웃
      • 사용자 삭제
    • Channel
      • 채널 생성 / 삭제
      • 채널 조회
      • 채널 정보 업데이트
      • 채널 목록 조회
      • 채널 사용자 관리
      • 채널 참여 / 나가기
      • 채널 내 메시징
      • 채널 숨기기 / 보이기
      • 채널 Freeze / Unfreeze
      • 채널 주인 변경
      • 채널 푸시알림 설정
      • 채널별 개인 데이터 설정
    • Push Notification
  • REST API
    • Getting Started
    • API
      • User
        • 사용자 생성
        • 사용자 로그인 (로그인 토큰)
        • 사용자 조회
        • 사용자 정보 업데이트
        • 사용자 활성화 / 비활성화
        • 사용자 푸시 알림 설정
        • 사용자 삭제
        • 사용자 목록 조회
        • 사용자 채널 조회
        • 사용자 차단 목록 관리
      • Channel
        • 채널 생성
        • 채널 조회
        • 채널 정보 업데이트
        • 채널 삭제
        • 채널 목록 조회
        • 채널 사용자 관리
        • 채널 내 메시징
        • 채널 숨기기 / 보이기
        • 채널 Freeze / Unfreeze
        • 채널 주인 변경
        • 채널 알림 설정
      • App
        • 앱 조회
        • 앱 생성
        • 앱 삭제
      • Bot
        • 봇 생성
        • 봇 목록 조회
        • 봇 조회
        • 봇 정보 업데이트
        • 봇 삭제
        • 봇 채널 목록 조회
        • 봇 채널 내 메시징
        • 봇 채널 참여 / 나가기
    • Push Notification
    • Rate Limit
  • MISC
    • Webhooks
    • SDK Rate Limit
    • Error Code
    • FAQ
      • Function
      • Spec
Powered by GitBook
On this page
  • Web Push Notification
  • Enable / Disable Push Notification
  • SPA (Single Page Applications)
  1. JavaScript

Push Notification (FCM)

Web Push Notification

현재 브라우저 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)

FCM 토큰 등록

react-native와 같은 hybrid app에서 사용하는 FCM 토큰은 다음과 같이 등록할 수 있습니다:

await client.registerFcmToken({fcmToken: '<YOUR_FCM_TOKEN>'});    

FCM RemoteMessage 파싱

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>}],
		},
	}
	 */	
}
Previous채널별 개인 데이터 설정NextSample Application

Last updated 11 months ago