ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [iOS] Responding to the Launch of Your App (๊ณต์‹๋ฌธ์„œ ์ •๋ฆฌ)
    iOS/๐Ÿค– App 2021. 1. 28. 12:05

    1์ฐจ ์ˆ˜์ •: 2021/06/16

     

    ์•ˆ๋…•ํ•˜์„ธ์š”๐Ÿถ

    ์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” 'Responding to the Launch of Your App',

    ์ฆ‰ ์•ฑ ์‹œ์ž‘์‹œ ๋ฐœ์ƒํ•˜๋Š” ์ผ๋“ค์— ๋Œ€์‘ํ•˜๋Š” ๋‚ด์šฉ์„ ๋‹ด์€ ๊ณต์‹๋ฌธ์„œ๋ฅผ ์ •๋ฆฌํ•ด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

    ์ด์ „ ๊ธ€์„ ๋จผ์ € ์ฝ๊ณ  ๋ณด์‹œ๋Š” ๊ฒƒ๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”๐Ÿ˜‰

     

    "์•ฑ์˜ ์ž๋ฃŒ ๊ตฌ์กฐ๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜๊ณ , ์•ฑ์„ ์‹คํ–‰์‹œํ‚ค๊ธฐ์œ„ํ•ด ์ค€๋น„ํ•˜๊ณ , launch-time ์— ์˜ค๋Š” ์‹œ์Šคํ…œ ์š”์ฒญ๋“ค์— ๋Œ€์‘ํ•ฉ๋‹ˆ๋‹ค."


     

     

    ๊ฐ„๋žตํ•œ ๊ฐœ์š”

    ์‚ฌ์šฉ์ž๊ฐ€ ํ™ˆ ํ™”๋ฉด์˜ ์•ฑ ์•„์ด์ฝ˜์„ ํƒญํ•  ๋•Œ, ์‹œ์Šคํ…œ์€ ์šฐ๋ฆฌ์˜ ์•ฑ์„ ์‹œ์ž‘์‹œํ‚ต๋‹ˆ๋‹ค.

     

    ๋งŒ์•ฝ ์•ฑ์ด ํŠน์ •ํ•œ ์ด๋ฒคํŠธ๋ฅผ ์š”์ฒญํ–ˆ๋‹ค๋ฉด, ์‹œ์Šคํ…œ์€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๊ทธ ์ด๋ฒคํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด `background`์—์„œ ์•ฑ์„ ์‹œ์ž‘์‹œํ‚ต๋‹ˆ๋‹ค.

    :: Scene-based ์•ฑ์—์„œ, ์‹œ์Šคํ…œ์€ ์œ„์™€ ๋น„์Šทํ•˜๊ฒŒ ์•ฑ์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.

    :: ํ™”๋ฉด ์ƒ์— ๋‚˜ํƒ€๋‚  ํ•„์š”๊ฐ€ ์žˆ๊ฑฐ๋‚˜, ์–ด๋–ค ์ž‘์—…์„ ํ•ด์•ผํ•  ๋•Œ ๊ทธ๋ ‡๊ฒŒ ๋™์ž‘ ํ•ฉ๋‹ˆ๋‹ค.

     

    ๋ชจ๋“  ์•ฑ์€ Launch ์™€ ๊ด€๋ จ๋œ ์ฒ˜๋ฆฌ๊ณผ์ •์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

    :: ์ด ์ฒ˜๋ฆฌ๊ณผ์ •์„ Launch-cycle ์ด๋ผ๊ณ  ๋ถ€๋ฅด๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค.

     

    ์ด ์ฒ˜๋ฆฌ๊ณผ์ •์€  UIApplication ์˜ค๋ธŒ์ ํŠธ๊ฐ€ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

     

    ์•ฑ๋“ค์€ ๋˜ํ•œ AppDelegate ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

    ::UIApplicationDelegate ํ”„๋กœํ† ์ฝœ์„ ์ฑ„ํƒํ•œ ์˜ค๋ธŒ์ ํŠธ ์ž…๋‹ˆ๋‹ค

     

    ๊ธฐ๋ณธ์ ์œผ๋กœ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค. iOS13 ์ดํ›„ ๋ถ€ํ„ฐ๋Š” SceneDelegate ๋„ ๊ฐ™์ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.

     

    App delegate ๋Š” ์ฒ˜๋ฆฌ๊ณผ์ •์—์„œ ์ค‘์š”ํ•œ ์ด๋ฒคํŠธ๊ฐ€ ๋ฐœ์ƒํ–ˆ์„๋•Œ ๋Œ€์‘ํ•ฉ๋‹ˆ๋‹ค.

    :: Scene-based ์•ฑ๋„ ๊ธฐ๋ณธ์ ์ธ ์ด๋ฒคํŠธ์ธ `launch`, `termination`๊ณผ ๊ฐ™์€ ์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ์— App delegate ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

     

    ์•ฑ ์‹œ์ž‘ ์‹œ์ ์—, UIKit ์€ ์ž๋™์ ์œผ๋กœ UIApplication ๊ณผ App delegate ์˜ค๋ธŒ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

     

    ๊ทธ๋ฆฌ๊ณ  UIKit์€ ๊ณง๋ฐ”๋กœ ์•ฑ์˜ main event loop๋ฅผ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.

    :: ์ •ํ™•ํžˆ๋Š” UIApplicationMain(_:_:_:_:)  ํ•จ์ˆ˜์—์„œ ๋ฉ”์ธ ์ด๋ฒคํŠธ ๋ฃจํ”„๋ฅผ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค.

     

    iOS ์•ฑ์€ ๊ธฐ๋ณธ์ ์œผ๋กœ ์‚ฌ์šฉ์ž๊ฐ€ ๋ฐœ์ƒ์‹œํ‚จ ์ด๋ฒคํŠธ์— ์˜ํ•ด

    ์‹คํ–‰ํ๋ฆ„์ด ๊ฒฐ์ •๋˜๋Š” Events-Driven Architecture ์ด๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.


     

    ๋Ÿฐ์น˜์Šคํฌ๋ฆฐ ์Šคํ† ๋ฆฌ๋ณด๋“œ (Lauch StoryBoard)

    ์ด ํ™”๋ฉด์€ ํ”Œ๋žซํผ๊ณผ ๊ด€๋ จ ์—†์ด 'splash screen' ์ด๋ผ๋Š” ์šฉ์–ด๋กœ๋„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

     

    ์‚ฌ์šฉ์ž๊ฐ€ ์•ฑ์„ ๊ธฐ๊ธฐ์—์„œ ์ฒ˜์Œ ์‹คํ–‰ํ•  ๋•Œ, ์‹œ์Šคํ…œ์€ ์šฐ๋ฆฌ์˜ ์•ฑ์ด UI๋ฅผ ํ™”๋ฉด์˜ ๋„์šธ ์ค€๋น„๋ฅผ ํ•˜๋Š”๋™์•ˆ `launch storyboard` ๋ฅผ ํ™”๋ฉด์— ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

     

    `Launch storyboard` ๋ฅผ ํ™”๋ฉด์— ํ‘œ์‹œํ•˜๋Š”๊ฒƒ์€

    ์‚ฌ์šฉ์ž์—๊ฒŒ "์•ฑ์ด ์‹คํ–‰๋˜์—ˆ๊ณ , ๋ฌด์–ธ๊ฐ€๋ฅผ ์ž‘์—…ํ•˜๊ณ ์žˆ๋‹ค." ๋ผ๋Š” ์ ์„ ํ™•์ธ์‹œ์ผœ ์ฃผ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

     

    ์•ฑ์ด ๋งŒ์•ฝ ์Šค์Šค๋กœ ์ดˆ๊ธฐํ™” ํ•˜๊ณ  UI ๋ฅผ ๋น ๋ฅด๊ฒŒ ์ค€๋น„ํ•œ๋‹ค๋ฉด, ์‚ฌ์šฉ์ž๋Š” `launch storyboard` ๋ฅผ ๋ณด๋Š” ์‹œ๊ฐ„์ด ์งง์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

     

    Xcode ํ”„๋กœ์ ํŠธ๋Š” ์ž๋™์œผ๋กœ ๊ธฐ๋ณธ `launch storyboard` ๋ฅผ ์ œ๊ณตํ•˜์—ฌ์„œ, ์ปค์Šคํ„ฐ๋งˆ์ด์ง•ํ• ์ˆ˜ ์žˆ๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

     

    ํ˜น์€ ์šฐ๋ฆฌ๊ฐ€ ํ•„์š”ํ•  ๋•Œ ์ถ”๊ฐ€์ ์œผ๋กœ `launch storyboard` ๋ฅผ ๋งŒ๋“ค์ˆ˜ ์žˆ๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

     

    Default LaunchScreen

    ์ƒˆ๋กœ์šด `launch storyboard` ๋ฅผ ํ”„๋กœ์ ํŠธ์— ์ถ”๊ฐ€ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š”, ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ˆœ์„œ์— ๋”ฐ๋ผ ์ž‘์—…ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค:

    ๊ฐ„๋‹จํ•œ ์˜์–ด์ด๋ฏ€๋กœ ๋”ฐ๋กœ ํ•ด์„ํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.

    1. Open your project in Xcode.
    2. Choose File > New > File.
    3. Add a Launch Screen resource to your project.

    `Launch storyboard` ์— view ๋“ค์„ ์ถ”๊ฐ€ํ•˜๊ณ  Auto Layout ์ œ์•ฝ์„ ์ด์šฉํ•ด ์œ„์น˜์™€ ํฌ๊ธฐ๋ฅผ ์„ค์ •ํ•จ์œผ๋กœ์„œ, ์•ฑ์ด ์‚ฌ์šฉํ™˜๊ฒฝ (๊ธฐ๊ธฐ) ์— ๋งž๊ฒŒ ๋Ÿฐ์น˜์Šคํฌ๋ฆฐ์˜ ๋‚ด์šฉ์„ ๋ณด์—ฌ์ฃผ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

     

    Important

    `Launch Screen`์œผ๋กœ ์ •์ ์ธ ์ด๋ฏธ์ง€ ์ž์ฒด๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ๋งˆ์„ธ์š”.

    Storyboard ๋ฅผ ์ด์šฉํ•˜์—ฌ Launch Screen ์„ ๋งŒ๋“ค๋ผ๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค.

     

    iOS 14 ๋ฒ„์ „ ์ดํ›„๋กœ, Launch Screen ์˜ ํฌ๊ธฐ๋Š” 25MB ๋กœ ์ œํ•œ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.



     

    ์•ฑ์— ํ•„์š”ํ•œ ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜๊ธฐ

     

    ์•ฑ์˜ Launch-time ์ดˆ๊ธฐํ™” ์ฝ”๋“œ๋ฅผ ์•„๋ž˜์— ์ œ์‹œํ•œ ๋ฉ”์†Œ๋“œ์— ์ž‘์„ฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

     

    UIKit ์€ ์œ„ ๋ฉ”์†Œ๋“œ๋“ค์„ ์•ฑ์˜ Launch-cycle ์‹œ์ž‘๋ถ€๋ถ„์— ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค.

     

    ์œ„ ๋ฉ”์†Œ๋“œ๋“ค์€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์šฉ๋„๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    • ์•ฑ์— ํ•„์š”ํ•œ ์ž๋ฃŒ ๊ตฌ์กฐ ์ดˆ๊ธฐํ™”ํ•˜๊ธฐ
    • ์•ฑ์ด ์‹คํ–‰์„ ํ•„์š”๋กœํ•˜๋Š” ๋ฆฌ์†Œ์Šค๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธ
    • ์•ฑ์ด ์ตœ์ดˆ์— ์‹คํ–‰๋  ๋•Œ `one-time setup`์ˆ˜ํ–‰ํ•˜๊ธฐ. ์˜ˆ๋ฅผ ๋“ค๋ฉด, ํ…œํ”Œ๋ฆฟ์„ ์„ค์น˜ํ•˜๊ฑฐ๋‚˜, ์“ฐ๊ธฐ๊ฐ€๋Šฅํ•œ ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์‚ฌ์šฉ์ž ์ˆ˜์ •๊ฐ€๋Šฅํ•œ ํŒŒ์ผ๋“ค์„ ์„ค์น˜ํ•˜๊ธฐ.  ๊ด€๋ จ ๊ธ€
    • ์•ฑ์ด ์‚ฌ์šฉํ•˜๋Š” ์ค‘์š”ํ•œ ์„œ๋น„์Šค์™€ ์—ฐ๊ฒฐํ•˜๊ธฐ. ์˜ˆ๋ฅผ ๋“ค๋ฉด, ์•ฑ์ด remote noti ๊ฐ€ ํ•„์š”ํ•œ ๊ฒฝ์šฐ APN ์„œ๋น„์Šค์— ์—ฐ๊ฒฐํ•˜๊ธฐ.
    • `Launch options dictionary` ๋ฅผ ํ™•์ธํ•˜์—ฌ, ์•ฑ์ด ์™œ ์‹คํ–‰๋˜์—ˆ๋Š”์ง€์— ๋Œ€ํ•œ ์ •๋ณด ํ™•์ธํ•˜๊ธฐ. ๊ด€๋ จ ๊ธ€

     

    `Scene-based` ์•ฑ์ด ์•„๋‹Œ ๊ฒฝ์šฐ, UIKit ์€ ์•ฑ์˜ ๊ธฐ๋ณธ UI ๋ฅผ launch-time ์— ์ž๋™์œผ๋กœ ๋ถˆ๋Ÿฌ์˜ต๋‹ˆ๋‹ค.

     

    UI๊ฐ€ ํ™”๋ฉด์— ๋‚˜ํƒ€๋‚˜๊ณ  ์ถ”๊ฐ€์ ์ธ ์ž‘์—…์„ ํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ์— application(_:didFinishLaunchingWithOptions:)  ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

     

    ์œ„ ๋ฉ”์„œ๋“œ์˜ ํ˜ธ์ถœ ์‹œ์ ์€ LaunchScreen ์ด ์‚ฌ๋ผ์ง€๊ณ  Main ์— ํ•ด๋‹นํ•˜๋Š” ์”ฌ์ด ํ™”๋ฉด์— ๋‚˜ํƒ€๋‚˜๊ธฐ ์ง์ „ ์‹œ์ ์ž…๋‹ˆ๋‹ค.

     

    ์˜ˆ๋ฅผ ๋“ค์–ด ์‚ฌ์šฉ์ž๊ฐ€ ์ง์ „ ์•ฑ ์ข…๋ฃŒ ์‹œ์ ์ „์— ํ•˜๊ณ  ์žˆ์—ˆ๋˜ ์ž‘์—…์„ ๋ฐ˜์˜์‹œํ‚จ ํ™”๋ฉด์„ ๋ณด์—ฌ์ฃผ๊ฒŒ ์„ค์ •ํ•  ์ˆ˜๋„ ์ž‡์Šต๋‹ˆ๋‹ค.


     

    ๋ฉ”์ธ ์“ฐ๋ ˆ๋“œ์—์„œ ์‹œ๊ฐ„์ด ์˜ค๋ž˜๊ฑธ๋ฆฌ๋Š” ์ž‘์—…๋“ค์„ ์ œ๊ฑฐํ•˜๊ธฐ

    ์‚ฌ์šฉ์ž๊ฐ€ ์•ฑ์„ ์‹œ์ž‘์‹œํ‚ฌ ๋•Œ, ๋น ๋ฅด๊ฒŒ Launching ํ•ด์„œ ์ข‹์€ ์ธ์ƒ์„ ๋‚จ๊ฒจ์•ผ ํ•ฉ๋‹ˆ๋‹ค.

     

    UIKit์€  application(_:didFinishLaunchingWithOptions:) ๊ฐ€

    ๋ฐ˜ํ™˜๋˜๊ธฐ ์ „๊นŒ์ง€ ์•ฑ์˜ UI๋ฅผ ํ™”๋ฉด์— ํ‘œ์‹œํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

     

    application(_:didFinishLaunchingWithOptions:) ๋‚˜ application(_:willFinishLaunchingWithOptions:) ๋ฉ”์„œ๋“œ์—์„œ ์‹œ๊ฐ„์ด ์˜ค๋ž˜๊ฑธ๋ฆฌ๋Š” ์ž‘์—…์„ ํ•œ๋‹ค๋ฉด, ์‚ฌ์šฉ์ž์—๊ฒŒ ์•ฑ์ด ๊ตผ๋œจ๋‹ค๊ณ (sluggish) ์ƒ๊ฐ๋˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

     

    ์•ฑ์ด `background`์— ๋Ÿฐ์นญ ๋  ๋•Œ๋„ ์œ„ ๋ฉ”์„œ๋“œ๋“ค์„ ๋น ๋ฅด๊ฒŒ ๋ฐ˜ํ™˜ํ•˜๋Š” ๊ฒƒ์€ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.

    :: ์™œ๋ƒํ•˜๋ฉด ์‹œ์Šคํ…œ์ด ์•ฑ์˜ `background`์‹คํ–‰ ์‹œ๊ฐ„์„ ์ œํ•œํ•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

     

    ๋”ฐ๋ผ์„œ ์•ฑ ์ดˆ๊ธฐํ™”์— ์ค‘์š”ํ•˜์ง€ ์•Š์€ ์ž‘์—…๋“ค์€ launch-time cycle์—์„œ ์ œ๊ฑฐํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค

     

    ๊ทธ ์˜ˆ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

    • ์•ฑ์ด ๋‹น์žฅ ํ•„์š”๋กœํ•˜์ง€ ์•Š๋Š” ๊ธฐ๋Šฅ๋“ค์˜ ์ดˆ๊ธฐํ™”๋ฅผ ๋’ค๋กœ ๋ฏธ๋ค„์ฃผ์„ธ์š”.
    • ์ค‘์š”ํ•˜๊ณ , ์‹œ๊ฐ„์ด ์˜ค๋ž˜๊ฑธ๋ฆฌ๋Š” ์ž‘์—…๋“ค์„ ์•ฑ์˜ ๋ฉ”์ธ ์“ฐ๋ ˆ๋“œ์—์„œ ์ œ๊ฑฐํ•˜์„ธ์š”.
    • ๊ทธ๋Ÿฐ ์ž‘์—…๋“ค์€ Global Dispatch Queue์—์„œ ๋น„๋™๊ธฐ์ ์œผ๋กœ ๋Œ๋ฆฌ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

    Global Dispatch Queue ๋Š” GCD ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์ž‘์—… ํ์ž…๋‹ˆ๋‹ค.

    ์ œ๊ฐ€ ์ž‘์„ฑํ•œ ๊ด€๋ จ ๊ธ€์„ ํ•œ๋ฒˆ ์ฝ์–ด๋ณด์„ธ์š”!

     

     

    ๐Ÿค” ์•Œ๊ฒŒ ๋œ์ 

    Launch-cycle ์—์„œ ํ˜ธ์ถœ๋˜๋Š” ๋ฉ”์„œ๋“œ application(_:didFinishLaunchingWithOptions) ๋“ฑ์ด ๋ฉ”์ธ ์“ฐ๋ ˆ๋“œ์—์„œ ๋Œ์•„ ๊ฐ„๋‹ค๋Š”์ , ์ƒˆ์‚ผ ์ƒ๊ฐํ•ด๋ณด๋ฉด ๋‹น์—ฐํ•œ ๊ฒƒ์ด์ง€๋งŒ ์˜ค๋žœ ์‹œ๊ฐ„์ด ๊ฑธ๋ฆฌ๋Š” ์ž‘์—…๋“ค์„ ์—ฌ๊ธฐ์„œ ์ˆ˜ํ–‰ํ•˜๋ฉด ์•ˆ๋˜๊ฒ ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค.


     

    ์•ฑ์ด ์™œ ์‹คํ–‰๋˜์—ˆ๋Š”์ง€ ํŒ๋‹จํ•˜๊ณ , ์‹คํ–‰ ์ด์œ ์— ๋”ฐ๋ผ ๋ถ„๊ธฐ์‹œํ‚ค๊ธฐ

     

    UIKit ์ด ์•ฑ์„ ์‹œ์ž‘์‹œํ‚ฌ ๋•Œ, UIKit์€ ์•ฑ์ด ์‹คํ–‰๋œ ์ด์œ ๋ฅผ `launch options dictionary`์— ๋„ฃ์–ด์„œ application(_:willFinishLaunchingWithOptions:) ์™€ application(_:didFinishLaunchingWithOptions:) ๋ฉ”์„œ๋“œ์— ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค๐Ÿ˜ฎ

     

    ํ•ด๋‹น ๋”•์…”๋„ˆ๋ฆฌ์˜ ํ‚ค๋Š” ์ฆ‰์‹œ ์ˆ˜ํ–‰ํ•˜์—ฌ์•ผ ํ•˜๋Š” ์ค‘์š”ํ•œ ์ผ๋“ค์„ ๊ฐ€๋ฆฌํ‚ต๋‹ˆ๋‹ค.

     

    ์˜ˆ๋ฅผ ๋“ค๋ฉด,

    ํ‚ค๋“ค์€ ์‚ฌ์šฉ์ž๊ฐ€ ์•ฑ ๋ฐ–์˜ ๋‹ค๋ฅธ ์–ด๋””์„ ๊ฐ€์—์„œ ์‹œ์ž‘ํ•œ ์ž‘์—…์„ ์šฐ๋ฆฌ์˜ ์•ฑ์—์„œ ์ด์–ด์„œ ํ• ์ˆ˜ ์žˆ๋„๋ก ๋ฐ˜์˜ํ• ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค๋‹ˆ๋‹ค.

     

    ํ•ญ์ƒ `Launch options dictionary`์˜ ํ‚ค ๋‚ด์šฉ์„ ํ™•์ธํ•˜๊ณ , ๊ทธ์— ๋งž๊ฒŒ ์ ์ ˆํ•˜๊ฒŒ ๋Œ€์‘ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.


    N o t e

     

    `Scene-based`์•ฑ์˜ ๊ฒฝ์šฐ์—๋Š” UIKit์ด application(_:configurationForConnecting:options:) ๋ฉ”์„œ๋“œ์— ์ „๋‹ฌํ•œ ์˜ต์…˜์„ ํ™•์ธํ•˜์—ฌ ์”ฌ์ด ์™œ ์ƒ์„ฑ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค

     


     

    ์•„๋ž˜ ์ฝ”๋“œ๋Š” `background` location update ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ App delegate ๋ฉ”์„œ๋“œ๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

     

    launchOptions์— `loaction key` ๊ฐ€ ์กด์žฌํ•œ๋‹ค๋ฉด, ์•ฑ์€ location update ๋ฅผ ๋ฏธ๋ฃจ์ง€ ์•Š๊ณ  ์ฆ‰์‹œ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

     

    Location update ๋Š” Core Location ํ”„๋ ˆ์ž„์›Œํฌ๊ฐ€ ์ƒˆ๋กœ์šด location event ๋ฅผ ์ „๋‹ฌํ•˜๊ฒŒ๋” ํ•ด์ค๋‹ˆ๋‹ค.

     

    class AppDelegate: UIResponder, UIApplicationDelegate, 
                   CLLocationManagerDelegate {
        
       let locationManager = CLLocationManager()
       func application(_ application: UIApplication,
                  didFinishLaunchingWithOptions launchOptions:
                  [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
           
          // If launched because of new location data,
          //  start the visits service right away.
          if let keys = launchOptions?.keys {
             if keys.contains(.location) {
                locationManager.delegate = self
                locationManager.startMonitoringVisits()
             }
          }
           
          return true
       }
       // other methods…
    }
    

     

    ์‹œ์Šคํ…œ์€ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ๊ธฐ๋Šฅ์— ๊ด€ํ•œ ํ‚ค๋Š” ํฌํ•จํ•ด์„œ ์ „๋‹ฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

     

    ์˜ˆ๋ฅผ ๋“ค์–ด, ์•ฑ์ด remote notification ๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด, ์‹œ์Šคํ…œ์€ ์ด๊ฒƒ์„ ํ‚ค์— ํฌํ•จ์‹œํ‚ค์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

     

     

    UIKit ์ด ์ „๋‹ฌํ•˜๋Š” LaunchOptionKey ์— ๋Œ€ํ•ด์„œ ๊ถ๊ธˆํ•˜๋‹ค๋ฉด? ๐Ÿ‘‰๐Ÿป ๊ณต์‹๋ฌธ์„œ ์ฝ๊ธฐ

     

     

    ๋!


    ๐Ÿค–๐ŸŸข[์šฐ์งฑ์˜ iOS ๋ธ”๋กœ๊ทธ]๐Ÿ”ต๐Ÿ’ป

    iOS๋ฅผ ๊ณต๋ถ€ํ•˜๋ฉด์„œ ๋ฐฐ์šด ๋‚ด์šฉ์„ ๊ธฐ๋กํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

    ๋Œ“๊ธ€

์–ด์ œ๋ณด๋‹ค ๋ฐœ์ „ํ•œ ๋‚˜