Giter Site home page Giter Site logo

revenuecat / react-native-purchases Goto Github PK

View Code? Open in Web Editor NEW
667.0 16.0 74.0 7.16 MB

React Native in-app purchases and subscriptions made easy. Support for iOS and Android.

Home Page: https://www.revenuecat.com

License: MIT License

Java 7.70% JavaScript 24.96% Objective-C 13.56% Shell 0.92% Ruby 4.37% Swift 0.12% Kotlin 12.51% TypeScript 35.69% C 0.07% HTML 0.09%
ios android stripe react-native iap hacktoberfest

react-native-purchases's Introduction

๐Ÿ˜ป In-App Subscriptions Made Easy ๐Ÿ˜ป

License

RevenueCat is a powerful, reliable, and free to use in-app purchase server with cross-platform support. Our open-source framework provides a backend and a wrapper around StoreKit and Google Play Billing to make implementing in-app purchases and subscriptions easy.

Whether you are building a new app or already have millions of customers, you can use RevenueCat to:

  • Fetch products, make purchases, and check subscription status with our native SDKs.
  • Host and configure products remotely from our dashboard.
  • Analyze the most important metrics for your app business in one place.
  • See customer transaction histories, chart lifetime value, and grant promotional subscriptions.
  • Get notified of real-time events through webhooks.
  • Send enriched purchase events to analytics and attribution tools with our easy integrations.

Sign up to get started for free.

React Native Purchases

React Native Purchases is the client for the RevenueCat subscription and purchase tracking system. It is an open source framework that provides a wrapper around StoreKit, Google Play Billing and the RevenueCat backend to make implementing in-app purchases in React Native easy.

Migrating from React-Native Purchases v4 to v5

RevenueCat SDK Features

RevenueCat
โœ… Server-side receipt validation
โžก๏ธ Webhooks - enhanced server-to-server communication with events for purchases, renewals, cancellations, and more
๐ŸŽฏ Subscription status tracking - know whether a user is subscribed whether they're on iOS, Android or web
๐Ÿ“Š Analytics - automatic calculation of metrics like conversion, mrr, and churn
๐Ÿ“ Online documentation and SDK reference up to date
๐Ÿ”€ Integrations - over a dozen integrations to easily send purchase data where you need it
๐Ÿ’ฏ Well maintained - frequent releases
๐Ÿ“ฎ Great support - Help Center

Getting Started

For more detailed information, you can view our complete documentation at docs.revenuecat.com.

Please follow the Quickstart Guide for more information on how to install the SDK.

Or view our React Native sample app:

Requirements

The minimum React Native version this SDK requires is 0.64.

SDK Reference

Our full SDK reference can be found here.


Installation

ExpoKit projects of version 33 or higher can successfully use react-native-purchases. If you haven't upgraded, you can follow the instructions here to upgrade.

โ—๏ธ If you're planning on ejecting from Expo, upgrade your expo version first, THEN eject. It'll save you a whole lot of hassle. โ—๏ธ

1. Add the library to the project

$ npm install react-native-purchases --save

or

$ yarn add react-native-purchases

2. Link library to the project

$ react-native link react-native-purchases

Additional iOS Setup

If your project uses Cocoapods

If your project already uses Cocoapods to install iOS dependencies, common in ExpoKit projects, linking the library should have added it to the podfile. If it hasn't, add the following to your project's podfile to reference the library from your node_modules folder:

pod 'RNPurchases', :path => '../node_modules/react-native-purchases'
    :inhibit_warnings => true

In your ios folder, run pod install. If you've just upgraded ExpoKit, you might need to upgrade cocoapods to the newest version: sudo gem install cocoapods.

Migrating from manual installation (if your project doesn't use CocoapodsCreate)

Remove the Framework Reference from your project
  1. Remove Purchases.framework and PurchasesHybridCommon.framework from the libraries section of the project.
Remove iOS Frameworks to Embedded Binaries
  1. In Xcode, in project manager, select your app target.
  2. Select the general tab
  3. Look for Purchases.framework and PurchasesHybridCommon.framework in the Embedded Binaries section and remove them.

Remove $(PROJECT_DIR)/../node_modules/react-native-purchases/ios from Framework Search paths in build settings

Remove Strip Frameworks Phase

During the old manual installation instructions, now deprecated, we indicated to add a build phase to strip fat frameworks.

  1. In Xcode, in project manager, select your app target.
  2. Open the Build Phases tab
  3. Remove the added Strip Frameworks phase
  4. Clean Derived Data
Link static library

The react-native link command should have added the libRNPurchases.a library to the Linked Frameworks and Libraries section of your app target. If it hasn't add it like this:

react-native-purchases's People

Contributors

aboedo avatar alfondotnet avatar anthonyjoeseph avatar beylmk avatar codykerns avatar coreyrab avatar dependabot[bot] avatar ericpkerr avatar ethervoid avatar fabien0102 avatar jeanregisser avatar jefago avatar jeiting avatar joshdholtz avatar markvillacampa avatar mboettcher avatar mshmoustafa avatar nachosoto avatar nfcampos avatar pettero avatar rcgitbot avatar rglanz-rc avatar swrobel avatar taquitos avatar tiinanguyen avatar timpetricola avatar tonidero avatar tonycosentini avatar vegaro avatar yonom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-purchases's Issues

Purchases.getProducts(['','']) returns an empty array

  • "react-native": "0.54.2",
  • "react-native-purchases": "1.3.4",
  • os: iOS,
  • environment: iPhone7,
  • entitlements, offerings and products (appstore only) are set in dashboard at RevenueCat

Code:
const products = await Purchases.getProducts(['itemId_1', 'itemId_2']);
console.log(products)

Expected behavior: display array of products (2 items)

Actual behavior: display empty array

Unzip can not create folder on Bitbucket Pipelines

There are problems installing this library on Bitbucket Pipelines

+ npm install --unsafe-perm=true --allow-root
> [email protected] preinstall /opt/atlassian/pipelines/agent/build/node_modules/react-native-purchases
> npm run fetch:ios:sdk
> [email protected] fetch:ios:sdk /opt/atlassian/pipelines/agent/build/node_modules/react-native-purchases
> ./scripts/download-purchases-framework.sh 1.1.3
cat: can't open '.framework_version': No such file or directory
/opt/atlassian/pipelines/agent/build/node_modules/react-native-purchases/ios
Downloading Purchases iOS 1.1.3 from https://github.com/RevenueCat/purchases-ios/releases/download/1.1.3/Purchases.framework.zip, this may take a minute.
unzip: can't change directory to 'temp': No such file or directory
mv: can't rename 'temp/Purchases.framework': No such file or directory
rm: can't remove 'temp': No such file or directory
Purchases.framework not found. Please reinstall react-native-purchases
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] fetch:ios:sdk: `./scripts/download-purchases-framework.sh 1.1.3`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] fetch:ios:sdk script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-10-18T11_06_26_893Z-debug.log
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] preinstall: `npm run fetch:ios:sdk`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-10-18T11_06_27_703Z-debug.log

Our bitbucket-pipelines.yml

image: node:10.8-alpine

pipelines:
  default:
    - step:
        caches:
          - node
        script:
          - npm install
          - npm run ci

Android userInfoMap rejection

Issue is related with:
#58

On every npm install, I need to go and edit RNPurchaseModule.java

Please add Throwable function:
function line: 441
private static void reject(Promise promise, PurchasesError error)

this is the old code
promise.reject(error.getCode().ordinal() + "", error.getMessage(), userInfoMap);

this is how to fix the issue:

promise.reject(error.getCode().ordinal() + "", error.getMessage(), (Throwable) userInfoMap);

Android "Service is not registered: com.android.billingclient.api.BillingClientImpl" when calling .setup() twice.

Im calling .setup() when a new user is signed in to initialise RevenueCat with the new appUserId. However when I call it the second time I am seeing the following:

Service is not registered: com.android.billingclient.api.BillingClientImpl

I can reproduce with the following;

  • react-native init TestApp
  • cd TestApp
  • yarn add react-native-purchases
  • react-native link react-native-purchases
  • Add the following to App.js:
async componentDidMount() {
  await Purchases.setup(REVENUE_CAT_KEY, '123');
  await Purchases.setup(REVENUE_CAT_KEY, '1234');
}
  • react-native run-android

...

image

"Cannot connect to the iTunes Store"

I am upgrading to 2.0.0 and I am getting this weird error on sandbox that you can see in the background of the Success message.

image

I am trying to render a JSON object in a iOS alert box, which is why there is a red screen. But the dialog says it worked.

try {
      console.log('selectedPlan', selectedPlan)
      const purchaseMade = await Purchases.makePurchase(selectedPlan.identifier);
      console.log('selectedPlan.purchaseMade', purchaseMade)
      if (purchaseMade != undefined && purchaseMade.purchaserInfo.activeEntitlements !== "undefined" &&
        purchaseMade.purchaserInfo.activeEntitlements.includes(selectedPlan.identifier)) {
        createPurchase(selectedPlan.identifier, purchaseMade.purchaserInfo)
      }
      this.setState({ loading: 'purchaseMade is done?' });
    } catch (e) {
      console.log('handleUpgradeNow.e', e)
      this.setState({ loading: false });
      if (!e.userCancelled) {
        // e should be e.message...
        Alert.alert(I18n.t('SubscribeScreen.error'), e);
      }
    }

Versions:
My podfile:
RNPurchases (2.0.0):

  • Purchases (~> 2.0.0)
    RNPurchases: 9bf26606edc02e95e9f569715989fb2361c7b41b
    Purchases: 17496bdab0d0fb678f5f647c4c7039bca3b8263c

yarn.lock
react-native-purchases@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/react-native-purchases/-/react-native-purchases-2.0.0.tgz#4f9746f79eff80e0531f2f7746b2878c7366d800"
integrity sha512-rGZIq3IIeLC5wRhoAtDQEWd2OYpUif1HbrGANFuPTyQcvxG7522hiS0hLNnUK1S7G0IOG1ogaN08FkhAlg1epg==

Using a number as user id when setting up throws error

Using a number as user id in Purchases.setup, throws an error (where 47 is a user ID):

JSON value '47' of type NSNumber cannot be converted to NSString

Converting the ID to string before passing it to setup works fine. A usage message should be included in the repo or should be shown by the library itself. The error message does not provide enough information to easily track down the error to this issue.

Retrieving In App Purchase in iOS returning empty Object

Hi Team, I am lost with iOS development. My in app purchase is already Ready to Submit , the productID is based on the app bundleID. I build test app from XCode, running from device and when I try getEntitlements, I get empty object. Is anywhere I am doing wrong ?

getEntitlements() is slow. Add caching?

Between Apple and RevenueCat's API, I found just calling setup and getEntitlements is slow (like 6-7s.)

My quick fix was to fetch that information every time the app loads and then cache it to disk so I can quickly show the pricing information to the user.

It would be great if the package could do the caching for us instead of needing to do it ourselves.

Crash related to 'Support for pending purchases must be enabled'

Output:

08-23 00:43:47.227 13649 13707 D [Purchases] - DEBUG: Debug logging enabled.
08-23 00:43:47.227 13649 13707 D [Purchases] - DEBUG: SDK Version - 2.3.1
08-23 00:43:47.227 13649 13707 D [Purchases] - DEBUG: Initial App User ID - null
08-23 00:43:47.227 13649 13707 D [Purchases] - DEBUG: Generated New App User ID - 80e4ba36-0b6d-4930-a3dd-fbad94af8699
08-23 00:43:47.227 13649 13707 D [Purchases] - DEBUG: Identifying App User ID: 80e4ba36-0b6d-4930-a3dd-fbad94af8699
08-23 00:43:47.227 13649 13707 D [Purchases] - DEBUG: Listener set
08-23 00:43:47.227 13649 13649 D AndroidRuntime: Shutting down VM
08-23 00:43:47.227 13649 13649 E AndroidRuntime: FATAL EXCEPTION: main
08-23 00:43:47.227 13649 13649 E AndroidRuntime: Process: [..removed...], PID: 13649
08-23 00:43:47.227 13649 13649 E AndroidRuntime: java.lang.IllegalArgumentException: Support for pending purchases must be enabled. Enable this by calling 'enablePendingPurchases()' on BillingClientBuilder.
08-23 00:43:47.227 13649 13649 E AndroidRuntime: 	at com.android.billingclient.api.BillingClient$Builder.build(BillingClient.java:309)
08-23 00:43:47.227 13649 13649 E AndroidRuntime: 	at com.revenuecat.purchases.BillingWrapper$ClientFactory.buildClient(BillingWrapper.kt:58)
08-23 00:43:47.227 13649 13649 E AndroidRuntime: 	at com.revenuecat.purchases.BillingWrapper$startConnection$1.run(BillingWrapper.kt:87)
08-23 00:43:47.227 13649 13649 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:739)
08-23 00:43:47.227 13649 13649 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:95)
08-23 00:43:47.227 13649 13649 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:158)
08-23 00:43:47.227 13649 13649 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7224)
08-23 00:43:47.227 13649 13649 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
08-23 00:43:47.227 13649 13649 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
08-23 00:43:47.227 13649 13649 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
08-23 00:43:47.227   866  2623 W ActivityManager:   Force finishing activity pl.keler.pytania.ppla/.MainActivity
08-23 00:43:47.227 13649 13707 D [Purchases] - DEBUG: Sending latest purchaser info to listener

getEntitlements return empty object

When i try getEntitlements() when returned object like this:
{ tattoos: { largePack: null, mediumPack: null, smallPack: null, } }
no title and other information

v2.3.3 - "File not found" error when importing header files into RNPurchases.m

I am having an issue stemming from when I upgraded the RNPurchases library to v2.3.3 from v2.2.2(which updated the Purchases library itself from v2.3.0 to 2.5.0).

In the "RNPurchases.m" file when trying to import these three header files: "RCPurchaserInfo+HybridAdditions.h", "RCEntitlement+HybridAdditions.h", "SKProduct+HybridAdditions.h", I am getting a "file not found" error. I've searched, and none of these files seem to exist within the RNPurchases package folder. In order to get it working I copied over files "RCPurchaserInfo+RNPurchases.h", "RCEntitlement+RNPurchases.h", and "SKProduct+RNPurchases.h" from v2.2.2 to the RNPurchases folder, and imported those within "RNPurchases.m" like they were in v2.2.2, instead of importing the header files ending with "+HybridAdditions.h". Obviously this is not a permanent solution, I just wanted to see if it would work, and thought it might give a little insight into the issue.

Should these files "RCPurchaserInfo+HybridAdditions.h", "RCEntitlement+HybridAdditions.h", "SKProduct+HybridAdditions.h" be in the package folder, or am I missing something here?

addPurchaserInfoUpdatedListener is not a function

Hi, here a RevenueCat customer.

I've just updated my project, I was using 1.2.0 of this library, and now I'm on 1.3.3

My surprise was that I'm getting an error when I try to run:

Purchases.addPurchaserInfoUpdatedListener((purchaserInfo, error) => {

_reactNativePurchases2.default.addPurchaserInfoUpdatedListener is not a function

I've unlinked and linked again react-native-purchases with iOS and Android, but no luck.

Can you help?

Thanks!

Can not make a purchase on iOS

  • "react-native": "0.54.2",
  • "react-native-purchases": "1.3.4",
  • os: iOS,
  • environment: iPhone7,
  • entitlements, offerings and products (appstore only) are set in dashboard at RevenueCat
  • signed out from device (YES)
  • created sandbox user (YES)
  • running on device (YES)

Code: Purchases.makePurchase(productId) nothing happened.

Actual behavior: after calling makePurchase nothing happens.

Expected behavior: after calling makePurchase sandboxed purchase screen must appear.

Can't install on Windows

When I try run 'npm install' there is error.
[email protected] fetch:ios:sdk: ./scripts/download-purchases-framework.sh 2.0.0

Full report:
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] fetch:ios:sdk: ./scripts/download-purchases-framework.sh 2.0.0ts/download-purchases-framework.sh 2.0.0
npm ERR! Exit status 1
npm ERR! :sdk script.
npm ERR! Failed at the [email protected] fetch:ioskely additional logging output above.:sdk script. did you mean to install?
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing,2019-04-10T09_23_20_860Z-debug.log did you mean to install? but none is installed. You must install peer dependencies yourself.
4 (node_modules\fsevents):
npm ERR! A complete log of this run can be found in: tform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! C:\Users\Yurhan\AppData\Roaming\npm-cache_logs\2019-04-10T09_23_20_860Z-debug.log
npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1npm ERR! [email protected] preinstall: npm run fetch:ios:sdknpm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Yurhan\AppData\Roaming\npm-cache_logs\2019-04-10T09_23_22_065Z-debug.log`

Exception thrown after calling Purchases.setup on react-native

After some struggling setting the project up (a mere npm install did not work, I had to manually copy the framework to the project root to make it work) I'm running in the following issue:

This exception is thrown after I call the setup method

  async setup(id) {
    try {
      this.purchases = await Purchases.setup('xxx', id);
      console.log(this.purchases)
    } catch (e) {
      console.error(e)
    }
  }
2018-08-03 11:28:28.271875+0200 vpnapp[79920:4614237] -[RCPurchaserInfo activeEntitlements]: unrecognized selector sent to instance 0x6040004263c0
2018-08-03 11:28:28.275429+0200 vpnapp[79920:4614237] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RCPurchaserInfo activeEntitlements]: unrecognized selector sent to instance 0x6040004263c0'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010e33112b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010c7def41 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010e3b2024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
	3   CoreFoundation                      0x000000010e2b3f78 ___forwarding___ + 1432
	4   CoreFoundation                      0x000000010e2b3958 _CF_forwarding_prep_0 + 120
	5   vpnapp                              0x000000010a89d716 -[RCPurchaserInfo(RNPurchases) dictionary] + 902
	6   vpnapp                              0x000000010a8a00f5 -[RNPurchases purchases:receivedUpdatedPurchaserInfo:] + 133
	7   vpnapp                              0x000000010a549c74 __34-[RCPurchases updatePurchaserInfo]_block_invoke + 148
	8   vpnapp                              0x000000010a544a02 -[RCBackend handle:withResponse:error:completion:] + 466
	9   vpnapp                              0x000000010a545ecf __55-[RCBackend getSubscriberDataWithAppUserID:completion:]_block_invoke + 143
	10  vpnapp                              0x000000010a547b06 __67-[RCHTTPClient performRequest:path:body:headers:completionHandler:]_block_invoke + 758
	11  CFNetwork                           0x000000010db0f454 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 19
	12  CFNetwork                           0x000000010db0ecad __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 147
	13  Foundation                          0x000000010c1f222f __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
	14  Foundation                          0x000000010c1f2091 -[NSBlockOperation main] + 68
	15  Foundation                          0x000000010c1f054e -[__NSOperationInternal _start:] + 778
	16  libdispatch.dylib                   0x00000001128ab33d _dispatch_client_callout + 8
	17  libdispatch.dylib                   0x00000001128b09f3 _dispatch_block_invoke_direct + 592
	18  libdispatch.dylib                   0x00000001128ab33d _dispatch_client_callout + 8
	19  libdispatch.dylib                   0x00000001128b09f3 _dispatch_block_invoke_direct + 592
	20  libdispatch.dylib                   0x00000001128b0783 dispatch_block_perform + 109
	21  Foundation                          0x000000010c1ec55c __NSOQSchedule_f + 342
	22  libdispatch.dylib                   0x00000001128ab33d _dispatch_client_callout + 8
	23  libdispatch.dylib                   0x00000001128b1754 _dispatch_continuation_pop + 967
	24  libdispatch.dylib                   0x00000001128afb85 _dispatch_async_redirect_invoke + 780
	25  libdispatch.dylib                   0x00000001128b7102 _dispatch_root_queue_drain + 772
	26  libdispatch.dylib                   0x00000001128b6da0 _dispatch_worker_thread3 + 132
	27  libsystem_pthread.dylib             0x0000000112d77169 _pthread_wqthread + 1387
	28  libsystem_pthread.dylib             0x0000000112d76be9 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

How to continue from here?

restoreTransactions doesn't emit an update to the listener

Unless I'm completely mistaken, restoreTransactions doesn't emit an event to the listener, even if the subscription status has been updated. This is most obvious while testing in the sandbox, since the subscription expires rather often.

I'm expecting any updates to the subscription status to emit an event.

Entitlements returning empty

Hello, this looks like a great product! However, I am having troubles setting up. I've followed the instructions on the README but running Purchases.getEntitlements() is always returning empty.

Also, should I be setting up the listeners inside the React component or outside? Some simple example code would be really helpful.

Thanks! :)

Our apps stopped working

We've been happily running "react-native-purchases": "^1.3.4", since some time now. Today I noticed that our apps are no longer working (with no modifications to the apps). Attempting to initiate a purchase does nothing. I will update when I find out what's broken.

Please don't break backwards compatibility.

Sandbox account infinite loop

I am experiencing this issue on iOS. Any suggestions on how to resolve this with the given RN-purchases js code? I am not very experienced in swift.

As such, you need to call finishTransaction: on the associated transaction to end the loop to resolve your issue. See TN2387 In-App Purchase Best Practices > Add a transaction queue observer at application launch and Finish the transaction for more information on how to prevent this issue.

I am not seeing how to call finishTransaction with the given react native purchases API.

AndroidX Support?

Getting a lot of Nullable related errors:

RNPurchasesModule.java:4: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;

etc

error: cannot find symbol class EntitlementInfo

Upon upgrading react-native-purchases from 2.2.1 to 2.4.1 it keeps giving this error when build on Android:

error: cannot find symbol class EntitlementInfo
error: cannot find symbol class EntitlementInfos

In Mappers.java
image

The SDK that Android Studio is fetching when build is com.revenuecat.purchases:purchases:2.2.2@aar instead of 2.4.0

I already cleaned npm cache with:
watchman watch-del-all && rm -rf node_modules/ && rm -rf $TMPDIR/react-* ~/.npm/ ~./rncache
Then
npm install

Versions:

  • react 16.8.3
  • react-native 0.59.8
  • react-native-purchases 2.4.1

screenshots/video demo

are there screenshots or a video of react-native-purchases? im specifically looking for what the popups/modals look like when making a purchase on ios

"Native module cannot be null" thrown when importing Purchases in javascript

I have followed the installation instructions and got the project to build successfully. Now, when I import Purchases in my javascript code I get the exception "Native module cannot be null".

screen shot 2018-10-04 at 18 49 30

Where revenueCatService.js:2 is where I have imported Purchases.

Clicking on <unknown> index.js:5:21 takes me to index.js in react-native-purchases:

screen shot 2018-10-04 at 18 50 39

System
Xcode 10
MacOS Mojave
React native 0.50.4

Cannot connect to itunes

Hello guys we are trying to implement an interchagable plan base for the user to upgrade/downgrade based on the number of groups that the user has.

so

this is the info of the codebase

"react": "16.4.1",
"react-native": "0.56.0",
"react-native-purchases": "2.1.2",

Issue:

Everytime that a user is planning to downgrade by erasing groups we are switching down the plan by setting makePurchases method to have the new value

we have a plan set as following
monthly1
monthly2
monthly3
monthly4
monthly5... and so on

example
FLOW
user purchases rights for one group > monthly1
upgrade to have one more > monthly2
downgrade to have only one over again > monthly1

considering this flow, last scenario is failing, and everytime there is an active subscription with bigger price and the user wants to downgrade his subscription the issue is arising.

Screen Shot 2019-06-05 at 9 15 45 AM

Screen Shot 2019-06-05 at 9 18 41 AM

So watching that pattern i replicated the same behavior by
doing the following in a test function
Purchases.makePurchase("monthly1"); SUCCESS
Purchases.makePurchase("monthly2"); SUCCESS
Purchases.makePurchase("monthly3"); SUCCESS
Purchases.makePurchase("monthly1"); FAILURE

Android crash on build

Hi team!
I got an error when trying to compile to apk.
I am using :
react-native-purchases": "^2.1.1

and the error I got is
incompatible types: WritableMap cannot be converted to Throwable
Error:Execution failed for task ':react-native-purchases:compileDebugJavaWithJavac'.

how can I fix this issue ?

Invalid Play Store credentials

Platform: Android
Version: 2.4.1
Testing: on Real device

When restoring purchases I get following error. What can go wrong?

Purchases.restoreTransactions()
        .then((purchaseInfo) => {
            if (containPurchase(purchaseInfo)) {
                return true
            }
            throw Error('No previous purchases found')
        })
        .catch(e => {
            console.log(JSON.stringify(e))
            throw e
        })
{
"framesToPop":1,
"nativeStackAndroid":[],
"userInfo": {
  "underlyingErrorMessage":"Invalid Play Store credentials.",
  "readable_error_code":"InvalidCredentialsError",
  "message":"There was a credentials issue. Check the underlying error for more details."
},
"code":"11"
}

I get the same error when purchasing subscription. Subscription is activated in Google Play(I do receive confirmation email).

To me it sounds like RevenueCat cannot confirm purchase. I have double checked that I have correct permissions in Google Play Console and that I have uploaded correct Service Account credentials JSON. I have also checked Google Play Package name as suggested here:
https://docs.revenuecat.com/discuss/5b95217206ca8a00031f0b93

2.4.1 pod install error (could not find compatible versions for pod "Purchases")

Upon installing as per the docs (yarn add react-native-purchases) I got the following error on pod install:

[!] CocoaPods could not find compatible versions for pod "Purchases":
  In Podfile:
    RNPurchases (from `../node_modules/react-native-purchases`) was resolved to 2.4.1, which depends on
      Purchases (~> 2.6.0)

None of your spec sources contain a spec satisfying the dependency: `Purchases (~> 2.6.0)`.

Versions:

  • react 16.8.6
  • react-native 0.60.5
  • react-native-purchases 2.4.1

Any ideas? And thanks - excited to try RevenueCat!

Crashes on newly init-ed RN project

repro:

react-native init PurchaseTest
cd PurchaseTest/
yarn add react-native-purchases
react-native link react-native-purchases

and then follow the 'Additional iOS Setup' section of this repo's README.

Starting the app causes it to start the metro bundler, load the splash screen on the simulator, and then crash. The error output to the xcode debug console (seen on the attached screenshot) says:

dyld: Library not loaded: @rpath/Purchases.framework/Purchases
  Referenced from: /Users/anthonygabriele/Library/Developer/CoreSimulator/Devices/EF75E6D3-2969-4BF5-B48E-D39BAE24C99B/data/Containers/Bundle/Application/4A66F92D-8E85-4CBD-871C-58C938056767/PurchaseTest.app/PurchaseTest
  Reason: image not found

Versions:

"react": "16.6.1",
"react-native": "0.57.7",
"react-native-purchases": "^1.5.1"

The latest collection of versions I can find that don't crash on startup are:

"react": "16.3.1",
"react-native": "^0.55.4",
"react-native-purchases": "^1.3.1",

screen shot 2018-12-10 at 12 23 54 pm

(Android) Error: There was a problem with the Play Store.

I am getting the below issue while trying to get the payment done on my sandbox test device. It goes to the payment page and then says the payment was successful but from Purchases i get the below error message.
Could you help me figure out where am I going wrong ?

Screenshot 2019-05-24 at 6 11 06 PM
I am using the following versions:
"react-native": "0.58.5",
"react-native-purchases": "^2.1.2",
implementation "com.google.android.gms:play-services-wallet:16.0.1",
my android settings are :
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
googlePlayServicesAuthVersion = "16.0.1"
and the following dependencies:
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.android.support:support-media-compat:28.0.0'
classpath 'com.google.android.gms:play-services-basement:16.0.1'

I am facing the same issue on iOS as well. below is the following error message i am getting:

'Error occurred while handling payment: ', { [Error: There was a problem with the App Store.]
framesToPop: 1,
code: '2',
domain: 'RCPurchasesErrorDomain',
userInfo:
{ NSUnderlyingError:
{ code: '0',
message: 'underlying error',
domain: 'SKErrorDomain',
userInfo: { NSLocalizedDescription: 'Cannot connect to iTunes Store' },
nativeStackIOS:
[ '0 fitlog 0x00000001050966a8 RCTJSErrorFromCodeMessageAndNSError + 156',
'1 fitlog 0x00000001050969cc RCTJSErrorFromCodeMessageAndNSError + 960',
'2 fitlog 0x000000010503d0e0 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.129 + 176',
'3 fitlog 0x00000001052f67fc -[RNPurchases rejectPromiseWithBlock:error:] + 272',
'4 fitlog 0x00000001052f4d64 __56-[RNPurchases makePurchase:oldSkus:type:resolve:reject:]_block_invoke + 200',
'5 Purchases 0x0000000106284908 __50-[RCPurchases storeKitWrapper:updatedTransaction:]_block_invoke + 168',
'6 Purchases 0x0000000106284c68 -[RCPurchases dispatch:] + 60',
'7 Purchases 0x0000000106284720 -[RCPurchases storeKitWrapper:updatedTransaction:] + 388',
'8 Purchases 0x00000001062864a8 -[RCStoreKitWrapper paymentQueue:updatedTransactions:] + 464',
'9 libdispatch.dylib 0x00000001063276f0 _dispatch_call_block_and_release + 24',
'10 libdispatch.dylib 0x0000000106328c74 _dispatch_client_callout + 16',
'11 libdispatch.dylib 0x00000001063366fc _dispatch_main_queue_callback_4CF + 1360',
'12 CoreFoundation 0x0000000228afdec0 + 12',
'13 CoreFoundation 0x0000000228af8df8 + 1924',
'14 CoreFoundation 0x0000000228af8354 CFRunLoopRunSpecific + 436',
'15 GraphicsServices 0x000000022acf879c GSEventRunModal + 104',
'16 UIKitCore 0x0000000254f6bb68 UIApplicationMain + 212',
'17 fitlog 0x0000000104f25a20 main + 124',
'18 libdyld.dylib 0x00000002285be8e0 + 4' ] },
NSLocalizedDescription: 'There was a problem with the App Store.',
readable_error_code: 'STORE_PROBLEM' },
nativeStackIOS:
[ '0 fitlog 0x00000001050966a8 RCTJSErrorFromCodeMessageAndNSError + 156',
'1 fitlog 0x000000010503d0e0 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.129 + 176',
'2 fitlog 0x00000001052f67fc -[RNPurchases rejectPromiseWithBlock:error:] + 272',
'3 fitlog 0x00000001052f4d64 __56-[RNPurchases makePurchase:oldSkus:type:resolve:reject:]_block_invoke + 200',
'4 Purchases 0x0000000106284908 __50-[RCPurchases storeKitWrapper:updatedTransaction:]_block_invoke + 168',
'5 Purchases 0x0000000106284c68 -[RCPurchases dispatch:] + 60',
'6 Purchases 0x0000000106284720 -[RCPurchases storeKitWrapper:updatedTransaction:] + 388',
'7 Purchases 0x00000001062864a8 -[RCStoreKitWrapper paymentQueue:updatedTransactions:] + 464',
'8 libdispatch.dylib 0x00000001063276f0 _dispatch_call_block_and_release + 24',
'9 libdispatch.dylib 0x0000000106328c74 _dispatch_client_callout + 16',
'10 libdispatch.dylib 0x00000001063366fc _dispatch_main_queue_callback_4CF + 1360',
'11 CoreFoundation 0x0000000228afdec0 + 12',
'12 CoreFoundation 0x0000000228af8df8 + 1924',
'13 CoreFoundation 0x0000000228af8354 CFRunLoopRunSpecific + 436',
'14 GraphicsServices 0x000000022acf879c GSEventRunModal + 104',
'15 UIKitCore 0x0000000254f6bb68 UIApplicationMain + 212',
'16 fitlog 0x0000000104f25a20 main + 124',
'17 libdyld.dylib 0x00000002285be8e0 + 4' ],
userCancelled: false,
line: 13307,
column: 26,
sourceURL: 'http://192.168.1.8:8081/index.bundle?platform=ios&dev=true&minify=false' }

null is not an object

Hi,

I'm fairly new to React Native, so I probably don't understand how all of this should work.

I'm using Expo to hot reload on an external android device (and because it was the proposed version on the React Native website).

So I'm trying to build a subscription system on an app.

So i wrote in my App.js file the following:

componentWillMount() {
        Purchases.setDebugLogsEnabled(true);
        Purchases.setup('***', null);
    }

But the app crashes with the following lines:

Uncaught Error: TypeError: null is not an object (evaluating 's.setDebugLogsEnabled')

This error is located at:
  in v
  in v
  in RCTView
  in RCTView
  in c

(These lines only appear on the device, not in the Metro Bundler nor in the terminal)

Purchases.getEntitlements() not resolving on android

Steps to reproduce:

  • react-native init TestApp
  • cd TestApp
  • yarn add react-native-purchases
  • react-native link react-native-purchases
  • Add the following to App.js:
async componentDidMount() {
  console.log(1);
  await Purchases.setup(REVENUE_CAT_KEY, '123');
  console.log(2);
  await Purchases.getEntitlements();
  console.log(3);
}
  • react-native run-android

Logs 1 and 2, but no 3 ๐Ÿ˜•

Purchasing a Subscription causing app crash on Android device

RN Version: 0.57.4
RN-Purchases version: 1.5.2
Device: Samsung Galaxy S8
Device OS Version: 8.0.0
Android minSdkVersion: 21
Android targetSdkVersion: 26
Android compileSdkVersion: 27

Expected behavior: When trying to buy already bought subscription, there should be a message telling you that you already own that subscription. Users are then prompted with a button to close a native dialog which closes dialog.
Actual behavior: When trying to buy already bought subscription, there is a message telling you that you already own that subscription. Users are then prompted with a button to close a native dialog which causes application to crash.
Error message: Cannot read property 'activeEntitlements' of undefined

Unnecessary debugger key

There is an unnecessary debugger; key in the removePurchaseListener. I can not see the key on the repository but it come with npm package.

image

Purchases.getEntitlements() contains only entitlements info

  • "react-native": "0.54.2",
  • "react-native-purchases": "1.3.4",
  • os: iOS,
  • environment: simulator iphone7,
  • entitlements, offerings and products (appstore only) set in dashboard at RevenueCat

Code:
const entitlements = await Purchases.getEntitlements();
console.log(entitlements)

Expected behavior:
entitlements object should be an object containing entitlements -> offerings -> products

Actual behavior:
entitlements contains only entitlements

UPDATE:
Just checked on device (iPhone7) behavior is the same

Add introductory pricing and period info

Hey guys! Discussed this with Jacob via the chat, but adding an issue here as well.

I'd love to use RevenueCat with RN in an existing app (iOS / Android) and migrate subscribers.

It seems this library is missing some essential info about the offerings, namely:

  1. Introductory pricing and periods / free trial period
  2. Customer's eligibility for the introductory pricing / free trial
  3. Subscription periods where available (iOS 11+)

The use-case here is showing a correct "Activate free trial" button when user is eligible for a free trial, instead of eg. "Buy 3 months for ...", as well as displaying subscription terms (period, pricing, free trial info etc.) on the purchase screen as required by Apple during review.

Thanks,
Mattias

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.