From c9d11ce05019c7ef99542fd387edfd2e9788e763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A6=8A=E5=8E=9F=E6=98=8C=E5=BD=A6?= Date: Wed, 4 Dec 2024 13:27:21 +0900 Subject: [PATCH] fix(identity): change how to get icon assets --- .../StripeIdentityPlugin/StripeIdentity.swift | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/packages/identity/ios/Sources/StripeIdentityPlugin/StripeIdentity.swift b/packages/identity/ios/Sources/StripeIdentityPlugin/StripeIdentity.swift index 98b16151..a3726503 100644 --- a/packages/identity/ios/Sources/StripeIdentityPlugin/StripeIdentity.swift +++ b/packages/identity/ios/Sources/StripeIdentityPlugin/StripeIdentity.swift @@ -21,18 +21,28 @@ import StripeIdentity return } - // Configure a square brand logo. Recommended image size is 32 x 32 points. - let configuration = IdentityVerificationSheet.Configuration( - brandLogo: UIImage(named: "AppIcon")! - ) - self.identityVerificationSheet = IdentityVerificationSheet( - verificationSessionId: verificationId!, - ephemeralKeySecret: ephemeralKeySecret!, - configuration: configuration - ) + if let iconFileName = Bundle.main.object(forInfoDictionaryKey: "CFBundleIcons") as? [String: Any], + let primaryIcon = iconFileName["CFBundlePrimaryIcon"] as? [String: Any], + let iconFilesArray = primaryIcon["CFBundleIconFiles"] as? [String], + let fileName = iconFilesArray.first { - self.plugin?.notifyListeners(IdentityVerificationSheetEvents.Loaded.rawValue, data: [:]) - call.resolve([:]) + let configuration = IdentityVerificationSheet.Configuration( + brandLogo: UIImage(named: fileName) ?? UIImage() + ) + + self.identityVerificationSheet = IdentityVerificationSheet( + verificationSessionId: verificationId!, + ephemeralKeySecret: ephemeralKeySecret!, + configuration: configuration + ) + + self.plugin?.notifyListeners(IdentityVerificationSheetEvents.Loaded.rawValue, data: [:]) + call.resolve([:]) + } else { + let errorText = "CFBundleIcons or CFBundlePrimaryIcon or CFBundleIconFiles is not found. You should check ios image assets" + self.plugin?.notifyListeners(IdentityVerificationSheetEvents.FailedToLoad.rawValue, data: ["message": errorText]) + call.reject(errorText) + } } func present(_ call: CAPPluginCall) {