Hook for receiving background URLSession events queued for app relaunch or by app extensions

未关闭
#327 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@michalkcloudinay 已经在做这个了。

开始于 2021年2月22日。

评估

这个 Issue 还没有评估数据。

描述

enhancement

Feature request for Cloudinary iOS SDK

Explain your use case

We have business logic to run in response to a upload task completion (success or failure), e.g., database write, backend API calls, file cleanup, etc. Most importantly, this has to be done for all uploads, regardless of whether it is started by the current application process or not.

This includes, e.g., an upload started by an earlier app invocation gracefully killed by the system, or an upload started by a Share Extension that dismisses the UI eagarly in anticipation of the app being woken up for the background transfer completion (e.g. this Apple Dev forum thread).

Describe the problem you’re trying to solve

The current Cloudinary SDK does not surface any hook for us to get notified about these events sent by sessionSendsLaunchEvents = true. This blocks us from implementing functional background uploads, especially for a Share Extension.

Having said that, it looks the SDK is already well-equipped to support processing and serving these events to the API. More specifically, it:

  • does not use the block/closure callback versions of the Upload/Download tasks; and
    (so delegate callbacks won't get suppressed)

  • already handles the completion handler for clients that have to handle URLSession events in their UIApplicationDelegate. (e.g., when the SDK user implemented it for other URLSessions)

Do you have a proposed solution?

In conjunction to setBackgroundCompletionHandler(_:), the Cloudinary SDK should provide an root-level API to register a callback for all task completions in the SDK instance. This will be backed by URLSession:task:didCompleteWithError: for certain.

The callback needs not provide a full CLDUploadRequest or CLDFetchImageRequest object* — the expectation is a minimal set of basic metadata, like unique file ID and resource type. These should sufficiently allow us to look up the associated operation log in our database, and resume the post-upload or post-download work as necessary.

[*] technically, this could be tough to implement anyway for little to no value. URLSession tasks received via the didCompleteWithError delegate message can be a task resurrected only for the message, and so have no associated CLD*Request in the current process.

主要语言
Swift
星标
169
派生
107
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cloudinary/cloudinary_ios 的其他 Issue

查看 cloudinary/cloudinary_ios 的全部 Issue

相似的 Issue

更多 Swift Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。