React-native-iap: Promoted product event not raised on older devices

Created on 31 Jan 2019  路  1Comment  路  Source: dooboolab/react-native-iap

Version of react-native-iap

Master

Version of react-native

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

iOS only.

Expected behavior

After launching the app from a terminated state via an App Store promoted product, the iap-promoted-product event is received immediately.

Actual behavior

The iap-promoted-product is never received.

Tested environment (Emulator? Real Device?)

Real device (iPhone 5s running iOS 11.0.3). Confirmed with a colleague using an iPhone 6S.

Steps to reproduce the behavior

  • Add a listener for the iap-promoted-product event in the React Native constructor of the app鈥檚 entry point (for me, this is App.js).
  • Launch the app.
  • Terminate the app.
  • Simulate purchasing a promoted product.

Notes

This is happening because of a race condition on older/slower devices where the React Native bridge is not creating an instance of RNIapIos before iOS invokes the -[paymentQueue:shouldAddStorePayment:forProduct:] delegate of SKPaymentTransactionObserver.

The solution is to create a singleton that only responds to-[paymentQueue:shouldAddStorePayment:forProduct:] and initialise the singleton _as early as possible_ in -[application:didFinishLaunchingWithOptions:]. RNIapIos will be a delegate to this singleton and will emit the iap-promoted-product event when appropriate.

I already have this working and I鈥檓 happy for this issue to be assigned to me. I just need some guidance from @hyochan on the naming convention I should follow for this new class. Once I have that information, I can open a pull request with my implementation. I鈥檇 like to suggest IAPPromotionObserver as a potential class name.

馃悰 bug 馃摫 iOS

Most helpful comment

I am very pleased with your work and all your contributions so far.
I think what you've suggested is already an excellent option IAPPromotionObserver as we've discussed this in earlier PR, no-ops on android would be fine.

Thank you again for your great work.

>All comments

I am very pleased with your work and all your contributions so far.
I think what you've suggested is already an excellent option IAPPromotionObserver as we've discussed this in earlier PR, no-ops on android would be fine.

Thank you again for your great work.

Was this page helpful?
0 / 5 - 0 ratings