diff --git a/App.js b/App.js index d02f121..55443ef 100644 --- a/App.js +++ b/App.js @@ -32,14 +32,27 @@ const theme = { }; Notifications.setNotificationHandler({ - handleNotification: async () => ({ - shouldShowAlert: true, - shouldPlaySound: false, - shouldSetBadge: false, - }), + handleNotification: async () => { + //console.log("notif background"); + return { + shouldShowAlert: true, + shouldPlaySound: true, + shouldSetBadge: true, + }; + }, }); async function registerForPushNotificationsAsync() { + + if (Platform.OS === 'android') { + Notifications.setNotificationChannelAsync('default', { + name: 'default', + importance: Notifications.AndroidImportance.MAX, + vibrationPattern: [0, 250, 250, 250], + lightColor: '#FF231F7C', + }); + } + let token; if (Device.isDevice) { const { status: existingStatus } = await Notifications.getPermissionsAsync(); @@ -53,21 +66,9 @@ async function registerForPushNotificationsAsync() { return; } token = (await Notifications.getExpoPushTokenAsync({ projectId: "c2bb4d4e-4d4d-4f34-a873-7cad78c6023c", })).data; - console.log(token); } else { alert('Must use physical device for Push Notifications'); } - - if (Platform.OS === 'android') { - Notifications.setNotificationChannelAsync('default', { - name: 'default', - importance: Notifications.AndroidImportance.MAX, - vibrationPattern: [0, 250, 250, 250], - lightColor: '#FF231F7C', - }); - } - - console.log(token); return token; } @@ -89,11 +90,13 @@ const MainNavigation = () => { // This listener is fired whenever a notification is received while the app is foregrounded notificationListener.current = Notifications.addNotificationReceivedListener(notification => { + //console.log("got notif", notification) setNotification(notification); }); // This listener is fired whenever a user taps on or interacts with a notification (works when app is foregrounded, backgrounded, or killed) responseListener.current = Notifications.addNotificationResponseReceivedListener(response => { + //console.log("got notif click", notification) console.log(response); }); diff --git a/package-lock.json b/package-lock.json index 3675f44..e7bf2b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "expo-image-picker": "~14.0.2", "expo-notifications": "~0.17.0", "expo-status-bar": "~1.4.2", + "expo-task-manager": "~11.0.1", "expo-updates": "~0.15.6", "moment": "^2.29.1", "react": "18.1.0", @@ -6879,6 +6880,17 @@ "resolved": "https://registry.npmjs.org/expo-structured-headers/-/expo-structured-headers-3.0.1.tgz", "integrity": "sha512-x6hkzuQL5HJoyB+xQyBf9M04ZUmrjFWqEW7gzIYWN/6LA+dgyaV4fF6U9++Re+GgGjF03vHJFqR1xYaosKKZYQ==" }, + "node_modules/expo-task-manager": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/expo-task-manager/-/expo-task-manager-11.0.1.tgz", + "integrity": "sha512-9KXWkQyzldiTBz0+wRe7ypQQ0m02j838f8j0pDRrDbW2X5hBUJWzDGq7OItJ5F9vDjJ3oRZikOAhFGj+wxh3EA==", + "dependencies": { + "unimodules-app-loader": "~4.0.0" + }, + "peerDependencies": { + "expo": "*" + } + }, "node_modules/expo-updates": { "version": "0.15.6", "resolved": "https://registry.npmjs.org/expo-updates/-/expo-updates-0.15.6.tgz", @@ -12709,6 +12721,11 @@ "node": ">=4" } }, + "node_modules/unimodules-app-loader": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unimodules-app-loader/-/unimodules-app-loader-4.0.0.tgz", + "integrity": "sha512-YlV0rOM9pjdeTMEGR0rr/u+F7f1ygINUsTEiRIPvBewTk3Si/Sm8Ur5f92n+f0Sy1EIuOTGgyGaUdjJBfAd0YA==" + }, "node_modules/union-value": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", @@ -18406,6 +18423,14 @@ "resolved": "https://registry.npmjs.org/expo-structured-headers/-/expo-structured-headers-3.0.1.tgz", "integrity": "sha512-x6hkzuQL5HJoyB+xQyBf9M04ZUmrjFWqEW7gzIYWN/6LA+dgyaV4fF6U9++Re+GgGjF03vHJFqR1xYaosKKZYQ==" }, + "expo-task-manager": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/expo-task-manager/-/expo-task-manager-11.0.1.tgz", + "integrity": "sha512-9KXWkQyzldiTBz0+wRe7ypQQ0m02j838f8j0pDRrDbW2X5hBUJWzDGq7OItJ5F9vDjJ3oRZikOAhFGj+wxh3EA==", + "requires": { + "unimodules-app-loader": "~4.0.0" + } + }, "expo-updates": { "version": "0.15.6", "resolved": "https://registry.npmjs.org/expo-updates/-/expo-updates-0.15.6.tgz", @@ -22861,6 +22886,11 @@ "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.1.0.tgz", "integrity": "sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w==" }, + "unimodules-app-loader": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unimodules-app-loader/-/unimodules-app-loader-4.0.0.tgz", + "integrity": "sha512-YlV0rOM9pjdeTMEGR0rr/u+F7f1ygINUsTEiRIPvBewTk3Si/Sm8Ur5f92n+f0Sy1EIuOTGgyGaUdjJBfAd0YA==" + }, "union-value": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",