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

undefined is not an object (evaluating 'RNIapIos.canMakePayments') && [Unhandled promise rejection: ReferenceError: Can't find variable: products] #364

Closed
Jazzykhan opened this issue Jan 15, 2019 · 7 comments
Labels
🙏 help wanted Extra attention is needed

Comments

@Jazzykhan
Copy link

Version of react-native-iap

latest 2.4.0-beta6

Version of react-native

16.3.1

Platforms you faced the error (IOS or Android or both?)

IOS

Expected behavior

Get items details or something else

Actual behavior

[19:38:36] itemSkus : Array [
[19:38:36] "Get_SlickFit_Workout_Plans_Great",
[19:38:36] ]

[19:38:41] >>>>>>>>>>>>>>>>>>>>> undefined is not an object (evaluating 'RNIapIos.canMakePayments')

  • node_modules\react-native\Libraries\ReactNative\YellowBox.js:80:15 in warn
  • node_modules\expo\src\Expo.js:25:41 in warn
  • application\screens\Payment.js:39:25 in componentDidMount$
  • node_modules\regenerator-runtime\runtime.js:62:44 in tryCatch
  • node_modules\regenerator-runtime\runtime.js:296:30 in invoke
  • ... 13 more stack frames from framework internals

[19:38:45] [Unhandled promise rejection: ReferenceError: Can't find variable: products]

  • application\screens\Payment.js:43:4 in componentDidMount$
  • node_modules\regenerator-runtime\runtime.js:62:44 in tryCatch
  • node_modules\regenerator-runtime\runtime.js:296:30 in invoke
  • ... 13 more stack frames from framework internals

Tested environment (Emulator? Real Device?)

Real device with Expo app installed and testing on localhost.

Steps to reproduce the behavior

Code below:
import React, { Component } from 'react';
var styles = require('../../assets/files/Styles');
import { Alert, Dimensions, Image, TouchableOpacity, ScrollView, Linking, Platform } from 'react-native';
import { Container, Body, Header, Input, Item, Left, Text, Title, Right, View, Button, Toast, Thumbnail, Grid, Row } from 'native-base';
import Strings from '../utils/Strings';
import { Constants, Location, Permissions, ImagePicker } from 'expo';
import * as RNIap from 'react-native-iap';

const itemSkus = Platform.select({
ios: [
'Get_SlickFit_Workout_Plans_Great'
],
android: [
'Get_SlickFit_Workout_Plans_Great'
]
});

var { width, height } = Dimensions.get('window');

export default class Register extends Component {
static navigationOptions = {
title: ${Strings.ST125},
};
constructor() {
super();

    this.state = {
        receipt: null
    };
}

async componentDidMount() {
try {
await RNIap.initConnection();
const products = await RNIap.getProducts(itemSkus);
// this.setState({ items });
Alert.alert("Successfull")
} catch(err) {
console.warn(">>>>>>>>>>>>>>>>>>>>> "+err.message);
Alert.alert(err.message);

		 console.log("itemSkus : ", itemSkus);
		 console.log('Subscriptions', products);
      }
}

Payment = async() =>{
    RNIap.buyProduct('Get_SlickFit_Workout_Plans_Great').then(purchase => {
        this.setState({
         receipt: purchase.transactionReceipt
        });
        Alert.alert("Receipt------------" + this.state.receipt)
       // handle success of purchase product
       }).catch((error) => {
        Alert.alert("...................."+error.message);
       })
}



componentWillUnmount() {
    RNIap.endConnection();
  }


render() {

    return (
        <Container style={{ backgroundColor: '#fff' }}>
            <Grid>

                <Row style={{ flexDirection: 'column', justifyContent: 'center', alignItems: 'center', backgroundColor: '#FFF', height: height * 0.30, padding: 30, paddingBottom: 0 }}>
                    <Image
                        source={require('../../assets/images/logo_dark.png')}
                        style={{ flex: 1, width: 130, height: 130 }}
                        resizeMode='contain' />
                </Row>

            </Grid>
            <Button block info
                onPress={this.Payment}
                >
                <Text>{Strings.ST125}</Text>
            </Button>
        </Container>
    )
}

}

@hyochan
Copy link
Member

hyochan commented Jan 15, 2019

I think the module is not linked properly to your project. Please unlink and link again or do manual linking if you keep facing this.

@hyochan hyochan closed this as completed Jan 15, 2019
@hyochan hyochan added the 🙏 help wanted Extra attention is needed label Jan 15, 2019
@Jazzykhan
Copy link
Author

this code is correct?
thanks

@Jazzykhan
Copy link
Author

how do i do that can you please guide?
thanks

@Jazzykhan
Copy link
Author

Sir i can pay a small amount please help me.
thanks
i have unlinked and linked again but no help.
thanks

@hyochan
Copy link
Member

hyochan commented Jan 16, 2019

@Coinizy1 Please try manual installation.

@Jazzykhan
Copy link
Author

Jazzykhan commented Jan 16, 2019 via email

@hyochan
Copy link
Member

hyochan commented Jan 16, 2019

That question should be asked to expo. This thread might help you too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙏 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants