Skip to content

Commit

Permalink
Fix double notification on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
neven-s committed Dec 13, 2024
1 parent 828c6f7 commit c2d52cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packages/core-mobile/app/services/fcm/FCMService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
BalanceChangeEvents,
NotificationsBalanceChangeSchema
} from 'services/fcm/types'
import { Platform } from 'react-native'

type UnsubscribeFunc = () => void

Expand Down Expand Up @@ -59,6 +60,10 @@ class FCMService {
listenForMessagesBackground = (): void => {
messaging().setBackgroundMessageHandler(async remoteMessage => {
Logger.info('A new FCM message arrived in background', remoteMessage)
if (Platform.OS === 'android') {
//skip for android, FCM sdk handles this already
return
}
const result = NotificationsBalanceChangeSchema.safeParse(remoteMessage)
if (!result.success) {
Logger.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,16 +321,14 @@ class NotificationsService {
pressAction: {
id: PressActionId.OPEN_PORTFOLIO,
launchActivity: LAUNCH_ACTIVITY
}
},
channelId: channelId ?? ''
},
data
}
if (sound) {
notification.ios = { sound: sound }
}
if (channelId && notification.android) {
notification.android.channelId = channelId
}
await notifee.displayNotification(notification).catch(Logger.error)
}
}
Expand Down

0 comments on commit c2d52cd

Please sign in to comment.