heartright-co / expo-bare-test-module_payment

0 stars 0 forks source link

RevenueCat 이용 #4

Closed byyoungjin closed 3 years ago

byyoungjin commented 3 years ago

RevenueCat 으로 ios, android subscription 통합관리

3 과연결

1. offerings

offering display guide -> 사용자별로 다른 subscription 설정 가능 https://docs.revenuecat.com/docs/displaying-products

2. making purchase

구매하기 https://docs.revenuecat.com/docs/making-purchases

넘어가는 'package' 인자는 offerings.current.availablePackages 어레이의 각 item object

3. get subscriptoin status

지금 user 의 subscription 현황 알아보기 https://docs.revenuecat.com/docs/getting-started#get-subscription-status

byyoungjin commented 3 years ago

issue 1: offering is empty

identifier 를 store 와 동일하게 설정해줘야한다, https://support.revenuecat.com/hc/en-us/articles/360045538973-Why-are-active-entitlements-empty-with-an-active-subscription-

byyoungjin commented 3 years ago

issue2 : purchase 에서 'there was a credential issue' 에러

확인해보니 https://docs.revenuecat.com/discuss/5ea749abbbfeff0018f166f3

API 액세스에서 내 서비스 account 로 내 앱에 권한을 부여해야한다. https://docs.revenuecat.com/docs/creating-play-service-credentials

아직 error 존재 revenueCat 에따르면 https://docs.revenuecat.com/docs/creating-play-service-credentials#4-enter-the-credentials-json-in-revenuecat It can take up to 36 hours for your Play Service Credentials to work properly with the Android Developer API. You may see "Invalid Play Store credentials" errors and be unable to make purchases with RevenueCat until this happens. 라고하니 일단 36시간까지 기다려보기로

--> 약 36시간 이상 지났고, 확인해보니 잘 돌아감.

byyoungjin commented 3 years ago

기다리는 동안 ios setup

요거 진행해 보자 https://docs.revenuecat.com/docs/reactnative#additional-ios-setup

1. ios configuration on RevenueCat

inapp specific shared seccret 생성 https://docs.revenuecat.com/docs/itunesconnect-app-specific-shared-secret

subscription key 생성 https://www.revenuecat.com/blog/signing-ios-subscription-offers

2. offering, purchase, subscription상태 확인까지 완료

3. test 환경 setup 하기

ultimate guide to test ios subscription https://docs.revenuecat.com/docs/sandbox

4. restorePurchases

: 정리하자면 revenueCat 은 appUserId 를 가지고 user 를 파악하고 subscription 은 store 들과 연결되어있지만 따로 user identifier 를 제공하지 않는다. 그래서 사용자가 로그인하지 않았거나 중복되는 앱계정을 가지고있을때, 자기 store 계정을 통해서 자기가 구매한것을 증명하고 싶을때 restore 한다. restore 하는경우, revenueCat은 appUserId 들간에 alias를 만들고, 해당 alias 에 속하는 appUserId들은 한명의 user로 파악되어 같은 subscription 을 공유한다.

궁금한건, restore 할때 , device 도 고려하는것인지이다. 아래보면 apple Id(test용) 과 appUserId 를 다 바꾸고 로그인해도 바뀐 appUserId 가 기존 subscription 을 가져왔다. ( 바꾼 appUserId가 alias 에 포함되었다. ) apple Id 를 바꿨기때문에, tracking 할수있는건 device 밖에 없는것 같은데.. 확인해봐야할 부분.

기본적으로 구독한 유저가, 앱을 삭제했다가 다시 앱을 설치하고 돌아왔을경우, 기존에 구매했던 구독을 restore 할 수있게 해주는 기능. https://docs.revenuecat.com/v1.2/discuss/5dce991a93418b04c642be60#:~:text=Allowing%20that%20user%20to%20tap,ve%20previously%20made%20with%20RevenueCat.&text=The%20getPurchaserInfo%20call%20is%20getting,current%20App%20User%20Id%20only.

유저가 실수로 2개의 어카운트를 만들더라도 apple acount 가 같으면 merge한다. revenueCat 에는 appUserId 가 있는데, 내가 setup 할때 지정할수 있고(이때 지정값은 내 db 상의 userId 가될수 있을듯) , 지정하지 않으면, 앱 인스톨마다 다른 anonymousId 를 부여한다. 그래서 아이디는 유저가 실수로 2개의 어카운트를 만들거나, 지정하지않고 앱을 지웠다 다시깔면, userAppId 가 2개가 된다. 그대로 같은 apple id 상에서 이미 구매했던 것을 restore 해주는것이 바로 restore 기능. https://docs.revenuecat.com/v1.2/discuss/5e7558021ea1ea0021c11a6b

apple developer restore docs https://developer.apple.com/documentation/storekit/in-app_purchase/restoring_purchased_products

retore test 해보기

  1. pnuu_tester@gmail.com 으로 구독신청하고 앱을 삭제한다.
  2. 다시 앱을 깐다. -> 그냥 바로 된다. 왜냐면 내가 appUserId = tester_user_id 로 픽스해뒀기때문

1.같은 appleId 상에서 앱setup 할때 appUserId = 'tester_user_id2' 로 바꿔본다. -> revenueCat 에서 기존 id를 tester_user_id2로 바꾼다 ( 이게 merging 한다는 뜻인것 같음)

  1. appleId 와 apple acount 둘다 바꾼다. -> 그래도 연동되네..device 도 tracking 하는건가..?

  2. appUserId 를 지정하지 않는다.(user 가 가입하지 않은상황 가정)

userId 가 provide 되면 restore이 일어나지 않아도된다. https://docs.revenuecat.com/docs/user-ids#provided-app-user-id

image

5. Listening for Purchaser Info updates

앱내에서 request 보낼때, response 를 받아오면서 change 가 있으면, 호출되는 수동적인 listener 다른 platform 이나 다른 환경에서 바뀌었을때, 필요한 작업들을 진행해준다. -> purchase 후 user state 업데이트하는 로직등을 여기다가 넣으면됨. https://docs.revenuecat.com/docs/getting-started#listening-for-purchaser-info-updates

byyoungjin commented 3 years ago

Pod install 에대해

정확히 어떤역할을 하는지, https://stackoverflow.com/questions/58475316/what-exactly-does-pod-install-do-in-react-natives-autolinking

byyoungjin commented 3 years ago

test 환경에서의 시간 가속

https://docs.revenuecat.com/docs/apple-app-store#working-with-subscriptions

image

https://developer.apple.com/documentation/storekit/in-app_purchase/testing_in-app_purchases_with_sandbox

byyoungjin commented 3 years ago

user identification

production 에서는 아래와같이 설정필요할듯, 아니면 Oauth 로 설정 가능할까? https://docs.revenuecat.com/docs/user-ids

byyoungjin commented 3 years ago

마무리

RevenueCat 으로 inapp subscription 구현 방법에 대해 알아보고, 구현해봄. sandBox 수준에서 잘 동작하는것 확인했고, 실제로 만들고, 프러덕션수준에서 테스트하면서 진행하면 될듯