简体   繁体   English

iOS7 UIBackgroundModes从后台模式通过启动应用程序获取

[英]iOS7 UIBackgroundModes Fetch with launch app from background mode

I am trying to download some files in the background with new iOS 7 feature UIBackgroundModes Fetch and file is downloading successfully in background 我正在尝试使用新的iOS 7功能UIBackgroundModes Fetch在后台下载一些文件,并且文件在后台成功下载

But I want when my download completes in the background ,App should come in the Foreground I have also called the method setMinimumBackgroundFetchInterval in didFinishLaunchingWithOptions. 但是我想当when my download completes in the background ,App should come in the Foreground我在didFinishLaunchingWithOptions中也调用了setMinimumBackgroundFetchInterval方法。 But application:performFetchWithCompletionHandler method is not getting called in from background as well as foreground after download completes. 但是下载完成后, application:performFetchWithCompletionHandler方法不会从后台以及前台调用。

Is it possible to launch app in foreground after download completes? 下载完成后是否可以在前台启动应用程序?

You can fire Local Notification for this purpose. 您可以为此目的触发本地通知。 Schedule local notification once your download completes. 下载完成后安排本地通知。 Once download finishes, App will fire notification, User selects the notification & after clicking it, the application will open up. 下载完成后,应用程序将触发通知,用户选择通知,然后单击它,应用程序将打开。

Here are some good tutorials for adding local notification: 这是一些用于添加本地通知的好教程:

Local notification Sample 1 本地通知样本1

Local notification sample 2 本地通知样本2

Short answer, nope. 简短的回答,不。

The only thing an app is supposed to do when called for a background fetch is perform any data fetching that the app needs. 当要求进行后台提取时,应用唯一要做的就是执行应用所需的任何数据提取。 Then the completion handler is supposed to specify whether there was an error, new data, or no change. 然后,应该由完成处理程序指定是否有错误,新数据或没有更改。 If there was new data, the app screenshot in the app switcher is updated. 如果有新数据,则会更新应用程序切换器中的应用程序屏幕截图。 That's the extent of background fetching, hence the name. 那就是背景获取的程度,因此得名。

There is no way to bring your app to the foreground. 无法将您的应用程序置于前台。 The only way to have an app come to the foreground in iOS is through a user action. 在iOS中让应用程序成为前台的唯一方法是通过用户操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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