AndrewDongminYoo / react-native-step-counter

[리액트 네이티브 라이브러리] 사용자의 걸음 수를 계산합니다. Android는 StepCounter (or Accelerometer) 센서 API를, iOS는 CoreMotion CMPedometer 를 사용하여 걸음 수를 측정합니다.
https://andrewdongminyoo.github.io/react-native-step-counter/
MIT License
29 stars 10 forks source link

⚠ No permission handler detected. #5

Closed AndrewDongminYoo closed 1 year ago

AndrewDongminYoo commented 1 year ago

Expected Behavior

Actual Behavior

⚠  No permission handler detected.

• Check that you added at least one permission handler in your package.json reactNativePermissionsIOS config.
• Uninstall this app, reinstall your Pods, delete your Xcode DerivedData folder and rebuild it.

-[RNPermissions constantsToExport]
    RNPermissions.m:209
__57-[RCTModuleData gatherConstantsAndSignalJSRequireEnding:]_block_invoke
RCTUnsafeExecuteOnMainQueueSync
-[RCTModuleData gatherConstantsAndSignalJSRequireEnding:]
-[RCTModuleData gatherConstants]
__49-[RCTCxxBridge _prepareModulesWithDispatchGroup:]_block_invoke
DED4D0A5-1420-32AE-83A6-C31D938A1C9A
DED4D0A5-1420-32AE-83A6-C31D938A1C9A
DED4D0A5-1420-32AE-83A6-C31D938A1C9A
_dispatch_main_queue_callback_4CF
42CCFC7B-FF32-3D25-8F01-CCB2AD843A8B
42CCFC7B-FF32-3D25-8F01-CCB2AD843A8B
CFRunLoopRunSpecific
GSEventRunModal
CF21AD9C-EFBF-3961-A7C0-54BD30CEFEA9
UIApplicationMain
main
4B042F28-0D14-30EC-A1DE-3DBB10866AD7

Steps to Reproduce the Problem

  1. yarn create react-native-app my-app
  2. yarn add @dongminyu/react-native-step-counter react-native-permissions
  3. react-native link @dongminyu/react-native-step-counter
  4. npx pod-install
  5. npx react-native run-*android/ios*

Specifications

first, you should check your react-native-step-counter version and write it down.

AndrewDongminYoo commented 1 year ago

이 에러는 react-native-permissions 라이브러리를 사용할 때, iOS 권한 처리 핸들러가 설정되지 않았을 때 발생합니다.

해결책으로는 package.json 파일에서 reactNativePermissionsIOS 설정에 최소 하나 이상의 핸들러를 추가해주면 됩니다. 예를 들어, 카메라 권한 처리를 추가하려면 아래와 같이 설정해주면 됩니다.

{
  "name": "step-counter-example",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "@dongminyu/react-native-step-counter": "*",
    "react-native-permissions": "^13.1.0"
  },
  "reactNativePermissionsIOS": {
    "Motion": {
      "title": "Step Counter Permission",
      "message": "This app needs access to your motion sensor",
      "buttonPositive": "OK",
      "buttonNegative": "Cancel"
    }
  }
}

직접적으로 이 모듈에 필요한 Motion Pod을 링크하는 방법도 있습니다. 다음의 코드를 ios 폴더의 Podfile에 입력하고, npx pod-install을 실행하면 됩니다.

target 'step-counter-example' do
  config = use_native_modules!

  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Motion', :path => "#{permissions_path}/Motion"

또 다른 해결책으로는 앱을 삭제하고, Pod 파일들을 재설치한 후, XcodeDerivedData 폴더를 삭제하고 다시 빌드하면 됩니다.

AndrewDongminYoo commented 1 year ago

추가로 알게 된 것. 두가지 방법을 모두 사용하면 인터페이스 충돌이 일어나 빌드가 안된다. 별로 알고싶지는 않았다...