dooboolab-community / react-native-iap

In App Purchase module for React Native!
https://react-native-iap.dooboolab.com
MIT License
2.78k stars 634 forks source link

STOREKIT2_MODE getSubscriptions Error #2607

Closed isnolan closed 8 months ago

isnolan commented 9 months ago

Please use the Discussion board if you want to get some help. Please use issues to report bugs.

Description When use STOREKIT2_MODE getSubscriptions, catch an error for :

Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'ios' of undefined
TypeError: Cannot read property 'ios' of undefined
    at subscriptionSk2Map (http://192.168.2.8:8081/node_modules/react-native-iap/src/types/appleSk2.bundle//&platform=ios&hot=false&lazy=true&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:35:39)
    at map (native)
    at ?anon_0_ (http://192.168.2.8:8081/index.bundle//&platform=ios&dev=true&hot=false&lazy=true:275666:59)
    at next (native)
    at asyncGeneratorStep (http://192.168.2.8:8081/index.bundle//&platform=ios&dev=true&hot=false&lazy=true:6072:26)
    at _next (http://192.168.2.8:8081/index.bundle//&platform=ios&dev=true&hot=false&lazy=true:6091:29)
    at tryCallOne (/Users/distiller/react-native/packages/react-native/sdks/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:53:16)
    at anonymous (/Users/distiller/react-native/packages/react-native/sdks/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:139:27)
    at apply (native)
    at anonymous (http://192.168.2.8:8081/index.bundle//&platform=ios&dev=true&hot=false&lazy=true:39695:26)
    at _callTimer (http://192.168.2.8:8081/index.bundle//&platform=ios&dev=true&hot=false&lazy=true:39574:17)
    at _callReactNativeMicrotasksPass (http://192.168.2.8:8081/index.bundle//&platform=ios&dev=true&hot=false&lazy=true:39619:17)
    at callReactNativeMicrotasks (http://192.168.2.8:8081/index.bundle//&platform=ios&dev=true&hot=false&lazy=true:39825:44)
    at __callReactNativeMicrotasks (http://192.168.2.8:8081/index.bundle//&platform=ios&dev=true&hot=false&lazy=true:3677:46)
    at anonymous (http://192.168.2.8:8081/index.bundle//&platform=ios&dev=true&hot=false&lazy=true:3451:45)
    at __guard (http://192.168.2.8:8081/index.bundle//&platform=ios&dev=true&hot=false&lazy=true:3650:15)
    at flushedQueue (http://192.168.2.8:8081/index.bundle//&platform=ios&dev=true&hot=false&lazy=true:3450:21)
    at invokeCallbackAndReturnFlushedQueue (http://192.168.2.8:8081/index.bundle//&platform=ios&dev=true&hot=false&lazy=true:3444:33)

Expected Behavior Got subscriptions successful

Screenshots

Environment:

isnolan commented 9 months ago

Trace the code to find the cause of the problem:

1、The problem occurs in subscriptionSk2Map funcition , appleSk2.ts, SubscriptionPlatform is undefined. 2、The reason is that there is a problem with the way the SubscriptionPlatform object is referenced.

import {SubscriptionPlatform} from '.';

3、we are change it , will be ok.

import {SubscriptionPlatform} from './';