2
私はドロップボックスsdkを使用してdropboxから大きなファイルをダウンロードしているアプリケーションを作成しています。ダウンロード機能の仕組みは、downloadFileメソッドを呼び出して、デリゲートを渡します。ここで、ファイルのダウンロードが開始され、ファイルが完全にダウンロードされた後にコールバックします。アプリケーションが終了した場合のバックグラウンドでのタスクの実行
ただし、ファイルがダウンロードされているときにアプリケーションを閉じると、ユーザーがアプリに戻るまでファイルのダウンロードが一時停止します。
私は次のコードを使用しようとしましたが、アプリを閉じると、アプリに戻るまでダウンロードが完了しません。
UIApplication* app = [UIApplication sharedApplication];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//This call calls the sdk to start downloading the file. That method will then
// call this classes delegate methods with the progress of the download as well
// as when the file is totally finished downloading
[DBUtils downloadFile:fileVO.filename withHash:fileVO.filehash withRestClient:self.restClient];
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
});
どのように私はこの問題を解決できますか?
あなたは正確です!それはうまくいった!本当にありがとう!! –