1.20
iOS์์๋ง ํ ์คํธ ๋จ
๊ตฌ๋ ๋ชฉ๋ก ๊ฐ์ ธ ์ค๊ธฐ
RNIap.getSubscriptions ์ค๋ฅ : [TypeError : undefined๋ ๊ฐ์ฒด๊ฐ ์๋๋๋ค ( 'RNIapIos.getItems'ํ๊ฐ).]
์์ ๋ชจ๋
````
const itemSkus = Platform.select ({
ios : [
'com.shares.sharesapp', // [ 'BASIC', 'CLASSIC', 'MAX', 'PLUS']๋ ์๋ํ์ต๋๋ค ..
],
android : [
'com.shares.sharesapp',
],
});
async componentDidMount () {
{
๊ธฐ๋ค๋ฆฌ๊ณ RNIap.prepare ();
}
catch (err1) {
console.log ( "RNIap.prepare ์ค๋ฅ :", err1);
}
๋๋์ด {
console.log ( "finally");
{
const ์ ํ = ๋๊ธฐ RNIap.getSubscriptions (itemSkus);
console.log ( '๊ตฌ๋
', ์ ํ);
}
catch (err) {
console.log ( "RNIap.getSubscriptions ์ค๋ฅ :", err);
}
}
}
````
์๋ฎฌ๋ ์ดํฐ์์ ์๋ ๋ฐ์ค ๊ณ์ ์ผ๋ก ์ฐ๊ฒฐํ ์ ์์ต๋๋ค
์ค์ ์ฅ์น์์๋ ์ด๋ฌํ ํ์
์ด
๋ค์์ App Store Connect์ ๊ตฌ๋
๋ชฉ๋ก์
๋๋ค.
๋๊ตฐ๊ฐ ์ด๊ฒ์ ์ข์ ์ํ๋ก ์ค์ ํ๋๋ก ๋์ ์ฃผ์๊ฒ ์ต๋๊น?
๋๋ ๋ํ ์๋ํ๋ค
const purchases = await RNIap.getAvailablePurchases();
console.info('Available purchases :: ', purchases);
๋์ผํ ๊ฒฐ๊ณผ :
RNIap.getSubscriptions error : [TypeError: undefined is not an object (evaluating 'RNIapIos.getAvailableItems')]
App Store Connect์์ ProductID๋ฅผ "com.shares.sharesapp.basic"์ผ๋ก ๋ณ๊ฒฝํ๋ ค๋ฉด
const itemSkus = Platform.select({
ios: [
'com.shares.sharesapp.basic'
],
๋ ์ด์ ์ฑ๊ณตํ์ง ๋ชปํฉ๋๋ค ...
์ค๋ช
๋๋ก ์๋์ผ๋ก ์ค์นํด์ผํ์ต๋๋ค ...
````
์๋ ์ค์น
iOS
In XCode, in the project navigator, right click Libraries โ Add Files to [your project's name]
Go to node_modules โ react-native-iap and add RNIap.xcodeproj
In XCode, in the project navigator, select your project. Add libRNIap.a to your project's Build Phases โ Link Binary With Libraries
Run your project (Cmd+R)
````
์ด๋ฒ์๋ ์ฐ๊ฒฐ์ ์์ฒญํ ํ (๋จผ์ ์ค์ ์ฅ์น์์ ์ฐ๊ฒฐ ํด์ ) ์๋ ๋ฐ์ค ์ฌ์ฉ์๋ก ๋ค์ด๊ฐ๊ณ ๊ตฌ๋
์ธ๋ถ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์ฌ ์์์์ต๋๋ค ๐
async componentDidMount() {
try {
await RNIap.prepare();
}
catch (err1) {
console.log("RNIap.prepare error : ", err1);
}
finally {
console.log("finally");
try {
console.log("itemSkus : ", itemSkus);
const products = await RNIap.getSubscriptions(itemSkus);
console.log('Subscriptions', products);
}
catch (err) {
console.log("RNIap.getSubscriptions error : ", err);
}
}
}
๊ฒฐ๊ณผ :
itemSkus : Array [
"com.shares.sharesapp.basic",
]
Subscriptions Array [
Object {
"currency": "EUR",
"description": "***",
"localizedPrice": "3,99ย โฌ",
"price": "3.99",
"productId": "com.shares.sharesapp.basic",
"title": "Abonnement BASIQUE",
"type": "Do not use this. It returned sub only before",
},
]
์ฐธ๊ณ ๋ก, RNIap.getSubscriptions (itemSkus)๋ ์๋ฎฌ๋ ์ดํฐ์์๋ ์๋ํฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ค๋ช ๋๋ก ์๋์ผ๋ก ์ค์นํด์ผํ์ต๋๋ค ...
````
์๋ ์ค์น
iOS
````