diff --git a/FirebaseAuth/CHANGELOG.md b/FirebaseAuth/CHANGELOG.md index e781526007c..9a72b11dabc 100644 --- a/FirebaseAuth/CHANGELOG.md +++ b/FirebaseAuth/CHANGELOG.md @@ -1,6 +1,7 @@ # 11.2.0 - [Fixed] Fixed crashes that could occur in Swift continuation blocks running in the Xcode 16 betas. (#13480) +- [Fixed] Fixed Phone Auth via Sandbox APNS tokens that broke in 11.0.0. (#13479) # 11.1.0 - [fixed] Fixed `Swift.error` conformance for `AuthErrorCode`. (#13430) diff --git a/FirebaseAuth/Sources/Swift/Backend/VerifyClientRequest.swift b/FirebaseAuth/Sources/Swift/Backend/VerifyClientRequest.swift index dbf11784206..892e0cbd4c1 100644 --- a/FirebaseAuth/Sources/Swift/Backend/VerifyClientRequest.swift +++ b/FirebaseAuth/Sources/Swift/Backend/VerifyClientRequest.swift @@ -32,7 +32,9 @@ class VerifyClientRequest: IdentityToolkitRequest, AuthRPCRequest { if let appToken = appToken { postBody[Self.appTokenKey] = appToken } - postBody[Self.isSandboxKey] = isSandbox + if isSandbox { + postBody[Self.isSandboxKey] = true + } return postBody } @@ -42,11 +44,10 @@ class VerifyClientRequest: IdentityToolkitRequest, AuthRPCRequest { /// The flag that denotes if the appToken pertains to Sandbox or Production. private(set) var isSandbox: Bool - init(withAppToken: String?, + init(withAppToken appToken: String?, isSandbox: Bool, requestConfiguration: AuthRequestConfiguration) { - appToken = withAppToken - self.isSandbox = isSandbox + self.appToken = appToken self.isSandbox = isSandbox super.init(endpoint: Self.verifyClientEndpoint, requestConfiguration: requestConfiguration) } diff --git a/FirebaseAuth/Sources/Swift/SystemService/AuthAPNSTokenManager.swift b/FirebaseAuth/Sources/Swift/SystemService/AuthAPNSTokenManager.swift index 49521cae813..006efc5ddc1 100644 --- a/FirebaseAuth/Sources/Swift/SystemService/AuthAPNSTokenManager.swift +++ b/FirebaseAuth/Sources/Swift/SystemService/AuthAPNSTokenManager.swift @@ -143,18 +143,11 @@ } // TODO: resolve https://github.com/firebase/firebase-ios-sdk/issues/10921 - if Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt" { - // Distributed via TestFlight - return defaultAppTypeProd - } + // to support TestFlight - let path = Bundle.main.bundlePath + "embedded.mobileprovision" - guard let url = URL(string: path) else { - AuthLog.logInfo(code: "I-AUT000007", message: "\(path) does not exist") - return defaultAppTypeProd - } + let path = Bundle.main.bundlePath + "/" + "embedded.mobileprovision" do { - let profileData = try Data(contentsOf: url) + let profileData = try NSData(contentsOfFile: path) as Data // The "embedded.mobileprovision" sometimes contains characters with value 0, which signals // the end of a c-string and halts the ASCII parser, or with value > 127, which violates @@ -177,7 +170,7 @@ let scanner = Scanner(string: embeddedProfile) if scanner.scanUpToString(""), + guard let plistContents = scanner.scanUpToString("")?.appending(""), let data = plistContents.data(using: .utf8) else { return defaultAppTypeProd } @@ -194,7 +187,8 @@ message: "Provisioning profile has specifically provisioned devices, " + "most likely a Dev profile.") } - guard let apsEnvironment = plistMap["Entitlements.aps-environment"] as? String else { + guard let entitlements = plistMap["Entitlements"] as? [String: Any], + let apsEnvironment = entitlements["aps-environment"] as? String else { AuthLog.logInfo(code: "I-AUT000013", message: "No aps-environment set. If testing on a device APNS is not " + "correctly configured. Please recheck your provisioning profiles.") diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample.xcodeproj/project.pbxproj b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample.xcodeproj/project.pbxproj index edee157b901..2160a626445 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample.xcodeproj/project.pbxproj +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample.xcodeproj/project.pbxproj @@ -794,7 +794,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.google.FirebaseExperimental1; + PRODUCT_BUNDLE_IDENTIFIER = com.google.firebaseAuthSDKSampleApp.dev; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; @@ -817,7 +817,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.google.FirebaseExperimental1; + PRODUCT_BUNDLE_IDENTIFIER = com.google.firebaseAuthSDKSampleApp.dev; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample.xcodeproj/xcshareddata/xcschemes/AuthenticationExample.xcscheme b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample.xcodeproj/xcshareddata/xcschemes/AuthenticationExample.xcscheme index 7c762821b92..ab6e1b02565 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample.xcodeproj/xcshareddata/xcschemes/AuthenticationExample.xcscheme +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample.xcodeproj/xcshareddata/xcschemes/AuthenticationExample.xcscheme @@ -81,6 +81,12 @@ ReferencedContainer = "container:AuthenticationExample.xcodeproj"> + + + +