- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
即使应用程序在后台,我的应用程序也希望每 5 秒更新一次有关用户位置的服务器。我为它实现了后台获取。
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil))
application.setMinimumBackgroundFetchInterval(5.0)
return true
}
func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
completionHandler(UIBackgroundFetchResult.NewData)
UpdateData()
}
func UpdateData(){
print("UpdateData executes")
// function to update data when ever this method triggers
}
但问题是
最佳答案
你对什么是background fetch有误解。开发人员无权决定何时准确执行后台提取。 iOS 本身决定何时允许应用程序执行后台获取。
setMinimumBackgroundFetchInterval
函数仅允许您指定必须在后台提取之间传递的最小 时间间隔,以最大限度地减少应用的能源和数据使用。但是,您在此处设置的间隔根本不能保证您的应用程序能够如此频繁地执行后台提取。 documentation中的关键句关于此的是“在后台机会性地获取内容...”。
目前,确保您的应用程序可以在后台执行某些功能(包括从服务器获取数据)的唯一方法是定期从您自己的服务器发送静默推送通知。但是,即便如此,如果您的应用需要很长时间才能完成执行以响应推送,或者如果您的应用收到太多通知,系统可能会决定不唤醒您的应用以响应静默推送通知。
关于ios - 后台获取 performFetchWithCompletionHandler 不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50375733/
引用 iOS 7 的后台获取功能。 我想知道以下内容如何影响 performFetchWithCompletionHandler叫做: 用户行为 应用程序使用 应用使用频率 (iOS 如何确定您经常使
如果设备未连接到互联网,UIApplicationDelegate 是否会调用 performFetchWithCompletionHandler?在这种情况下,文档并不清楚。 最佳答案 经过一些测试
这是我的应用委托(delegate) (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NS
1)我的plist配置提供backgroundmode: UIBackgroundModes fetch 2) 在 didFinishLaunchingWithOptions 我有: [[
我有一个 iPad 应用程序,它使用完整数据保护来加密应用程序的内容,除非设备已解锁并运行。这是客户要求的,并且按预期工作。 第二个业务需求是我们在后台运行一些 Web 服务调用。这是使用新的 app
即使应用程序在后台,我的应用程序也希望每 5 秒更新一次有关用户位置的服务器。我为它实现了后台获取。 func application(application: UIApplication, didF
我正在尝试在 中添加日历事件 -(void)application:(UIApplication *)application performFetchWithCompletionHandler:(vo
要找到一个明确的答案是非常困难的;在 Apple 文档中找不到它,并且在搜索过去的问题后找不到明确的是/否。 问题很简单 - 如果应用程序请求在 N 次后执行后台提取,则用户终止该应用程序。操作系统是
在 performFetchWithCompletionHandler 中,所有的 http 请求是否必须在主 ui 线程或后台线程中完成? 最佳答案 您应该在后台线程中执行 HTTP 请求。如果您收
我想在某个时间间隔内执行一些操作。但是当应用程序处于后台或非事件状态时,这不应该发生。我已经按如下方式实现了这一点 func application(_ application: UIApplicat
我知道 performFetchWithCompletionHandler 旨在用于通过网络在后台获取数据,但我可以用它来获取不需要网络连接的数据吗?例如,我想使用 M7 运动协处理器从 CoreMo
我有点困惑 performFetchWithcompletionHandler参与 iOS 应用程序生命周期。在文档中提到它给了我们 30 秒的时间来下载任何数据,但我们的应用程序会在那时卡住 30
我有一个应用可以成功获取并显示我想添加后台获取的 RSS 源。我收到:线程 1 EXC_BAD_ACCESS(代码=1,地址=0x10),如下所示。 在应用委托(delegate)中: - (BOOL
在 Xcode 7.0.1 中,“模拟背景”获取命令导致 performFetchWithCompletionHandler 被触发两次。 这是 Xcode 调试错误吗,或者这可能发生在运行应用程序发
我为后台获取实现了 performFetchWithCompletionHandler。我有本地通知设置,可以在数据发生变化时触发。出于测试目的,即使数据没有变化,我也会触发通知,这样我就知道一切正常
如何在 Swift 中为后台提取调用完成处理程序。我执行以下操作: func application(application: UIApplication, performFetchWithC
我有一个应用程序可以借助 Background Fetch 在后台获取内容。 因此,如果发生后台提取,我的 application:performFetchWithCompletionHandler:
我实现了 performFetchWithCompletionHandler(即:background fetch)从服务器下载一些数据。 为此,在 performFetchWithCompletio
我在下面的模拟器中调用这个函数来模拟后台获取。 然后我在日志中收到这个警告: Swift Warning: Application delegate received call to -applica
我是一名优秀的程序员,十分优秀!