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

feat(mobile): add integration with gateway backend for notifications feature #4878

Open
wants to merge 27 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
50af7ca
feat: add dedicated hook for delegation
Jonathansoufer Feb 4, 2025
67d6a07
chore: move constants to global
Jonathansoufer Feb 4, 2025
d75da8e
fix: typo
Jonathansoufer Feb 4, 2025
07e4b56
feat: create delegate hook
Jonathansoufer Feb 5, 2025
178d4d0
refactor: sending signature
Jonathansoufer Feb 5, 2025
34dc5e7
chore: add siwe lib and utils
Jonathansoufer Feb 7, 2025
ef8b296
fix: add cockie auth on RTK
Jonathansoufer Feb 7, 2025
df34acc
chore: add debug logger
Jonathansoufer Feb 7, 2025
497cce7
feat: add siwe hook
Jonathansoufer Feb 7, 2025
81d76fa
feat: add useDelegate hook
Jonathansoufer Feb 7, 2025
3e83d6f
Merge branch 'dev' into feat/notifications-gtw-integration
Jonathansoufer Feb 7, 2025
6166897
chore: add support to random numbers generation
Jonathansoufer Feb 13, 2025
dcece0e
chore: adds sign w ethereum hook
Jonathansoufer Feb 13, 2025
9259893
chore: adds specific function to return signer
Jonathansoufer Feb 13, 2025
bdb6c84
chore: removes console.log
Jonathansoufer Feb 13, 2025
6a7264e
chore: adds hook to hold interaction w/ gateway
Jonathansoufer Feb 13, 2025
8158986
chore: adds redux structure for delegators
Jonathansoufer Feb 13, 2025
fd1ca3f
chore: adds timeout wrapper
Jonathansoufer Feb 13, 2025
f5d09ab
chore: adds userId
Jonathansoufer Feb 13, 2025
7bf5d31
refactor: useDelegator hook
Jonathansoufer Feb 13, 2025
8109e9b
refactor: fixes key generation and granted rights
Jonathansoufer Feb 18, 2025
8364bb4
Merge branch 'dev' into feat/notifications-gtw-integration
Jonathansoufer Feb 18, 2025
18690de
chore: addresses various fixes based on first round of review
Jonathansoufer Feb 19, 2025
3fd07b7
fix: merge conflicts
Jonathansoufer Feb 19, 2025
c8ae5be
chore: update yarn.lock
Jonathansoufer Feb 19, 2025
a0b15ee
chore: add warning ignoring pattern on FB
Jonathansoufer Feb 24, 2025
663bbe7
refactor: enablement rules & order
Jonathansoufer Feb 24, 2025
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
Prev Previous commit
Next Next commit
chore: adds timeout wrapper
  • Loading branch information
Jonathansoufer committed Feb 13, 2025
commit fd1ca3f223976f358c65c60874cff80edb949183
29 changes: 15 additions & 14 deletions apps/mobile/src/services/notifications/FCMService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//@ts-ignore
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we better move this to the entry point of the application. It's a bit weird to have this global var first in the FCMService. It seems to be a global thing that react-native-firebase "needs".

import messaging, { FirebaseMessagingTypes } from '@react-native-firebase/messaging'
import Logger from '@/src/utils/logger'
import NotificationsService from './NotificationService'
import { ChannelId } from '@/src/utils/notifications'
import { ChannelId, withTimeout } from '@/src/utils/notifications'
import { store } from '@/src/store'
import { savePushToken } from '@/src/store/notificationsSlice'

Expand All @@ -11,6 +13,7 @@ class FCMService {
async getFCMToken(): Promise<string | undefined> {
const { fcmToken } = store.getState().notifications
const token = fcmToken || undefined

if (!token) {
Logger.info('getFCMToken: No FCM token found')
}
Expand All @@ -19,8 +22,7 @@ class FCMService {

async saveFCMToken(): Promise<void> {
try {
const fcmToken = await messaging().getToken()

const fcmToken = await withTimeout(messaging().getToken(), 5000)
Logger.info('FCMService :: fcmToken', fcmToken)

if (fcmToken) {
Expand Down Expand Up @@ -55,17 +57,16 @@ class FCMService {
}

async registerAppWithFCM(): Promise<void> {
// if (!messaging().registerDeviceForRemoteMessages) {
console.log('registerAppWithFCM :: CALLED')
await messaging()
.registerDeviceForRemoteMessages()
.then((status: unknown) => {
Logger.info('registerDeviceForRemoteMessages status', status)
})
.catch((error) => {
Logger.error('registerAppWithFCM: Something went wrong', error)
})
// }
if (!messaging().registerDeviceForRemoteMessages) {
await messaging()
.registerDeviceForRemoteMessages()
.then((status: unknown) => {
Logger.info('registerDeviceForRemoteMessages status', status)
})
.catch((error) => {
Logger.error('registerAppWithFCM: Something went wrong', error)
})
}
}
}
export default new FCMService()