yevheniionipko / react-native-apple-payment

Apple Pay for React Native
MIT License
15 stars 9 forks source link

Module Apple Pay requires main queue #1

Closed designervoid closed 3 years ago

designervoid commented 3 years ago

installed the package and shows this warning: image

designervoid commented 3 years ago

with code in App.tsx:

import * as React from 'react';
import { StyleSheet, View, Text, TouchableOpacity } from 'react-native';
import ApplePay, { MethodData, DetailsData, TransactionIdentifier } from "react-native-apple-payment";

export default function App() {
  return (
    <View style={styles.container}>
      <TouchableOpacity
        onPress={async () => {
          const method: MethodData = {
            countryCode: 'UA',
            currencyCode: 'UAH',
            merchantIdentifier: 'merchant.com.onipko',
            supportedNetworks: ['Visa', 'MasterCard', 'AmEx'],
          };

          const details: DetailsData = {
            total: {
              label: 'Shoe-shop',
              amount: 10,
            },
          };

          const payment = new ApplePay(method, details);

          const canMakePayment: boolean = await payment.canMakePayments()

          if (canMakePayment) {
            const paymentResponse: TransactionIdentifier = await payment.initApplePay();
            console.log(paymentResponse);
          }
        }}
      >
        <Text>Apple Pay</Text>
      </TouchableOpacity>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});
yevheniionipko commented 3 years ago

Hi, simulator cannot send you a paymentResponse https://developer.apple.com/forums/thread/44972

About this warning, im not overrides method "init" in that library

(optional for examples) You can run "yarn bootstrap" in console, maybe problem in dependencies...

and can you say what a problem you have? Did you get PaymentResponse?

designervoid commented 3 years ago

@yevheniionipko we decided to use web view in our application, but thanks for the feedback