简体   繁体   中英

How to add native code to React Native (Expo)

I want to bring my expo app to the foreground from a background running task, the only third-party package I found on the internet that can do this is react-native-invoke-app but it does not work with expo managed apps.

There are three ways I think I can do this but I do not know how to implement any of them:

  1. How can I make this package compatible with expo by utilizing expo config plugin ?

  2. How can I copy their native java code that involves bringing the app to the foreground into my expo app? and perhaps build a custom dev clients

  3. Is there any other method that I can use to bring an expo app to the foreground from a background running task? please see my other question on this matter

I will appreciate any form of assistance

What's your use-case? A bit part of the answer depends on what you're trying to do.

It looks like the react-native-invoke-app package works through push notifications, so I would try making use of push notifications. For example, you could schedule repeating notifications with this package: https://github.com/expo/expo/tree/main/packages/expo-notifications

Or set up Firebase to send the push notifications based on some server logic, cloud functions, or API requests (which you could trigger with react-native-background-fetch).

You could also make use of a deep link, but it depends on your use case.

As far as I know, there's no way to force an app into the foreground without a push notification or a deep link.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM