Skip to Content
MobileReact Native11-ios-android

1. Android - manifest, Activity, Application

1.1 Application

  • 안드로이드 Application에서 전체 앱 상태를 관리하는 class
  • Event를 전달하기 위한 함수를 제공
    • onCreate : 어플리케이션이 실행될 때 최초에 호출
    • onTerminate : 어플리케이션이 종료될 때 호출

1.2 Manifest

  • Android 앱의 메타 정보를 요약해서 선언 해 둔것
  • 권한, 이름, 패키지명 등 앱의 전반적인 내용들을 담고 있음
  • 위치 : android/app/src/main/AndroidManifest.xml

1.3 Activity

  • 안드로이드에서 화면을 구성 하는 요소
  • 유저가 직접 보고, 누르는 등의 액션이 발생됨
  • 안드로이드의 4구성 요소 (activity, service, receiver, content provider)
  • Intent : 어떤 Activity를 호출할 때 사용하는것
    • 매개변수와 함께 보내는것
    • navigation을 이동했던 것과 비슷한 형태
  • Activity Life-cycle : onCreate → onResume → onPause → onDestroy

1.3.1 Intent-Filter

  • Intent-Filter : Intent를 실행 시킬 때 어떤 종류의 activity인지를 빠르게 찾기 위한 수단
  • Intent-Filter 구조
    • Action : activity가 어떤 행동에 유효한 것인지 나타내는 값 (ex SEND등)
    • Category : 어떤 종류의 액티비티 인지를 나타내는 값
jsx
1
<intent-filter>
2
<action android:name="android.intent.action.MAIN" />
3
<category android:name="android.intent.category.LAUNCHER" />
4
</intent-filter>
  • Intent-Filter의 종류
    • ACTION_MAIN : 앱의 시작점. 홈화면에 아이콘이 만들어짐
    • ACTION_SEND : 공유하기 액션등이 필요할 때 사용됨
    • ACTION_DIAL : 전화번호 폰 패드와 같은 화면이 필요할 때 사용됨

2. iOS - Info.plist, AppDelegate

2.1 AppDelegate

  • Android에서 activity처럼 화면을 구성 하는 단위
  • 각각 앱의 상태에 따라 불려지게 되는 함수가 있음
  • 다음은 iOS App status 그림이다.
txt
1
Not running → Inactive → Background → Suspended
2
↑ ↓
3
Active

2.1.1 didFinishLaunchingWithOptions

앱이 최초 실행될 때 호출되는 함수. (like android application onCreate)


2.1.2 Info.plist

  • 권한, 앱의 이름, 실행시 주로 필요한 값들을 관리 해주는 파일
  • SDK API Key값, 권한 요청시 텍스트 등 값을 관리

2.2 Build Phase

앱을 실행 시킴에 있어 필요한 값들을 자동으로 설정하도록 Command로 모두 선언해둔것


3. Android / iOS Permissions

3.1 Permissions

특정 리소스를 필요로 할 때 사용자에게 허용 할것인지 물어보는것


3.1.1 iOS Permissions flow

txt
1
Start → available Device? → already request? → request → granted
2
↓ ↓ ↓
3
unavailable ↓ ↓
4
blocked, limited, granted ↓
5
blocked

3.1.2 Android Permissions flow

txt
1
Start → available Device? → already request? → request → can request once?
2
↓ ↓ ↓ ↓
3
unavailable granted granted blocked

3.1.3 추가로 더 필요한것

  • iOS - Info.plist 권한 요청문

3.2 자주 사용하는 권한

  • 사진 관련
    • iOS - NSPhotoLibraryUsageDescription
    • Android - READ_EXTERNAL_STORAGE
  • 카메라 관련
    • iOS - NSCameraUsageDescription
    • Android - WRITE_EXTERNAL_STORAGE
  • 위치 관련
    • iOS - NSLocationAlwaysAndWhenInUseUsageDescription
    • Android
      • ACCESS_FINE_LOCATION
      • ACCESS_COARSE_LOCATION
      • ANDROID_BACKGROUND_LOCATION
  • AppTrackingTransparency
    • IDFA를 읽어오는 권한
    • iOS 앱 심사시 필수로 보고 있는 정보

4. Android / iOS Sceheme

4.1 Scheme

  • 외부에서 우리 앱을 호출하거나, 우리 앱이 외부앱을 호출하는 수단
  • test://path/to/screen
    • test:// 부분 : scheme
    • path/to/screen 부분 : path

4.2 Scheme 정의하는법

4.2.1 Android

  • intent-filter를 통해서 정의
jsx
1
<intent-filter>
2
<action android:name="android.intent.action.VIEW" />
3
<category android:name="android.intent.category.DEFAULT" />
4
<category android:name="android.intent.category.BROWSABLE" />
5
<data android:scheme="scheme" />
6
</intent-filter>

4.2.2 iOS

  • Info.plist > URL Types에 저장

4.3 Scheme 테스트하는법

  • uri-scheme package를 통하여 테스트
shellscript
1
npx uri-scheme open "scheme://path" —-ios
2
npx uri-scheme open "scheme://path" --android