Question

ERROR IN REVENUE CAT SDK SETUP in APP.JS

  • 24 May 2024
  • 2 replies
  • 19 views

Badge +1


I am trying to integrate Revenue cat in my React native android project but cannot get rid of this error 
[TypeError: Cannot read property 'setupPurchases' of null]
please provide me steps to solve this error as i have gone through all the above steps read articles watched videos implemented example and in every thing this error is common please help on this @React native team , @ Revenue cat community


This post has been closed for comments

2 replies

Badge +1

From couple of weeks i am struggling to solve this error  with no luck followed all the steps from documentation , to youtube tutorial but nothing is working kindly help to resolve this error

Userlevel 2
Badge +4

Hi @communityhelper! setupPurchases is a deprecated method; please use configure instead. Here’s the relevant snippet from our documentation:

import { Platform } from 'react-native';

//...

export default class App extends React.Component {

componentDidMount() {
Purchases.setLogLevel(Purchases.LOG_LEVEL.DEBUG);

if (Platform.OS === 'ios') {
await Purchases.configure({ apiKey: <public_apple_api_key> });
} else if (Platform.OS === 'android') {
await Purchases.configure({ apiKey: <public_google_api_key> });

// OR: if building for Amazon, be sure to follow the installation instructions then:
await Purchases.configure({ apiKey: <public_amazon_api_key>, useAmazon: true });
}

}
}