expo: Notifications.addNotificationResponseReceivedListener doesn't trigger if app is killed (Android Only)
I have this issue in a Bare workflow and only happens in Android (if app is killed) after expo-in-app-purchases is installed (IOS Works fine)
Steps to reproduce:
expo init --template bare-minimum
expo install expo-notifications
— After this everything working fine in both platforms —
npm install expo-in-app-purchases
Notifications.addNotificationResponseReceivedListener doesn’t work anymore in Android when app is killed.
App.js
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View, Linking } from 'react-native';
import * as Notifications from 'expo-notifications';
import Constants from 'expo-constants';
export default function Container({ navigation }) {
React.useEffect(() => {
registerForPushNotificationsAsync()
const subscription = Notifications.addNotificationResponseReceivedListener(response => {
console.log("User entered from notification.")
});
return () => subscription.remove();
}, [navigation]);
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<StatusBar style="auto" />
</View>
);
}
async function registerForPushNotificationsAsync(userId: string) {
let experienceId = undefined;
if (!Constants.manifest) {
// Absence of the manifest means we're in bare workflow
experienceId = '@user/project';
}
const expoPushToken = await Notifications.getExpoPushTokenAsync({
experienceId,
});
console.log("TOKENNNN")
console.log(expoPushToken)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
expo diagnostics
Expo CLI 3.25.0 environment info:
System:
OS: macOS 10.15.6
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.8.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.7 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6514223
Xcode: 11.6/11E708 - /usr/bin/xcodebuild
npmPackages:
expo: ~38.0.9 => 38.0.9
react: ~16.11.0 => 16.11.0
react-dom: ~16.11.0 => 16.11.0
react-native: ~0.62.2 => 0.62.2
react-native-web: ~0.11.7 => 0.11.7
npmGlobalPackages:
expo-cli: 3.25.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (7 by maintainers)
I’ve upgraded to SDK39 but the issue still persists.