Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix double notification on Android #2156

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading