dooboolab-community / react-native-iap

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

Value of type 'Transaction' has no member 'environment' in xcode #2484

Open Dhvani-Impero opened 1 year ago

Dhvani-Impero commented 1 year ago

Value of type 'Transaction' has no member 'environment'

usmanabid94 commented 1 year ago

check this link: https://usmanabid477.medium.com/in-app-purchase-integration-in-react-native-app-96c0acd13649

Abhishek1792 commented 1 year ago

Facing same problem

shivanitp commented 1 year ago

did anyone get the solution?

Abhishek1792 commented 1 year ago

did anyone get the solution?

what is your xcode version ?

shivanitp commented 1 year ago

xcode version 13.3.1

Abhishek1792 commented 1 year ago

you have to update macos and xcode else check in down version

shivanitp commented 1 year ago

ok thanks, I will update it

usmanabid94 commented 1 year ago

Please update if there is any success on this.

Abhishek1792 commented 1 year ago

The functionality has been verified on both Xcode versions 14.2 and 14.3.1, and it is working as expected without any issues.

usmanabid94 commented 1 year ago

@Abhishek1792 Can you share any sample for example ?

Abhishek1792 commented 1 year ago

Screenshot 2023-07-24 at 1 43 11 PM

usmanabid94 commented 1 year ago

any update on this ??

shivanitp commented 1 year ago

It works on Xcode versions 14.2 and 14.3.1, and while I found a solution for the older version, it isn't the right method to use.

This code only needs a few comments to function correctly and error-free.

// if #available(iOS 16.0, tvOS 16.0, *) { // environment = t.environment.rawValue // } else { // let env = t.environmentStringRepresentation // if ["Production", "Sandbox", "Xcode"].contains(env) { // environment = env // } // }

SamiChab commented 1 year ago

I have an older version of XCode (13.2.1), and I had to comment out a few lines in node_modules/react-native-iap/ios/IapSerializationUtils.swift to make it work :

@available(iOS 15.0, tvOS 15.0, *)
func serialize(_ t: Transaction) -> [String: Any?] {
    // comment the next 10 lines of code 
    // var environment: String?

    // if #available(iOS 16.0, tvOS 16.0, *) {
    //    environment = t.environment.rawValue
    // } else {
    //    let env = t.environmentStringRepresentation
    //    if ["Production", "Sandbox", "Xcode"].contains(env) {
    //        environment = env
    //    }
    // }

    return ["appAccountToken": t.appAccountToken?.uuidString,
            "appBundleID": t.appBundleID,
            "debugDescription": serializeDebug(t.debugDescription),
            "deviceVerification": t.deviceVerification,
            "deviceVerificationNonce": t.deviceVerificationNonce.uuidString,
            "expirationDate": t.expirationDate?.millisecondsSince1970,
            // "environment": environment, <-- comment this line
            ...

Don't forget to make a patch to keep your changes: npx patch-package react-native-iap

usmanabid94 commented 1 year ago

@SamiChab is there any release or update in the react-native-iap on this ?