Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any plan on supporting in-app purchase initiated from the App Store #102

Open
rohitgoyal opened this issue Jul 5, 2017 · 9 comments
Open

Comments

@rohitgoyal
Copy link

As Apple released the new beta SDK with support of IAP from the App Store page itself. It would be really helpful to have that functionality with this library.

https://developer.apple.com/documentation/storekit/skpaymenttransactionobserver/2877502-paymentqueue

@djw27
Copy link

djw27 commented Sep 27, 2017

+1

@chirag04
Copy link
Owner

happy to accept a PR that has an event based api for this.

@jeremyhicks
Copy link

I dropped the method in to handle it. It does kick off the purchase process but obviously there is no callback to tell the RN app that the purchase was a success. I'm willing to work on it but I've never done anything with events and was looking into Bubble and Direct events but they need to be attached to an element.

- (BOOL)paymentQueue:(SKPaymentQueue *)queue
  shouldAddStorePayment:(SKPayment *)payment
  forProduct:(SKProduct *)product
{
  return YES;
}

@superandrew213
Copy link
Contributor

@chirag04 can you give an example of how you want the API to look like?

@superandrew213
Copy link
Contributor

superandrew213 commented Oct 10, 2017

@chirag04 @jeremyhicks @rohitgoyal please see PR #128.

Added PurchaseCompleted event that is triggered for in-app purchases initiated from the App Store and subscription renewals. It can be used like this:

import {
  NativeEventEmitter,
  NativeModules,
} from 'react-native';

const { InAppUtils } = NativeModules;

const InAppUtilsEmitter = new NativeEventEmitter(InAppUtils);

const listener = InAppUtilsEmitter.addListener('PurchaseCompleted', purchase => {
  if(purchase && purchase.productIdentifier) {
      Alert.alert('Purchase Successful', 'Your Transaction ID is ' + purchase.transactionIdentifier);
      //unlock store here.
   }
});

listener.remove();

I also added promise support and an index.js so that we can import InAppUtils directly:

import InAppUtils from 'react-native-in-app-utils'

instead of:

import {
  NativeModules,
} from 'react-native';

const { InAppUtils } = NativeModules;

You can then also easily add the listener like this:

InAppUtils.addListener('PurchaseCompleted', this._onPurchaseCompleted);

These should be all non-breaking changes.

It would be great if someone else could also test in-app purchases initiated from the App Store and subscription renewals.

To trigger an in-app purchase initiated from the App Store, open this on your device:

itms-services://?action=purchaseIntent&bundleId=com.example.app&productIdentifier=product_name

Replace bundleId and productIdentifier with your own.

@jeremyhicks
Copy link

@superandrew213 awesome, I will test this out tonight and report back

@oguchy
Copy link

oguchy commented Jun 21, 2018

Any update on this?

@andreiciceu
Copy link

can they be retrieved using restorePurchases?

@ohtangza
Copy link

ohtangza commented Mar 6, 2020

This is very critical to get organic traffic. Any updates on it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants