标签: background-fetch

如何在iOS应用程序处于前台时在后台运行操作

我在Documents Directory中填充了字符串数据的JSON文件.在应用程序的用户界面中有一个UIButton.按下按钮,新的字符串将附加到JSON文件中.

现在我正在寻找任何帮助我使用swift将这些字符串(从JSON文件)发送到服务器的iOS服务.这项服务应完全独立于我的代码.关键是当我按下UIButton时,第一步是将字符串保存到JSON文件,然后服务应该使用此字符串并在Internet可用时将其发送到服务器.

成功发送字符串后,应将其从JSON文件中删除.如果有任何字符串保存到JSON文件中,则此服务应每30秒跟踪一次,然后将其发送到服务器.

我用Google搜索并找到后台获取,但它会performFetchWithCompletionHandler自动触发功能,我无法知道iOS何时触发它.我想每30秒就触发一次这种服务.

synchronization ios swift background-fetch

11
推荐指数
1
解决办法
6136
查看次数

突然间会出现很多Fabric Out of Memory会话:Fabric OOM报告是否会出现误报?

我最近在我的应用程序中添加了后台提取,它运行良好.我最近在Fabric中发现OOM免费会话的数量已逐渐从100%变为每日平均稳定,在十几岁时低至14%.我只看到这里和那里报告了一些崩溃,并且没有其他用户报告崩溃的证据.

在阅读了如何检测OOM会话之后,似乎可能是虚假报告.用户启动应用程序,稍后进入后台状态.然后,应用程序启动后台获取,执行提取,并终止 - 这种情况发生在操作系统允许的频率.

由于重复的背景提取启动和终止发生的方式,Fabric的OOM检测器是否可能错误地检测到OOM?

ios background-fetch google-fabric

10
推荐指数
1
解决办法
2144
查看次数

iOS11 swift静态推送(后台提取,didReceiveRemoteNotification)不再起作用了

我希望iOS11版本能解决无声推送问题,这是最新的测试版和通用版iOS版.

目前我很难理解,为什么我没有收到任何静音推送消息,这实际上应该唤醒我的应用程序以在后台执行一些所需的任务.

在iOS 10中,我只使用后台获取功能,并在我的AppDelegate中实现了"唤醒代码",如下面的代码所示.

在iOS 11中,注册代码仍然正常工作,我的后端也向Apples DEV服务器(沙箱)和PROD服务器(生产版本)提供推送通知.不幸的func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)是,静音推送通知从不调用该函数.

我真的错过了iOS 11的东西吗?


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  // .. some variables here ...

   func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

       // register silent push notification in backend
       application.registerForRemoteNotifications()

       // ... some code here ... 


       // Set Background Fetch Intervall for background services / terminated app
       UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)

       // ... some code here ... …
Run Code Online (Sandbox Code Playgroud)

swift background-fetch silentpush ios10 ios11

8
推荐指数
1
解决办法
5065
查看次数

iOS后台获取自定义间隔

我阅读了有关后台提取的所有Apple文档,目前我正在使用它:

[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:minimumBackgroundFetchInterval];
Run Code Online (Sandbox Code Playgroud)

我让操作系统决定何时执行后台提取,但如果我这样设置:

[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:21600];
Run Code Online (Sandbox Code Playgroud)

这是否意味着每隔6小时就会进行一次获取?

objective-c ios background-fetch

7
推荐指数
3
解决办法
8642
查看次数

iOS 中后台获取的执行频率是多少?

在 iOS 7 中,当应用程序不在最前面时,应用程序支持后台获取模式来获取数据:

在方便时,系统会在后台启动或恢复应用程序,并为其提供少量时间来下载任何新内容。

我的问题是:后台提取代码多久执行一次?

如果我设置最小间隔:

[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:10];
Run Code Online (Sandbox Code Playgroud)

它是每 10 秒执行一次,还是每天执行一次?一般来说,我应该期待什么样的间隔?

multitasking ios ios7 background-fetch

7
推荐指数
1
解决办法
3576
查看次数

后台任务和后台正确获取有什么区别?

我正在网上查看一些关于后台任务和后台获取的文档。

后台任务是在应用程序仍在运行时在后台执行的任务。当应用程序在后台时,任务完成任务的时间有限,一旦完全后台,任务也必须结束。

后台获取是应用程序完全处于后台或不活动的地方,如果资源可用,该操作将被安排在某个时间点执行。

这是我非常简短的理解。

ios xamarin background-task background-fetch

7
推荐指数
1
解决办法
3289
查看次数

如果应用程序已终止,将调用performFetchWithCompletionHandler

很难找到明确的答案; 在Apple文档中找不到它,在搜索过去的问题后找不到肯定的是/否.

问题很简单 - 如果应用程序请求在N次之后执行后台提取,则用户终止应用程序.操作系统是否仍会将应用程序启动到后台以执行后台获取?

ios background-fetch

7
推荐指数
1
解决办法
2117
查看次数

iOS:后台服务器调用经常导致超时

我的应用程序在启动时会进行一些服务器调用,现在我面临一个奇怪的问题:当推送通知content_available唤醒我的应用程序时也会调用,但更多时候它们会遇到超时.

这是否与应用程序在后台有关?配置错误了吗?我激活背景模式background fetch以及remote notifications.我错过了什么吗?

push-notification ios background-fetch ios11

7
推荐指数
1
解决办法
237
查看次数

expo.io的BackgroundFetch没有运行定义的任务

我目前正在使用expd sdk-version 32开发适用于iOS的应用程序。我必须定期从我的应用程序调用REST服务。为此,我尝试利用新的BackgroundFetch API。

这是我的代码:

const BACKGROUND_LOCATION_SENDING_TASK = "BACKGROUND_LOCATION_SENDING_TASK";

async function initBackgroundLocationSending() {
    console.log("initBackgroundLocationSending()");

    TaskManager.defineTask(BACKGROUND_LOCATION_SENDING_TASK, () => {

        // this console.log does never get called ... 
        console.log("BACKGROUND_LOCATION_SENDING_TASK");

        // i will implement real fetch logic here when i found out how to get this function called.
        return BackgroundFetch.Result.NewData;
    });

    console.log("is task registered ... ");
    let isRegistered = await TaskManager.isTaskRegisteredAsync(BACKGROUND_LOCATION_SENDING_TASK);
    console.log("isRegistered: ", isRegistered);

    if(isRegistered) {
        console.log("unregister task ...");
        await BackgroundFetch.unregisterTaskAsync(BACKGROUND_LOCATION_SENDING_TASK);
        console.log("Done");
    }

    console.log("is task registered ... ");
    isRegistered = await …
Run Code Online (Sandbox Code Playgroud)

ios background-fetch react-native expo

7
推荐指数
1
解决办法
1029
查看次数

Android 上后台获取 Flutter 访问数据库

我试图在应用程序完全关闭时访问设备上的本地数据库,为此我使用 sqlite 插件sqflite: ^1.2.0和后台获取插件background_fetch: ^0.4.0

\n\n

我能够毫无问题地注册无头后台任务,当我尝试运行后台任务时,出现以下错误!

\n\n

当应用程序运行或进入后台模式时,插件似乎可以正常工作。

\n\n

请问有什么建议吗?

\n\n

错误

\n\n
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite)\n
Run Code Online (Sandbox Code Playgroud)\n\n

颤动版本:

\n\n
Flutter 1.12.13+hotfix.7 \xe2\x80\xa2 channel stable \xe2\x80\xa2 https://github.com/flutter/flutter.git\nFramework \xe2\x80\xa2 revision 9f5ff2306b (11 days ago) \xe2\x80\xa2 2020-01-26 22:38:26 -0800\nEngine \xe2\x80\xa2 revision a67792536c\nTools \xe2\x80\xa2 Dart 2.7.0\n
Run Code Online (Sandbox Code Playgroud)\n\n

颤振医生

\n\n
[\xe2\x9c\x93] Flutter (Channel stable, v1.12.13+hotfix.7, on Mac OS X 10.15.2 19C57, locale en-GB)\n\n[\xe2\x9c\x93] Android toolchain - develop for Android devices (Android …
Run Code Online (Sandbox Code Playgroud)

sqlite dart background-fetch flutter

7
推荐指数
1
解决办法
6592
查看次数