在 iOS 中在后台加载。原生脚本

Loading in Background in iOS. Nativescript

我必须从服务器下载大量数据并在后台继续下载,即使用户隐藏了我的应用程序(示例:当您从 Play Market 安装应用程序时,您可以切换到另一个应用程序并加载继续)在我的 iOS nativescript-angular 应用程序中。我怎样才能做到这一点?我可以使用 Angular 服务吗?

作为对 this.A 的建议,Worker 不同于后台服务。一项工作只是帮助您将负载从 main / UI 线程转移到另一个线程。但是当你想要在后台获取位置和上传数据时,你需要一个后台服务,即使你的应用程序被最小化/终止。

nativescript-geolocation plugin itself has an example for fetching location in background,您可以使用类似的方法将数据上传到服务器,而不是像示例中那样在 toast 中显示。

对于 iOS,您应该使用地理位置插件并使用 Background Fetch 在后台订阅更新。而不是 UIBackgroundModes 作为 fetch 你应该使用 location.