Klat
  • TalkPlus SDK
  • Android
    • Getting Started
    • Callback
    • User
      • Create User / Login
      • Update User Information
      • Block / Unblock
      • Logout
      • Delete User
    • Channel
      • Create / Delete Channel
      • View Channel
      • Updating Channel
      • Viewing Channel LIst
      • Manage Channel Members
      • Join / Leave Channel
      • Messaging
      • Hide / Show Channel
      • Freeze / Unfreeze Channel
      • Transfer Channel Ownership
      • Channel Push Notification Settings
      • Channel Member Data
    • Push Notification
    • Sample Application
    • What's New
  • iOS
    • Getting Started
    • Callback
    • User
      • Create / Login
      • Update User Information
      • Block / Unblock
      • Logout
      • Delete User
    • Channel
      • Create / Delete Channel
      • View Channel
      • Updating Channel
      • View Channel List
      • Manage Channel Members
      • Join / Leave Channel
      • Messaging
      • Hide / Show Channel
      • Freeze / Unfreeze Channel
      • Transfer Channel Ownership
      • Channel Push Notification Settings
      • Channel Member Data
    • Push Notification
    • Sample Application
    • What's New
  • Unity
    • Getting Started
    • Callback
    • User
      • Create User / Login
      • Update User Information
      • Block / Unblock
      • Logout
      • Delete User
    • Channel
      • Create / Delete Channel
      • View Channel
      • Updating Channel
      • View Channel List
      • Manage Channel Members
      • Join / Leave Channel
      • Messaging
      • Hide / Show Channel
      • Freeze / Unfreeze Channel
      • Transfer Channel Ownership
      • Channel Push Notification Settings
      • Channel Member Data
    • Push Notification
    • Sample Application
  • JavaScript
    • Getting Started
    • Realtime Event
    • Pagination
    • User
      • Create User / Login
      • Update User Information
      • Block / Unblock
      • Logout
      • Delete
    • Channel
      • Create / Delete Channel
      • View Channel
      • Updating Channel
      • View Channel List
      • Manage Channel Members
      • Join / Leave Channel
      • Messaging
      • Hide / Show Channel
      • Freeze / Unfreeze Channel
      • Transfer Channel Ownership
      • Channel Push Notification Settings
      • Channel Member Data
    • Push Notification (FCM)
    • Sample Application
    • What's New
  • Flutter
    • Getting Started
    • Callback
    • User
      • Create User / Login
      • Update User Information
      • Block / Unblock
      • Logout
      • Delete User
    • Channel
      • Create Channel
      • View Channel
      • Updating Channel
      • View Channel List
      • Manage Channel Members
      • Join / Leave Channel
      • Messaging
      • Hide / Show Channel
      • Freeze / Unfreeze Channel
      • Transfer Channel Ownership
      • Channel Push Notification Settings
      • Channel Member Data
    • Push Notification (FCM)
  • REST API
    • Getting Started
    • API
      • Users
        • Create User
        • Login (using login token)
        • View User
        • Update User
        • Activate / Deactivate
        • Enable / Disable Push Notification
        • Delete User
        • View Users
        • View Channels
        • Block / Unblock
      • Channel
        • Create Channel
        • View Channel
        • Update Channel
        • Delete Channel
        • View Channel List
        • Manage Channel Members
        • Messaging
        • Hide / Show Channel
        • Channel Freeze / Unfreeze
        • Transfer Channel Ownership
        • Channel Push Notification Settings
      • Bot
        • Create Bot
        • View Bot List
        • View Bot
        • Update Bot
        • Delete Bot
        • View Joined Channel List
        • Messaging
        • Join / Leave Channel
    • 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 is not supported.

Enable / Disable Push Notification

You can enable or disable user push notification (FCM) by calling the following methods:

// Enable push notification
await client.enablePushNotification();

// Disable push notification
await client.disablePushNotification();

SPA (Single Page Applications)

Registering FCM Token

Registering an FCM token enables you to receive push notifications in hybrid apps (such as React Native):

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

FCM RemoteMessage

You can parse FCM RemoteMessage as follows:

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>}],
		},
	}
	 */	
}
PreviousChannel Member DataNextSample Application

Last updated 11 months ago