diff options
| author | Shravya Ramesh <37447613+shravyaramesh@users.noreply.github.com> | 2021-04-23 15:06:01 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-23 15:06:01 -0700 |
| commit | a27963c51aa2c0b65dd23b5e7211addf5995046f (patch) | |
| tree | 3c2b2328384630b6388ed77773ee6470e17df23d /src/services | |
| parent | ce5bf93fef3f5108e0dca35bf24accb4d9d654bb (diff) | |
| parent | 5e247c2045fa53616008aae73f0192ffed048709 (diff) | |
Merge branch 'master' into tma-807-onpress-indicator
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/FCMService.ts | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/services/FCMService.ts b/src/services/FCMService.ts index 84f30f09..711483ec 100644 --- a/src/services/FCMService.ts +++ b/src/services/FCMService.ts @@ -2,8 +2,10 @@ import AsyncStorage from '@react-native-community/async-storage'; import messaging from '@react-native-firebase/messaging'; import {Platform} from 'react-native'; import {getDeviceId, getDeviceName} from 'react-native-device-info'; +import {StreamChat} from 'stream-chat'; import {FCM_ENDPOINT} from '../constants'; import * as RootNavigation from '../RootNavigation'; + class FCMService { setUpPushNotifications = () => { // Requesting user to permit notifications @@ -78,10 +80,13 @@ class FCMService { return ''; }; - sendFcmTokenToServer = async () => { + sendFcmTokenToServer = async (chatClient: StreamChat) => { const registration_id: string | null = await AsyncStorage.getItem( '@fcmToken', ); + if (registration_id !== null) { + chatClient.addDevice(registration_id, 'firebase'); + } const device_id = getDeviceId(); const type = Platform.OS; let active: boolean = false; @@ -117,7 +122,6 @@ class FCMService { console.log('Successfully stored device token!'); } else { console.log('Failed to store device token!'); - console.log(response); } } }; |
