We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3320ecb commit 0418379Copy full SHA for 0418379
1 file changed
packages/expo/src/modules/push/KnockExpoPushNotificationProvider.tsx
@@ -188,6 +188,23 @@ const InternalKnockExpoPushNotificationProvider: React.FC<
188
[knockClient],
189
);
190
191
+ useEffect(() => {
192
+ const fetchExpoTokenIfNeeded = async () => {
193
+ const { status: existingStatus } =
194
+ await Notifications.getPermissionsAsync();
195
+ if (existingStatus === "granted" && Device.isDevice) {
196
+ try {
197
+ const token = await getExpoPushToken();
198
+ setExpoPushToken(token ? token.data : null);
199
+ } catch (error) {
200
+ console.error(`[Knock] Error getting expo push token:`, error);
201
+ }
202
203
+ };
204
+
205
+ fetchExpoTokenIfNeeded();
206
+ }, []);
207
208
useEffect(() => {
209
Notifications.setNotificationHandler({
210
handleNotification:
0 commit comments