Open zhmul opened 4 years ago
Hey @zhmul have you been able to figure this out? I'm having a similar issue where this delegate method is also not called for me. Same code implementation.
Hi @MiraEs! The only way that I found for this to work is call performDataEncryption
in the main thread. Only then the delegate method is called back.
Hi @zhmul I'm doing something like below but not seeing the delegate function called - any ideas or fixes from what you see below that would help me hit the delegate method?
@objc(performPaymentDataEncryption:withRejector:)
func performPaymentDataEncryption(resolve:@escaping RCTPromiseResolveBlock, reject:@escaping RCTPromiseRejectBlock) -> Void {
self.resolve = resolve
self.reject = reject
let transactionObject = InAppSDKTransactionObject()
transactionObject.billTo = self.billingData
transactionObject.cardData = self.cardData
transactionObject.merchant = self.merchantData
InAppSDKSettings.sharedInstance()?.inAppSDKEnvironment = INAPPSDK_ENV_TEST
InAppSDKSettings.sharedInstance()?.enableLog = true
DispatchQueue.main.async {
let result = InAppSDKGateway.sharedInstance()?.performPaymentDataEncryption(transactionObject, with: self) ?? false
if (result) {
print("InAppSDK: Request Accepted. Expect the response in the delegate method.")
} else {
print("InAppSDK: Request NOT Accepted. Verify the input values if any one is invalid.");
}
}
}
func encryptPaymentDataServiceFinishedWithGatewayResponse(paramResponseData: InAppSDKGatewayResponse, paramError: InAppSDKError) -> Void {
if (self.resolve != nil) {
self.resolve!(paramResponseData)
}
}
btw my class signature is:
class AwesomeModule: NSObject, InAppSDKGatewayDelegate {
Hi @crherman7! I'm doing everything in the main thread, in the same closure: creating the instances of InAppSDKMerchant
, InAppSDKCardData
, InAppSDKTransactionObject
and calling InAppSDKGateway
's performPaymentDataEncryption
. Only then, I got a delegate call.
Try moving all code lines inside the dispatch queue block.
@zhmul thank you so much! In the end encryptPaymentDataServiceFinishedWithGatewayResponse
is actually supposed to be encryptPaymentDataServiceFinished
but since it's optional xcode never gave me the warning to rename until I put the @objc
header on there. In the end you did have the in the original issue description 💯 thanks again!
iOS SDK Version:
1.0.3
iOS Version:13.2.2
Expected behavior:
When executing this (given that
self
conforms toInAppSDKGatewayDelegate
):The expected behavior would be:
success
istrue
encryptPaymentDataServiceFinished(with:withError:)
is called, with the expected parameters.Current behavior:
If
performDataEncryption
is not executed in the main thread, this happens:success
istrue
encryptPaymentDataServiceFinished(with:withError:)
is never called.