I'm developing a firebase function for an old ios app. It's working ok and I would like to add AppCheck to it, but I'm struggling with this.
This is what I have now.
I my podfile:
pod 'FirebaseFunctions', '10.5.0'
In my AppDelegate.m file:
[[_functions HTTPSCallableWithName:@"isMyFunctionActive"] callWithCompletion:^(FIRHTTPSCallableResult * _Nullable result,
NSError * _Nullable error) {
// Manage response
}];
And my firebase function is this:
const {onCall} = require("firebase-functions/v2/https");
exports.isMyFunctionActive = onCall((request) => {
return {
isMyFunctionActive: true,
};
});
This is working OK. To add AppCheck I've done this:
In my firebase console I've registered App Attest for my project iOS app.
I've added AppCheck pod and I've made a pod install:
pod 'FirebaseFunctions', '10.5.0'
pod 'FirebaseAppCheck', '10.5.0'
I've added this to my AppDelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
FIRAppCheckDebugProviderFactory* providerFactory = [[FIRAppCheckDebugProviderFactory alloc] init];
[FIRAppCheck setAppCheckProviderFactory:providerFactory];
...
}
I've left my firebase function call as it was.
Finally I've added enforceAppCheck to my firebase function:
const {onCall} = require("firebase-functions/v2/https");
exports.isMyFunctionActive = onCall({enforceAppCheck: true}, (request) => {
return {
isMyFunctionActive: true,
};
});
With these changes, every time my app calls the firebase function it receives an Unauthenticated error.
Which is the reason? I assume I'm wrong, but I thought that the configuration of FIRAppCheck in didFinishLaunchingWithOptions would store internally the token (in fact my app logs show Firebase App Check debug token: '...') and this token would be automatically added to firebase functions calls.
I'm developing a firebase function for an old ios app. It's working ok and I would like to add AppCheck to it, but I'm struggling with this.
This is what I have now.
I my podfile:
pod 'FirebaseFunctions', '10.5.0'
In my AppDelegate.m file:
[[_functions HTTPSCallableWithName:@"isMyFunctionActive"] callWithCompletion:^(FIRHTTPSCallableResult * _Nullable result,
NSError * _Nullable error) {
// Manage response
}];
And my firebase function is this:
const {onCall} = require("firebase-functions/v2/https");
exports.isMyFunctionActive = onCall((request) => {
return {
isMyFunctionActive: true,
};
});
This is working OK. To add AppCheck I've done this:
In my firebase console I've registered App Attest for my project iOS app.
I've added AppCheck pod and I've made a pod install:
pod 'FirebaseFunctions', '10.5.0'
pod 'FirebaseAppCheck', '10.5.0'
I've added this to my AppDelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
FIRAppCheckDebugProviderFactory* providerFactory = [[FIRAppCheckDebugProviderFactory alloc] init];
[FIRAppCheck setAppCheckProviderFactory:providerFactory];
...
}
I've left my firebase function call as it was.
Finally I've added enforceAppCheck to my firebase function:
const {onCall} = require("firebase-functions/v2/https");
exports.isMyFunctionActive = onCall({enforceAppCheck: true}, (request) => {
return {
isMyFunctionActive: true,
};
});
With these changes, every time my app calls the firebase function it receives an Unauthenticated error.
Which is the reason? I assume I'm wrong, but I thought that the configuration of FIRAppCheck in didFinishLaunchingWithOptions would store internally the token (in fact my app logs show Firebase App Check debug token: '...') and this token would be automatically added to firebase functions calls.
Share Improve this question edited Mar 23 at 16:18 Doug Stevenson 318k36 gold badges456 silver badges473 bronze badges Recognized by Google Cloud Collective asked Mar 23 at 16:13 WontonWonton 1,1431 gold badge19 silver badges38 bronze badges1 Answer
Reset to default 0Just in case anyone needs the solution the reason was very silly. I fot to add AppCheck capability to my target and change the entitlement key to "production".