I am using React Native Expo and here is a simple code:
import React from 'react';
import * as Notifications from 'expo-notifications';
function Testing(props) {
const sendNotification = () => {
setTimeout(() => {
const content = { title: "Hello World!" };
Notifications.scheduleNotificationAsync({ content, trigger: null });
}, 5000);
}
return (<Button title="Send Notification" onPress={() => sendNotification()}/>);
}
export default Testing;
I have not included Requesting permission code but it works.
When testing this on an IOS Simulator, I successfully get the notification after clicking the button and getting out of the app. But when testing on Real Device, it works when I am in the App Switcher Screen but does not work when App is in background.
Is there any additional thing to make it work on Real Device?
question from:
https://stackoverflow.com/questions/65838743/react-native-app-continues-to-work-in-background-in-simulator-but-not-on-real-de 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…