Skip to content

Commit 2d1377b

Browse files
committed
fix: remove notifee
1 parent e0b61aa commit 2d1377b

File tree

6 files changed

+1
-140
lines changed

6 files changed

+1
-140
lines changed

examples/SampleApp/App.tsx

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { DarkTheme, DefaultTheme, NavigationContainer } from '@react-navigation/
44
import { createStackNavigator } from '@react-navigation/stack';
55
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
66
import { getMessaging } from '@react-native-firebase/messaging';
7-
import notifee, { EventType } from '@notifee/react-native';
87
import { AppContext } from './src/context/AppContext';
98
import { AppOverlayProvider } from './src/context/AppOverlayProvider';
109
import { UserSearchProvider } from './src/context/UserSearchContext';
@@ -42,17 +41,6 @@ console.assert = () => null;
4241
// when a channel id is set here, the intial route is the channel screen
4342
const initialChannelIdGlobalRef = { current: '' };
4443

45-
notifee.onBackgroundEvent(async ({ detail, type }) => {
46-
// user press on notification detected while app was on background on Android
47-
if (type === EventType.PRESS) {
48-
const channelId = detail.notification?.data?.channel_id as string;
49-
if (channelId) {
50-
navigateToChannel(channelId);
51-
}
52-
await Promise.resolve();
53-
}
54-
});
55-
5644
const Stack = createStackNavigator<StackNavigatorParamList>();
5745
const UserSelectorStack = createStackNavigator<UserSelectorParamList>();
5846
const App = () => {
@@ -70,24 +58,6 @@ const App = () => {
7058
}
7159
});
7260
// handle notification clicks on foreground
73-
const unsubscribeForegroundEvent = notifee.onForegroundEvent(({ detail, type }) => {
74-
if (type === EventType.PRESS) {
75-
// user has pressed the foreground notification
76-
const channelId = detail.notification?.data?.channel_id as string;
77-
if (channelId) {
78-
navigateToChannel(channelId);
79-
}
80-
}
81-
});
82-
notifee.getInitialNotification().then((initialNotification) => {
83-
if (initialNotification) {
84-
// Notification caused app to open from quit state on Android
85-
const channelId = initialNotification.notification.data?.channel_id as string;
86-
if (channelId) {
87-
initialChannelIdGlobalRef.current = channelId;
88-
}
89-
}
90-
});
9161
messaging.getInitialNotification().then((remoteMessage) => {
9262
if (remoteMessage) {
9363
// Notification caused app to open from quit state on iOS
@@ -100,7 +70,6 @@ const App = () => {
10070
});
10171
return () => {
10272
unsubscribeOnNotificationOpen();
103-
unsubscribeForegroundEvent();
10473
};
10574
}, []);
10675

examples/SampleApp/android/build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ allprojects {
3131
maven {
3232
url "$rootDir/../../../node_modules/detox/Detox-android"
3333
}
34-
// this is how Notifee finds it's Android library:
35-
maven {
36-
url "$rootDir/../node_modules/@notifee/react-native/android/libs"
37-
}
3834
}
3935
}
4036

examples/SampleApp/ios/Podfile.lock

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,30 +1470,6 @@ PODS:
14701470
- React-jsiexecutor
14711471
- React-RCTFBReactNativeSpec
14721472
- ReactCommon/turbomodule/core
1473-
- react-native-document-picker (10.1.3):
1474-
- DoubleConversion
1475-
- glog
1476-
- hermes-engine
1477-
- RCT-Folly (= 2024.11.18.00)
1478-
- RCTRequired
1479-
- RCTTypeSafety
1480-
- React-Core
1481-
- React-debug
1482-
- React-Fabric
1483-
- React-featureflags
1484-
- React-graphics
1485-
- React-hermes
1486-
- React-ImageManager
1487-
- React-jsi
1488-
- React-NativeModulesApple
1489-
- React-RCTFabric
1490-
- React-renderercss
1491-
- React-rendererdebug
1492-
- React-utils
1493-
- ReactCodegen
1494-
- ReactCommon/turbomodule/bridging
1495-
- ReactCommon/turbomodule/core
1496-
- Yoga
14971473
- react-native-netinfo (11.4.1):
14981474
- React-Core
14991475
- react-native-safe-area-context (5.4.1):
@@ -1950,11 +1926,6 @@ PODS:
19501926
- ReactCommon/turbomodule/bridging
19511927
- ReactCommon/turbomodule/core
19521928
- Yoga
1953-
- RNNotifee (9.1.8):
1954-
- React-Core
1955-
- RNNotifee/NotifeeCore (= 9.1.8)
1956-
- RNNotifee/NotifeeCore (9.1.8):
1957-
- React-Core
19581929
- RNScreens (4.11.1):
19591930
- DoubleConversion
19601931
- glog
@@ -2053,7 +2024,6 @@ DEPENDENCIES:
20532024
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
20542025
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
20552026
- React-microtasksnativemodule (from `../node_modules/react-native/ReactCommon/react/nativemodule/microtasks`)
2056-
- "react-native-document-picker (from `../node_modules/@react-native-documents/picker`)"
20572027
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
20582028
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
20592029
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
@@ -2091,7 +2061,6 @@ DEPENDENCIES:
20912061
- "RNFBApp (from `../node_modules/@react-native-firebase/app`)"
20922062
- "RNFBMessaging (from `../node_modules/@react-native-firebase/messaging`)"
20932063
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
2094-
- "RNNotifee (from `../node_modules/@notifee/react-native`)"
20952064
- RNScreens (from `../node_modules/react-native-screens`)
20962065
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
20972066

@@ -2194,8 +2163,6 @@ EXTERNAL SOURCES:
21942163
:path: "../node_modules/react-native/ReactCommon"
21952164
React-microtasksnativemodule:
21962165
:path: "../node_modules/react-native/ReactCommon/react/nativemodule/microtasks"
2197-
react-native-document-picker:
2198-
:path: "../node_modules/@react-native-documents/picker"
21992166
react-native-netinfo:
22002167
:path: "../node_modules/@react-native-community/netinfo"
22012168
react-native-safe-area-context:
@@ -2270,8 +2237,6 @@ EXTERNAL SOURCES:
22702237
:path: "../node_modules/@react-native-firebase/messaging"
22712238
RNGestureHandler:
22722239
:path: "../node_modules/react-native-gesture-handler"
2273-
RNNotifee:
2274-
:path: "../node_modules/@notifee/react-native"
22752240
RNScreens:
22762241
:path: "../node_modules/react-native-screens"
22772242
Yoga:
@@ -2333,7 +2298,6 @@ SPEC CHECKSUMS:
23332298
React-logger: 44e070aefe084568c02b544b9d7d436703be1a47
23342299
React-Mapbuffer: ed1f528261013e46790379cc6727b8005e169a67
23352300
React-microtasksnativemodule: da563fd4cb7ecc23f67b5f15b92dfe94a9791e2d
2336-
react-native-document-picker: 06ad77eb1650e628def114ff74f9f767f1888edd
23372301
react-native-netinfo: f0a9899081c185db1de5bb2fdc1c88c202a059ac
23382302
react-native-safe-area-context: f2e97b088ae5f3078f1ad03f51a44bd84f479053
23392303
React-NativeModulesApple: c761e39d8bb17a074530cb637ec6fe4460fac3af
@@ -2371,7 +2335,6 @@ SPEC CHECKSUMS:
23712335
RNFBApp: df5caad9f64b6bc87f8a0b110e6bc411fb00a12b
23722336
RNFBMessaging: 6586f18ab3411aeb3349088c19fe54283d39e529
23732337
RNGestureHandler: 2fa49aef8b58d35bcc61abe06ffecc4bcc5268a4
2374-
RNNotifee: 4a6ee5c7deaf00e005050052d73ee6315dff7ec9
23752338
RNScreens: d9d5d8a2a484bb4446968bfa00db991f1117db44
23762339
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
23772340
Yoga: b2eaabf17044cd4273a661b14eb83f9fd2c90491

examples/SampleApp/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
"clean-all": "yarn clean && rm -rf node_modules && rm -rf ios/Pods && rm -rf vendor && bundle install && yarn install && cd ios && bundle exec pod install && cd -"
2424
},
2525
"dependencies": {
26-
"@notifee/react-native": "^9.1.8",
2726
"@react-native-async-storage/async-storage": "^2.2.0",
2827
"@react-native-community/netinfo": "^11.4.1",
29-
"@react-native-documents/picker": "^10.1.3",
3028
"@react-native-firebase/app": "22.2.1",
3129
"@react-native-firebase/messaging": "22.2.1",
3230
"@react-navigation/bottom-tabs": "7.3.14",

examples/SampleApp/src/hooks/useChatClient.ts

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useEffect, useRef, useState } from 'react';
22
import { getMessaging, AuthorizationStatus } from '@react-native-firebase/messaging';
3-
import notifee from '@notifee/react-native';
43
import { USER_TOKENS, USERS } from '../ChatUsers';
54
import AsyncStore from '../utils/AsyncStore';
65

@@ -28,7 +27,7 @@ const requestAndroidPermission = async () => {
2827
};
2928

3029
export const useChatClient = () => {
31-
const [chatClient, setChatClient] = useState<StreamChat | null>(null);
30+
const [chatClient, setChatClient] = useState<null>(null);
3231
const [isConnecting, setIsConnecting] = useState(true);
3332

3433
const unsubscribePushListenersRef = useRef<() => void>(undefined);
@@ -40,19 +39,6 @@ export const useChatClient = () => {
4039
const loginUser = async (config: LoginConfig) => {
4140
// unsubscribe from previous push listeners
4241
unsubscribePushListenersRef.current?.();
43-
const client = StreamChat.getInstance(config.apiKey, {
44-
timeout: 6000,
45-
// logger: (type, msg) => console.log(type, msg)
46-
});
47-
setChatClient(client);
48-
49-
const user = {
50-
id: config.userId,
51-
image: config.userImage,
52-
name: config.userName,
53-
};
54-
await client.connectUser(user, config.userToken);
55-
await AsyncStore.setItem('@stream-rn-sampleapp-login-config', config);
5642

5743
const permissionAuthStatus = await messaging.hasPermission();
5844
let isEnabled =
@@ -82,13 +68,11 @@ export const useChatClient = () => {
8268
? providerNameOverride
8369
: (provider?.name ?? 'rn-fcm');
8470
const token = id === 'firebase' ? firebaseToken : (apnsToken ?? firebaseToken);
85-
await client.addDevice(token, id as PushProvider, client.userID, name);
8671

8772
// Listen to new FCM tokens and register them with stream chat server.
8873
const unsubscribeTokenRefresh = messaging.onTokenRefresh(async (newFirebaseToken) => {
8974
const newApnsToken = await messaging.getAPNSToken();
9075
const newToken = id === 'firebase' ? newFirebaseToken : (newApnsToken ?? firebaseToken);
91-
await client.addDevice(newToken, id as PushProvider, client.userID, name);
9276
});
9377
// show notifications when on foreground
9478
const unsubscribeForegroundMessageReceive = messaging.onMessage(async (remoteMessage) => {
@@ -97,64 +81,28 @@ export const useChatClient = () => {
9781
...rest,
9882
...((stream as unknown as Record<string, string> | undefined) ?? {}), // extract and merge stream object if present
9983
};
100-
const channelId = await notifee.createChannel({
101-
id: 'foreground',
102-
name: 'Foreground Messages',
103-
});
10484
// create the android channel to send the notification to
10585
// display the notification on foreground
10686
const notification = remoteMessage.notification ?? {};
10787
const body = (data.body ?? notification.body) as string;
10888
const title = (data.title ?? notification.title) as string;
10989

110-
if (body && title) {
111-
await notifee.displayNotification({
112-
android: {
113-
channelId,
114-
pressAction: {
115-
id: 'default',
116-
},
117-
},
118-
body,
119-
title,
120-
data,
121-
});
122-
}
12390
});
12491

12592
unsubscribePushListenersRef.current = () => {
12693
unsubscribeTokenRefresh();
12794
unsubscribeForegroundMessageReceive();
12895
};
12996
}
130-
setChatClient(client);
13197
};
13298

13399
const switchUser = async (userId?: string) => {
134-
if (chatClient?.userID) {
135-
return;
136-
}
137100

138101
setIsConnecting(true);
139102

140103
try {
141104
if (userId) {
142-
await loginUser({
143-
apiKey: 'yjrt5yxw77ev',
144-
userId: USERS[userId].id,
145-
userImage: USERS[userId].image,
146-
userName: USERS[userId].name,
147-
userToken: USER_TOKENS[userId],
148-
});
149105
} else {
150-
const config = await AsyncStore.getItem<LoginConfig | null>(
151-
'@stream-rn-sampleapp-login-config',
152-
null,
153-
);
154-
155-
if (config) {
156-
await loginUser(config);
157-
}
158106
}
159107
} catch (e) {
160108
console.warn(e);
@@ -164,8 +112,6 @@ export const useChatClient = () => {
164112

165113
const logout = async () => {
166114
setChatClient(null);
167-
chatClient?.disconnectUser();
168-
await AsyncStore.removeItem('@stream-rn-sampleapp-login-config');
169115
};
170116

171117
useEffect(() => {
@@ -175,7 +121,6 @@ export const useChatClient = () => {
175121
};
176122
run();
177123
return unsubscribePushListenersRef.current;
178-
// eslint-disable-next-line react-hooks/exhaustive-deps
179124
}, []);
180125

181126
return {

examples/SampleApp/yarn.lock

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,11 +1830,6 @@
18301830
"@nodelib/fs.scandir" "2.1.5"
18311831
fastq "^1.6.0"
18321832

1833-
"@notifee/react-native@^9.1.8":
1834-
version "9.1.8"
1835-
resolved "https://registry.yarnpkg.com/@notifee/react-native/-/react-native-9.1.8.tgz#3d55cb3fbcc21f9e35931e366afdf64b294da891"
1836-
integrity sha512-Az/dueoPerJsbbjRxu8a558wKY+gONUrfoy3Hs++5OqbeMsR0dYe6P+4oN6twrLFyzAhEA1tEoZRvQTFDRmvQg==
1837-
18381833
"@pkgjs/parseargs@^0.11.0":
18391834
version "0.11.0"
18401835
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
@@ -2062,11 +2057,6 @@
20622057
resolved "https://registry.yarnpkg.com/@react-native-community/netinfo/-/netinfo-11.4.1.tgz#a3c247aceab35f75dd0aa4bfa85d2be5a4508688"
20632058
integrity sha512-B0BYAkghz3Q2V09BF88RA601XursIEA111tnc2JOaN7axJWmNefmfjZqw/KdSxKZp7CZUuPpjBmz/WCR9uaHYg==
20642059

2065-
"@react-native-documents/picker@^10.1.3":
2066-
version "10.1.3"
2067-
resolved "https://registry.yarnpkg.com/@react-native-documents/picker/-/picker-10.1.3.tgz#105d2376dd488a36861073218a9470227d2f5100"
2068-
integrity sha512-nHgJFXEfNYo49Of55RB1zkdVhUCI/R0g2R7H3nzBQINo+EO+UvMViSvV8AcVXG/ZJakOt1gukOoJUX1g7Br8Aw==
2069-
20702060
"@react-native-firebase/[email protected]":
20712061
version "22.2.1"
20722062
resolved "https://registry.yarnpkg.com/@react-native-firebase/app/-/app-22.2.1.tgz#640f84c5bda89c58503bfdde376853eb3ac47ced"

0 commit comments

Comments
 (0)