TIL: RN | 인앱 결제 react-native-iap (10) etc. - 221130

Lumpen·2022년 11월 30일
0

RN인앱결제

목록 보기
10/16

앱 내에서 구독 취소

iOS와 Android 모두에서 사용자는 앱 내에서 구독을 취소할 수 없습니다. 사용자를 iTunes/App Store 또는 Google Play로 안내해야 합니다.

iTunes 로 가기

iOS 12 이상

Linking.openURL('https://apps.apple.com/account/subscriptions');

iOS 12 미만
https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/manageSubscriptions

android

Linking.openURL(
  'https://play.google.com/store/account/subscriptions?package=YOUR_PACKAGE_NAME&sku=YOUR_PRODUCT_ID',
);

(change YOUR_PACKAGE_NAME and YOUR_PRODUCT_ID)

How do I handle promoted products in iOS?

(버전 8.6.0부터) 네이티브 코드에서는 자동으로 처리된다. 추가 기본 설정이 필요하지 않음

javascript

앱 라이프사이클 초기에 iap 프로모션 제품 이벤트 청취자를 추가합니다.

import {NativeModules, NativeEventEmitter} from 'react-native';
const {RNIapIos} = NativeModules;
const RNIapEmitter = new NativeEventEmitter(RNIapIos);

RNIapEmitter.addListener('iap-promoted-product', async () => {
  // Check if there's a persisted promoted product
  const productId = await RNIap.getPromotedProductIOS();
  if (productId !== null) {
    // You may want to validate the product ID against your own SKUs
    try {
      await RNIap.buyPromotedProductIOS(); // This will trigger the App Store purchase process
    } catch (error) {
      console.warn(error);
    }
  }
});
profile
떠돌이 생활을 하는. 실업자는 아니지만, 부랑 생활을 하는

0개의 댓글