Revunuecat과 Expo 관리형 워크플로우의 통합

Revunuecat과 Expo 관리형 워크플로우의 통합

영리치 0 77 07.19 13:27

https://www.revenuecat.com/blog/using-revenuecat-with-expos-managed-workflow/ 


최신 문서 위에 참고하면 됨



ios 실행 명령어

EXPO_NO_CAPABILITY_SYNC=1 eas build --profile development --platform ios

웹사이트로 실행 가능함.



참고로 엑스포 build는 시간이 많이 걸림

미국 시간대보다는 미국 저녁 시간, 한국 낮 시간에 해야함


참고로 한국시간 프리티어의 경우 20분 걸리고

미국 시간은 프리티어의 경우 4시간 걸림



import React, { useEffect, useState } from 'react';
import { Platform, Text, View } from 'react-native';

import Purchases, { PurchasesOffering } from 'react-native-purchases';

const APIKeys = {
apple: "your_revenuecat_apple_api_key",
google: "your_revenuecat_google_api_key",
};

export default function App() {
const [currentOffering, setCurrentOffering] = useState<PurchasesOffering | null>(null);

useEffect(() => {
const fetchData = async () => {
const offerings = await Purchases.getOfferings();
setCurrentOffering(offerings.current);
};

Purchases.setDebugLogsEnabled(true);
if (Platform.OS == "android") {
Purchases.setup(APIKeys.google);
} else {
Purchases.setup(APIKeys.apple);
}

fetchData()
.catch(console.log);
}, []);

if (!currentOffering) {
return "Loading...";
} else {
return (
<View>
<Text>Current Offering: {currentOffering.identifier}</Text>
<Text>Package Count: {currentOffering.availablePackages.length}</Text>
{
currentOffering.availablePackages.map((pkg) => {
return <Text>{ pkg.product.identifier }</Text>
})
}
</View>
);
}
}


In order to be iterable, non-array objects must have a [Symbol.iterator]() method.


This error is located at:

    in App (created by ExpoRoot)

    in ExpoRoot

    in RCTView (created by View)

    in View (created by AppContainer)

    in RCTView (created by View)

    in View (created by AppContainer)

    in AppContainer

at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException

at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException

at node_modules/react-native/Libraries/Core/ReactFiberErrorDialog.js:43:2 in showErrorDialog

at node_modules/react-native/Libraries/ReactNative/renderApplication.js:58:4 in renderApplication

at node_modules/react-native/Libraries/ReactNative/AppRegistry.js:117:25 in runnables.appKey.run

at node_modules/react-native/Libraries/ReactNative/AppRegistry.js:202:4 in runApplication


RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks

at node_modules/react-native/Libraries/Utilities/RCTLog.js:34:8 in logIfNoNativeHook


TypeError: Invalid attempt to destructure non-iterable instance.

In order to be iterable, non-array objects must have a [Symbol.iterator]() method.


This error is located at:

    in App (created by ExpoRoot)

    in ExpoRoot

    in RCTView (created by View)

    in View (created by AppContainer)

    in RCTView (created by View)

    in View (created by AppContainer)

    in AppContainer

at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException

at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException

at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError

at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0



위 코드로 실행해보려고 했는데 에러 엄청 많이 남



import Purchases, { PurchasesOffering } from "react-native-purchases";

위의 에러는 패키지 임포트 과정에서 나옴


expo run:ios -d 00008030-000939AC0EB8402E


위와 같이 UUID로 실행하라고 함. Expo Go에서는 안되나봄?

UUID로도 안되서 아래와 같이 실행함


관련 이슈

https://github.com/expo/expo/issues/11786 

https://github.com/expo/expo/issues/17581 


expo run:ios

b75896754231e6306a91c41d05b53588_1658214295_8875.png


b75896754231e6306a91c41d05b53588_1658214379_0826.png

새로운 폴더들이 막 생기는 중
 


피지컬 디바이스를 컴퓨터에 연결하고 다음과 같이 실행함

expo run:ios --device 00008030-000939AC0E


위에는 인앱 결제 테스트 등 피지컬 디바이스를 노트북 선으로 연결해야함. 노트북과 아이폰이 물리적으로 연결되어 있어야함.


실행했더니 이제 이런 에러남

There's a problem with your configuration. There are no products registered in the RevenueCat dashboard for your offerings. To configure products, follow the instructions in https://rev.cat/how-to-configure-offerings. 

More information: https://rev.cat/why-are-offerings-empty



현재 코드는 아래와 같음


import React, { useEffect, useState } from "react";
import { SafeAreaView } from "react-native";
import { StatusBar } from "expo-status-bar";
import { Platform, Text, View } from "react-native";

import Purchases, { PurchasesOffering } from "react-native-purchases";

import { APIKeys } from "../utils/contants.js";

const Test = ({}) => {
const [currentOffering, setCurrentOffering] = useState(null);

useEffect(() => {
const fetchData = async () => {
const offerings = await Purchases.getOfferings();
setCurrentOffering(offerings.current);
};

Purchases.setDebugLogsEnabled(true);
if (Platform.OS == "android") {
Purchases.setup(APIKeys.google);
} else {
Purchases.setup(APIKeys.apple);
}

fetchData().catch(console.log);
}, []);

if (!currentOffering) {
return (
<SafeAreaView style={{ backgroundColor: "#ffffff", flex: 1 }}>
<StatusBar style={"dark"} backgroundColor={"#ffffff"} />
<View>
<Text>Loading...</Text>
</View>
</SafeAreaView>
);
} else {
return (
<SafeAreaView style={{ backgroundColor: "#ffffff", flex: 1 }}>
<StatusBar style={"dark"} backgroundColor={"#ffffff"} />
<View>
{/* 웹뷰에서 현재 URL을 트래킹 하는 것은 React Web과의 통신을 통해 해결해야 할 것 같음. */}
<Text>Current Offering: {currentOffering.identifier}</Text>
<Text>Package Count: {currentOffering.availablePackages.length}</Text>
{currentOffering.availablePackages.map((pkg) => {
return <Text>{pkg.product.identifier}</Text>;
})}
</View>
</SafeAreaView>
);
}
};

export default Test;
 



49a36bb00b5054cfafaaf3adcd7b3038_1658240973_2994.png
 

offerings 채워넣으면 다음과 같이 나옴.


49a36bb00b5054cfafaaf3adcd7b3038_1658241016_2806.jpeg


이렇게 한다음에 뭐 어쩌란건지 모르겠음. 그 다음 말이 없음 ㅠ
 

Comments

Category
Magazine
훈남/훈녀
 
 
 
Facebook Twitter GooglePlus KakaoStory NaverBand