leoho0722
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
###### tags: `第13屆IT邦鐵人賽文章` # 【在 iOS 開發路上的大小事-Day29】淺談 iOS 的 Background Modes 先前在研究如何讓 App 在背景多存活久一點 有稍微去了解了一下 iOS 的 Background Mode 是如何運作的 下面就來分享一下 iOS 的 Background Mode # App 在系統的運作流程 ![](https://i.imgur.com/svNuJX3.png) # Background Mode 有哪些 上面簡單介紹了一個 App 在系統裡面是如何運作的 下面要來介紹到底有哪些 Background Mode可以選擇 * Audio, AirPlay, and Picture in Picture * Location updates * Voice over IP * External accessory communication * Uses Bluetooth LE accessories * Acts as a Bluetooth LE accessory * Background fetch * Remote notifications * Background processing ## Audio, AirPlay, and Picture in Picture **Audio**:顧名思義就是聲音、音樂播放,或是麥克風使用,當 App 從前景退到背景時,只要有開啟這個選項,就可以常駐在背景播放,不會被系統關閉 **AirPlay**:像是將 iOS/iPadOS/macOS 的畫面投影到其他裝置上的功能,就是屬於這個 **Picture in Picture**:這功能是子母畫面,也有人稱作畫中畫,他是讓你可以在使用 A 應用,同時也可以讓 B 應用在背景透過一個小視窗在畫面上播放著影片,像是最近 YouTube Premium 會員可以測試的子母畫面就是屬於這個的應用。一開始這功能是 for iPad 使用的,不過從 iOS 14 開始,也可以在 iOS 上使用了 ## Location updates **Location updates**:顧名思義就是位置更新,當開啟這個選項後, App 進到背景後也會持續透過抓取定位來更新當前所在位置,像是 Google Maps、Apple Maps 在導航時,無論是在前景或是背景都可以根據你當前所在處進行判斷該如何導航 ## Voice over IP **Voice over IP**:這功能是類似透過網路來打電話,像是常見的 Line、Skype 等都屬此類應用,原理大致上是這樣的,系統一樣還是會將此應用在進到背景的時候強制停止,但在停止的時候,會由系統來接手管理 Socket,當有資料的時候,系統會將此應用再次啟動,並且將先前系統接管的 Socket 再交回給應用,整個流程大致如下 (有錯還請告知,感謝!) ![](https://i.imgur.com/fgO9pZU.png) ## External accessory communication **External accessory communication**:這個選項是提供給一些 MFI 裝置透過藍牙、Lightning 等方式與 iOS 設備連接,進而可以在 MFI 裝置對系統發送通知時,將已經被系統強制停止的應用啟動 ## Uses Bluetooth LE accessories **Uses Bluetooth LE accessories**:這個選項跟 External accessory communication 類似,只是不需要是 MFI 裝置,而是需要 Bluetooth LE 設備 ## Acts as a Bluetooth LE accessory **Acts as a Bluetooth LE accessory**:這個選項是當有一個藍牙裝置與 iOS/iPadOS 裝置連接時,對應的應用可以背景執行,但是使用此模式需要使用者進行授權認證 ## Background fetch **Background fetch**:適用於即使在背景,也需要頻繁更新資料的 App,過程最多只能執行 30 秒 ## Remote notifications **Remote notifications**:這個是遠端推播,與本地推播不同,這是需要付費開發者才能使用的,當系統收到伺服器的推播後,系統會去通知 App 並將 App 喚醒來接收推播 ## Background processing **Background processing**:這個是在 Xcode 11 新增的一種 Background Mode,主要是用來在背景處理一些事情的,但資料感覺有點少,下面是引述 [Apple Developer](https://developer.apple.com/documentation/backgroundtasks) 的說明 >Use the BackgroundTasks framework to keep your app content up to date and run tasks requiring minutes to complete while your app is in the background. Longer tasks can optionally require a powered device and network connectivity. > >Register launch handlers for tasks when the app launches and schedule them as required. The system will launch your app in the background and execute the tasks. # 總結 上面簡單介紹了各種 Background Mode,希望可以找到適合你的模式 但如果你想要的模式沒有在上面,卻又想要掛羊皮賣狗肉的話,那就要小心了 因為有極高機率會在上架的時候,被 Apple 擋下來,畢竟現在 Apple 越來越重視使用者隱私了~ # 參考資料 1. [ios background modes (簡書)](https://www.jianshu.com/p/d92ecfa01012) 2. [What is the Xcode "Background Processing" Background Mode? (stack overflow)](https://stackoverflow.com/questions/57197958/what-is-the-xcode-background-processing-background-mode) 3. [Background Tasks (Apple Developer Documentation)](https://developer.apple.com/documentation/backgroundtasks) 4. [Swift小記:iOS後台保活方法 (簡書)](https://www.jianshu.com/p/988d9b664000)

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully