【问题标题】:React Native: Best approach to run a background task on iOS when the app is closed?React Native:关闭应用程序时在 iOS 上运行后台任务的最佳方法?
【发布时间】:2019-04-04 12:08:41
【问题描述】:

我需要定期将 HealthKit 数据发送到服务器。我正在使用 React Native 和 rn-apple-healthkit。我试过react-native-background-task,但在应用程序关闭时它不起作用(不是后台模式)。我在 Apple 开发者文档中读到,这是设计使然。

我在网上找到了一些解决方案,例如地理定位服务、运行套接字和“播放”静音、捎带推送通知,但它们似乎都是解决方法。

2019年有什么好的办法吗?

【问题讨论】:

    标签: ios react-native react-native-android react-native-ios background-task


    【解决方案1】:

    使用静默通知是实现此目的的正确方法。但是当手机被锁定时它不会工作:

    For security, the HealthKit store is encrypted when the device is locked, and the HealthKit store can only be accessed by an authorized app. As a result, you may not be able to read data from the store when your app is launched in the background; however, apps can still write data to the store, even when the phone is locked.

    取自https://developer.apple.com/documentation/healthkit/protecting_user_privacy

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-13
    • 1970-01-01
    • 2016-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多