TIL: RN | 인앱 결제 react-native-iap (9) android Methods - 221130

Lumpen·2022년 11월 30일
0

RN인앱결제

목록 보기
9/16

acknowledgePurchaseAndroid

제품을 확인합니다.

Signature

acknowledgePurchaseAndroid(
  /** The product's token */
  token: string,

  /** Android developerPayload */
  developerPayload?: string,
): Promise<PurchaseResult | void>;

Usage

import React from 'react';
import {Button} from 'react-native';
import {acknowledgePurchaseAndroid} from 'react-native-iap';

const App = () => {
  const handlePurchase = async () => {
    await acknowledgePurchaseAndroid({
      token: 'token',
      developerPayload: 'developer-payload',
    });
  };

  return <Button title="Acknowledge purchase" onPress={handlePurchase} />;
}

deepLinkToSubscriptionsAndroid

구독 화면에 대한 심층 링크입니다.

Signature

deepLinkToSubscriptionsAndroid(
  /** The product's SKU */
  sku: Sku,
): Promise<void>;

Usage

import React from 'react';
import {Button} from 'react-native';
import {deepLinkToSubscriptionsAndroid} from 'react-native-iap';

const App = () => {
  const handleSubscriptions = async () => {
    await deepLinkToSubscriptionsAndroid({sku: 'sku-id'});
  };

  return <Button title="Manage subscriptions" onPress={handleSubscriptions} />;
};

flushFailedPurchasesCachedAsPendingAndroid

Consume all 'ghost' purchases.
이미 실패했지만 여전히 Play Store 캐시에 보류 중으로 표시된 보류 중인 결제입니다.

Signature

flushFailedPurchasesCachedAsPendingAndroid(): Promise<void>;

Usage

import React from 'react';
import {Button} from 'react-native';
import {flushFailedPurchasesCachedAsPendingAndroid} from 'react-native-iap';

const App = () => {
  const handleFlush = async () => {
    await flushFailedPurchasesCachedAsPendingAndroid();
  };

  return (
    <Button title="Flush purchases cache" onPress={handleFlush} />
  );
}

validateReceiptAndroid

영수증을 확인합니다.

이 메서드는 디버깅 목적으로만 사용됩니다. 사용자에게 제공하는 이진 파일에 액세스 토큰을 포함하는 것은 잠재적으로 위험합니다. 프로덕션 빌드에 서버 측 유효성 검사를 대신 사용하십시오.

Signature

validateReceiptAndroid(
  /** package name of your app. */
  packageName: string,

  /** product id for your in app product. */
  productId: string,

  /** token for your purchase. */
  productToken: string,

  /** accessToken from googleApis. */
  accessToken: string,

  /** whether this is a subscription or in-app product. `true` for subscription. */
  isSub?: boolean,
): Promise<ProductPurchase | SubscriptionPurchase>;

Usage

import React from 'react';
import {Button} from 'react-native';
import {validateReceiptAndroid} from 'react-native-iap';

const App = () => {
  const handlePurchase = async () => {
    const response = await validateReceiptAndroid({
      packageName: purchase.packageNameAndroid, 
      productId: purchase.productId, 
      productToken: purchase.purchaseToken, 
      accessToken: 'your-access-token', 
      isSub: true
  });
  };

  return <Button title="Purchase" onPress={handlePurchase} />;
}
profile
떠돌이 생활을 하는. 실업자, 부랑 생활을 하는

0개의 댓글