Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

ios - React Native App continues to work in background in Simulator but not on Real Device

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...