![](/img/trans.png)
[英]Swift -How to get certain silent notifications in the background and others in the foreground?
[英]Swift : How to run a GET call in background and then show notifications
我正在制作一個顯示網站/博客數據的應用程序。 用戶可以關注任何作者。 要求是,當應用程序進入后台時1)首先應運行對數據的GET調用2)分析數據后,應顯示正確的通知
我已經閱讀了有關Background Fetch
詳細信息。 但它指出,操作系統將自行設置運行該代碼的時間。 Ive檢查了該應用程序,它僅在3天內顯示了一次通知。
誰能告訴我如何正確進行后台獲取並相應地顯示通知。 任何好的文章鏈接也將不勝感激。
您沒看錯,在iOS中,您不能無限期地在后台運行,相反,iOS將監視您的應用程序的使用模式,並在滿足某些條件(例如電池,時間等)的情況下啟動您的應用程序。
您可以查看此鏈接以了解有關后台執行的更多信息, https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
對於實現,請查看以下文章,它真的很有用
https://www.raywenderlich.com/92428/background-modes-ios-swift-tutorial
https://www.appcoda.com/ios7-background-fetch-programming/
https://blog.newrelic.com/2016/01/13/ios9-background-execution/
希望能幫助到你!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.