Closed sahag98 closed 5 months ago
Hi there! It looks like your issue requires a minimal reproducible example, but it is invalid or absent. Please prepare such an example and share it in a new issue.
The best way to get attention to your issue is to provide a clean and easy way for a developer to reproduce the issue on their own machine. Please do not provide your entire project, or a project with more code than is necessary to reproduce the issue.
A side benefit of going through the process of narrowing down the minimal amount of code needed to reproduce the issue is that you may get lucky and discover that the bug is due to a mistake in your application code that you can quickly fix on your own.
"How to narrow down the source of an error"
You may not have spent enough time narrowing down the root cause of the issue. Try out the techniques discussed in this manual debugging guide to learn how to isolate the problem from the rest of your codebase.
That's understandable, it can take some time to prepare. We ask that you hold off on filing an issue until you are able to fully complete the required fields in the issue template.
This is useful knowledge, but it's still valuable to have the resulting project that is produced from running the steps, where you have verified you can reproduce the issue.
Summary
ResponseListener not firing on dev/prod builds. It's only firing within expo go.
responseListener.current = Notifications.addNotificationResponseReceivedListener((response) => { console.log("response: ", response); //nothing is being logged. });
Managed or bare workflow?
managed
What platform(s) does this occur on?
iOS
Package versions
"dependencies": { "@babel/plugin-proposal-export-namespace-from": "^7.18.9", "@config-plugins/react-native-webrtc": "7.0.0", "@expo/config-plugins": "~7.2.2", "@expo/metro-config": "~0.10.0", "@expo/prebuild-config": "~6.2.4", "@expo/webpack-config": "^19.0.0", "@legendapp/motion": "^2.3.0", "@miblanchard/react-native-slider": "^2.3.1", "@notifee/react-native": "^7.8.2", "@react-native-async-storage/async-storage": "1.18.2", "@react-native-community/blur": "^4.3.0", "@react-native-community/datetimepicker": "7.2.0", "@react-native-community/netinfo": "9.3.10", "@react-native-masked-view/masked-view": "0.2.9", "@react-navigation/bottom-tabs": "^6.5.7", "@react-navigation/drawer": "^6.6.2", "@react-navigation/native": "^6.1.6", "@react-navigation/native-stack": "^6.9.12", "@react-navigation/stack": "^6.3.16", "@reduxjs/toolkit": "^1.9.3", "@sanity/client": "^5.4.2", "@sanity/image-url": "^1.0.2", "@shopify/flash-list": "1.4.3", "@stream-io/react-native-webrtc": "^118.0.1", "@stream-io/video-react-native-sdk": "^0.5.13", "@supabase/supabase-js": "^2.32.0", "1.3.0": "^1.3.0", "axios": "^1.4.0", "crypto-js": "^4.2.0", "expo": "^49.0.22", "expo-application": "~5.3.0", "expo-auth-session": "~5.0.2", "expo-av": "~13.4.1", "expo-blur": "~12.4.1", "expo-clipboard": "~4.3.1", "expo-constants": "~14.4.2", "expo-crypto": "~12.4.1", "expo-dev-client": "~2.4.13", "expo-device": "~5.4.0", "expo-font": "~11.4.0", "expo-image-picker": "~14.3.2", "expo-insights": "~0.2.0", "expo-linear-gradient": "~12.3.0", "expo-linking": "~5.0.2", "expo-localization": "~14.3.0", "expo-network": "~5.4.0", "expo-notifications": "~0.20.1", "expo-secure-store": "~12.3.1", "expo-speech": "~11.3.0", "expo-splash-screen": "~0.20.5", "expo-status-bar": "~1.6.0", "expo-store-review": "~6.4.0", "expo-updates": "~0.18.19", "expo-web-browser": "~12.3.2", "firebase": "^9.10.0", "leo-profanity": "^1.7.0", "lottie-react-native": "5.1.6", "moment": "^2.29.4", "native-notify": "^3.0.4", "radio-buttons-react-native": "^1.0.4", "react": "18.2.0", "react-dom": "18.2.0", "react-native": "0.72.10", "react-native-animatable": "^1.3.3", "react-native-animated-loader": "^1.0.0", "react-native-animated-splash-screen": "^2.0.5", "react-native-chat-bubble": "^1.0.0", "react-native-device-info": "^10.6.0", "react-native-dotenv": "^3.4.8", "react-native-dropdown-select-list": "^2.0.4", "react-native-elements": "^3.4.3", "react-native-event-listeners": "^1.0.7", "react-native-gesture-handler": "~2.12.0", "react-native-incall-manager": "^4.2.0", "react-native-linear-gradient": "^2.8.3", "react-native-material-dropdown": "^0.11.1", "react-native-modal-datetime-picker": "^17.1.0", "react-native-paper": "^5.6.0", "react-native-reanimated": "~3.3.0", "react-native-safe-area-context": "4.6.3", "react-native-screens": "~3.22.0", "react-native-size-matters": "^0.4.2", "react-native-splash-screen": "^3.3.0", "react-native-svg": "13.9.0", "react-native-swipe-list-view": "^3.2.9", "react-native-toast-message": "^2.1.6", "react-native-unordered-list": "^1.0.4", "react-native-url-polyfill": "^1.3.0", "react-native-uuid": "^2.0.1", "react-native-vector-icons": "^9.2.0", "react-native-version-check-expo": "^3.4.7", "react-native-web": "~0.19.6", "react-redux": "^8.0.5", "reanimated-color-picker": "^2.4.1", "redux": "^4.2.1", "redux-persist": "^6.0.0", "redux-thunk": "^2.4.2", "styled-components": "^5.3.9", "timeago.js": "^4.0.2", "expo-task-manager": "~11.3.0" }, "devDependencies": { "@babel/core": "^7.21.4", "@babel/plugin-transform-export-namespace-from": "^7.23.4", "@types/styled-components-react-native": "^5.2.1" },
Environment
expo-env-info 1.2.0 environment info: System: OS: Windows 11 10.0.22631 Binaries: Node: 20.11.1 - C:\Program Files\nodejs\node.EXE npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: AI-212.5712.43.2112.8815526 npmPackages: @expo/metro-config: ~0.10.0 => 0.10.7 @expo/webpack-config: ^19.0.0 => 19.0.1 expo: ^49.0.22 => 49.0.23 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 react-native: 0.72.10 => 0.72.10 react-native-web: ~0.19.6 => 0.19.10 Expo Workflow: managed
Reproducible demo
import { useState, useEffect, useRef } from "react"; import { Text, View, Button, Platform } from "react-native"; import as Device from "expo-device"; import as Notifications from "expo-notifications";
Notifications.setNotificationHandler({ handleError: () => { console.log("error"); }, handleSuccess: (notificationId) => { console.log("success", notificationId); }, handleNotification: async () => ({ shouldShowAlert: true, shouldPlaySound: false, shouldSetBadge: false, }), });
export default function NotiTest() { const [expoPushToken, setExpoPushToken] = useState(""); const [notification, setNotification] = useState(false); const notificationListener = useRef(); const responseListener = useRef();
useEffect(() => { registerForPushNotificationsAsync().then((token) => setExpoPushToken(token) );
}, []);
return ( <View style={{ flex: 1, alignItems: "center", justifyContent: "space-around", }}
async function schedulePushNotification() { await Notifications.scheduleNotificationAsync({ content: { title: "You've got mail! 📬", body: "Here is the notification body", data: { data: "goes here" }, }, trigger: { seconds: 2 }, }); }
async function registerForPushNotificationsAsync() { let token;
if (Platform.OS === "android") { await Notifications.setNotificationChannelAsync("default", { name: "default", importance: Notifications.AndroidImportance.MAX, vibrationPattern: [0, 250, 250, 250], lightColor: "#FF231F7C", }); }
if (Device.isDevice) { const { status: existingStatus } = await Notifications.getPermissionsAsync(); let finalStatus = existingStatus; if (existingStatus !== "granted") { const { status } = await Notifications.requestPermissionsAsync(); finalStatus = status; } if (finalStatus !== "granted") { alert("Failed to get push token for push notification!"); return; } // Learn more about projectId: // https://docs.expo.dev/push-notifications/push-notifications-setup/#configure-projectid token = ( await Notifications.getExpoPushTokenAsync({ projectId: process.env.EXPO_PUBLIC_PROJECT_ID, }) ).data; console.log(token); } else { alert("Must use physical device for Push Notifications"); }
return token; }
Stacktrace (if a crash is involved)
No response