My podfile has the following definitions.
pod 'Firebase/Core', '5.15.0'
pod 'Firebase/AdMob'
pod 'Firebase/Messaging'
pod 'Firebase/Functions'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Performance'
My iOS code using Functions.functions().httpsCallable(...).call(...) doesn't make a call.
I guess my configuration could be something wrong, but not sure. Other features like Performance are working fine in production.
I wanted to call my cloud function from iOS. My cloud function is like this:
export const validation = functions
.runWith({ timeoutSeconds: 60, memory: '128MB' })
.https.onCall(async (data, _) => { // I use callable function
return asyncHandler(data) // Returns Promise
.then(...)
.catch(...)
})
I confirmed it's deployed successfully and it works using curl.
My iOS code to call it above is
Functions.functions()
.httpsCallable("validation")
.call([ "foo": "bar" ]) { [weak self] (result, error) in
guard error == nil else { ... }
...
}
I believe this code is fine. However I couldn't see any requests from my client to the firebase function even using Charles proxy app. Then I put breakpoints to figure out where it doesn't work. Finally I found there is a strange behavior at FUNContext.m.
https://github.com/firebase/firebase-ios-sdk/blob/d671776654fca82edbf276977fa1f21943cb4be8/Functions/FirebaseFunctions/FUNContext.m#L69
A callback of the function above was never run. I mean I put breakpoints at L71 but process doesn't stop there. I believe it's the root cause of my issue but I don't know why.
My app doesn't use Auth component so I'm just guessing it might relate to this. As for my function, context is not required so far.
I assume it should not be a common issue (I mean all users other than me are fine) but I can't provide any information related to this so far. Please let me know if you want any helpful information that I could offer.
Thanks,
I found a few problems with this issue:
The callback above worked after I just added pod 'Firebase/Auth' to Podfile. Ok, I think I missed documentation that describes pre-requisites to use callable functions.
I think you did find a valid bug - if auth is nil we should still call the callback but that doesn't happen. Looks like this was inadvertently broken in #2113. I'll make a fix shortly!
Thank you! Looking forward to the new version!
This was a pretty big regression. Thanks for reporting it and fixing it. I would have never guessed that I needed to install the Firebase/Auth pod to resolve this. This functionality was working for me until recently and broke my production app.
@chadpav apologies for the issue, we've definitely learned from this and will ensure transitions in the future go tested even further. This wasn't caught originally due to Auth always being included in our test project to ensure that the Authentication and security didn't break.
Previously we were using a fragile interface between Auth and other SDKs but now it's more appropriate - the thing we missed was calling the completion handler for the Auth used ID when Auth wasn't available.
If you want to include the fix in your project before the next release without adding Auth, you can point to it in your Podfile you can point to the master branch or specific commit with instructions here: http://guides.cocoapods.org/using/the-podfile.html#from-a-podspec-in-the-root-of-a-library-repo
Once this fix is included in the release, it would make sense to remove the special branch/commit locking to ensure you get further updates.
Once again, apologies for the issue and thanks to @pot8os for reporting it.
Most helpful comment
I think you did find a valid bug - if
authis nil we should still call the callback but that doesn't happen. Looks like this was inadvertently broken in #2113. I'll make a fix shortly!