Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我曾经URLSessions进行网络调用,当我将应用程序置于后台状态时它总是失败。当我将应用程序置于前台状态时,URLSession将URLResponse作为nil.
URLSessions
URLSession
URLResponse
nil
我怎样才能让它在后台状态下工作?
如果您为后台下载或上传配置会话,则可以让 URLSession 在后台状态下工作。但是如果你使用 session 进行常规的后端 API 调用,你可以做的最好是在应用程序再次进入前台后重复调用。