The root problem is that it SkPaymentQueue.defaultQueue().addPayment()doesn't allow you to pass a callback function, and there is no way to pass a function at runtime (which I know) to SKPaymentTransactionObserver. I use the React-native version 0.28to create a module that allows me to make purchases in the application, however I would like to call the Javascript function after completing the purchase in the application.
So I was going to keep the callback link RCTResponseSenderBlockin the class and reference it in SKPaymentTransactionObserver. However, I do not know how to access a function in Swift.
I tried to make the following variable
weak var purchaseCallback: RCTResponseSenderBlock = nil
at the top of the class so that I can install it and refer to it later; however, Swift complains about the following:
Nil cannot initialize specified type 'RCTResponseSenderBlock'
If there is a way to handle function references and / or a better way to make a callback, I would appreciate help!
source
share