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

IOS Promotional Offers #27

Open
jlafosse opened this issue Mar 27, 2025 · 1 comment
Open

IOS Promotional Offers #27

jlafosse opened this issue Mar 27, 2025 · 1 comment
Labels
🐛 bug Something isn't working 📱 iOS Related to iOS 🍚 need contribution Need PR

Comments

@jlafosse
Copy link

Hi. Will this patch/fix from react-native-iap need to be applied to expo-iap? I looked in the ExpoIAPModule.swift file and it appears it still uses the same signature as the RNI file does.

hyochan/react-native-iap#2715 (comment)

https://github.com/hyochan/expo-iap/blob/main/ios/ExpoIapModule.swift#L324C29-L324C42

Excited about this project!

Thanks.

@hyochan
Copy link
Owner

hyochan commented Mar 28, 2025

@jlafosse Hi there! Thanks for your enthusiasm about expo-iap—we’re thrilled to have you interested in the project!

Regarding your question about whether the patch from react-native-iap#2715 needs to be applied to expo-iap: you’ve spotted a key similarity! In that react-native-iap issue, the proposed fix changes the signature parsing from signature.data(using: .utf8) to Data(base64Encoded: signature) in RNIapIosSk2.swift to handle base64-encoded signatures correctly, aligning with Apple’s documentation (Generating a Signature for Promotional Offers).

Checking the current ExpoIapModule.swift in expo-iap (line 324), it still uses signature.data(using: .utf8), which assumes a UTF-8 string rather than a base64-encoded string. This could indeed cause the "Unable to Purchase" error you’re encountering when passing a base64-encoded signature, as it’s not being decoded properly before being passed to StoreKit.

Given that:

  • Apple’s documentation and sample code expect the signature to be base64-encoded.
  • The react-native-iap discussion identifies this as the fix (though it doesn’t seem to have a merged PR yet).
  • expo-iap uses the same outdated signature handling.

It looks like this patch should be applied to expo-iap to support promotional offer purchases correctly. The change would be:

// Current line
let signature = signature.data(using: .utf8)

// Proposed fix
let signature = Data(base64Encoded: signature)

Since you’ve pinpointed this, I’d encourage you to submit a Pull Request (PR) to the expo-iap repository with this fix! Here’s how:

  1. Fork the expo-iap repo: https://github.com/hyochan/expo-iap.
  2. Update ExpoIapModule.swift at line 324 with the base64 decoding.
  3. Test it with your promotional offer setup (using a base64-encoded signature).
  4. Submit a PR, referencing react-native-iap#2715 and your findings.

This would be a great contribution to ensure expo-iap handles Apple promotional offers properly. Bonus points: since react-native-iap hasn’t merged this fix yet, submitting a similar PR there (https://github.com/hyochan/react-native-iap) would benefit both projects and the wider community! If you’re not up for submitting PRs yourself, I’d be happy to draft them based on your feedback—just let me know!

Can’t wait to see this progress—thanks for diving into this!

@hyochan hyochan added 🍚 need contribution Need PR 🐛 bug Something isn't working 📱 iOS Related to iOS labels Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 📱 iOS Related to iOS 🍚 need contribution Need PR
Projects
None yet
Development

No branches or pull requests

2 participants