Uygulama Kontrolü'nü Apple platformlarında özel sağlayıcıyla kullanmaya başlayın
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Bu sayfada, özel App Check sağlayıcınızı kullanarak bir Apple uygulamasında App Check özelliğini nasıl etkinleştireceğiniz gösterilmektedir. App Check seçeneğini etkinleştirdiğinizde, projenizin Firebase kaynaklarına yalnızca uygulamanızın erişebilmesini sağlayabilirsiniz.
Ayrıca, bağlı olduğunuz Firebase hizmeti istemci kitaplıklarının en son sürümünü kullandığınızdan emin olun.
pod install komutunu çalıştırın ve oluşturulan .xcworkspace dosyasını açın.
2. App Check protokollerini uygulayın
Öncelikle AppCheckProvider ve AppCheckProviderFactory protokollerini uygulayan sınıflar oluşturmanız gerekir.
AppCheckProvider sınıfınızda, özel App Check sağlayıcınızın kimlik doğrulama kanıtı olarak gerektirdiği bilgileri toplayan ve bunları App Check jetonu karşılığında jeton edinme hizmetinize gönderen bir getToken(completion:) yöntemi olmalıdır. App Check SDK'sı jeton önbelleğe almayı işler. Bu nedenle, getToken(completion:) uygulamanızda her zaman yeni bir jeton alın.
@interfaceYourCustomAppCheckProvider : NSObject<FIRAppCheckProvider>
@propertyFIRApp*app;-(id)initWithApp:(FIRApp*)app;@end@implementationYourCustomAppCheckProvider-(id)initWithApp:app{self=[superinit];if(self){self.app=app;}returnself;}-(void)getTokenWithCompletion:(nonnullvoid(^)(FIRAppCheckToken*_Nullable,NSError*_Nullable))handler{dispatch_async(dispatch_get_main_queue(),^{// Logic to exchange proof of authenticity for an App Check token.// ...// Create FIRAppCheckToken object.NSTimeIntervalexp=expirationFromServer;FIRAppCheckToken*token=[[FIRAppCheckTokenalloc]initWithToken:tokenFromServerexpirationDate:[NSDatedateWithTimeIntervalSince1970:exp]];// Pass the token or error to the completion handler.handler(token,nil);});}@end
Ayrıca, AppCheckProviderFactory sınıfını uygulayarak AppCheckProvider uygulamanızın örneklerini oluşturun:
Güncellenen istemci uygulaması, Firebase'e yaptığı her istekle birlikte App Check jetonları göndermeye başlar. Ancak Firebase ürünleri, Firebase konsolunun App Check bölümünde zorunlu kılmayı etkinleştirene kadar jetonların geçerli olmasını gerektirmez.
Metrikleri izleme ve yaptırım uygulama
Ancak zorunlu kılmayı etkinleştirmeden önce, bu işlemin mevcut meşru kullanıcılarınızın hizmetten yararlanmasını engellemeyeceğinden emin olmanız gerekir. Diğer yandan, uygulama kaynaklarınızın şüpheli bir şekilde kullanıldığını görüyorsanız yaptırımı daha erken etkinleştirmek isteyebilirsiniz.
Bu kararı vermenize yardımcı olması için kullandığınız hizmetlerin App Check metriklerine bakabilirsiniz:
Data Connect, Firebase AI Logic, Realtime Database, Cloud Firestore, Cloud Storage, Authentication, Google Identity for iOS, Maps JavaScript API ve Places API (Yeni) için App Check istek metriklerini izleyin.
App Check özelliğinin kullanıcılarınızı nasıl etkileyeceğini anladığınızda ve devam etmeye hazır olduğunuzda App Check zorunluluğunu etkinleştirebilirsiniz:
App Check zorunlu kılma özelliğini Data Connect, Firebase AI Logic, Realtime Database, Cloud Firestore, Cloud Storage, Authentication, Google Identity for iOS, Maps JavaScript API ve Places API (Yeni) için etkinleştirin.
Cloud Functions için App Check zorunlu kılma özelliğini etkinleştirin.
Hata ayıklama ortamlarında App Check kullanma
Uygulamanızı App Check için kaydettikten sonra, uygulamanızı normalde App Check tarafından geçerli olarak sınıflandırılmayacak bir ortamda (ör. geliştirme sırasında simülatörde veya sürekli entegrasyon (CI) ortamında) çalıştırmak istiyorsanız uygulamanızın gerçek bir onay sağlayıcı yerine App Check hata ayıklama sağlayıcısını kullanan bir hata ayıklama sürümünü oluşturabilirsiniz.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-07-22 UTC."],[],[],null,["This page shows you how to enable App Check in an Apple app, using [your\ncustom App Check provider](/docs/app-check/ios/custom-provider). When you enable App Check,\nyou help ensure that only your app can access your project's Firebase resources.\n\nIf you want to use App Check with the built-in providers, see the docs for\n[App Check with App Attest](/docs/app-check/ios/app-attest-provider) and\n[App Check with DeviceCheck](/docs/app-check/ios/devicecheck-provider).\n\nBefore you begin\n\n- [Add Firebase to your Apple project](/docs/ios/setup) if you haven't\n already done so.\n\n- [Implement your custom App Check provider's server-side logic](/docs/app-check/custom-provider).\n\n1. Add the App Check library to your app\n\n1. Add the dependency for App Check to your project's `Podfile`:\n\n ```\n pod 'FirebaseAppCheck'\n ```\n\n Or, alternatively, you can use [Swift Package\n Manager](/docs/ios/swift-package-manager) instead.\n\n Also, make sure you're using the latest version of any Firebase service\n client libraries you depend on.\n2. Run `pod install` and open the created `.xcworkspace` file.\n\n2. Implement the App Check protocols\n\nFirst, you need to create classes that implement the `AppCheckProvider` and\n`AppCheckProviderFactory` protocols.\n\nYour `AppCheckProvider` class must have a `getToken(completion:)` method, which\ncollects whatever information your custom App Check provider requires as\nproof of authenticity, and sends it to your token acquisition service in\nexchange for an App Check token. The App Check SDK handles token\ncaching, so always get a new token in your implementation of\n`getToken(completion:)`. \n\nSwift \n\n```swift\nclass YourCustomAppCheckProvider: NSObject, AppCheckProvider {\n var app: FirebaseApp\n\n init(withFirebaseApp app: FirebaseApp) {\n self.app = app\n super.init()\n }\n\n func getToken() async throws -\u003e AppCheckToken {\n let getTokenTask = Task { () -\u003e AppCheckToken in\n // ...\n\n // Create AppCheckToken object.\n let exp = Date(timeIntervalSince1970: expirationFromServer)\n let token = AppCheckToken(\n token: tokenFromServer,\n expirationDate: exp\n )\n\n if Date() \u003e exp {\n throw NSError(domain: \"ExampleError\", code: 1, userInfo: nil)\n }\n\n return token\n }\n\n return try await getTokenTask.value\n }\n\n}\n```\n\nObjective-C \n\n```objective-c\n@interface YourCustomAppCheckProvider : NSObject \u003cFIRAppCheckProvider\u003e\n\n@property FIRApp *app;\n\n- (id)initWithApp:(FIRApp *)app;\n\n@end\n\n@implementation YourCustomAppCheckProvider\n\n- (id)initWithApp:app {\n self = [super init];\n if (self) {\n self.app = app;\n }\n return self;\n}\n\n- (void)getTokenWithCompletion:(nonnull void (^)(FIRAppCheckToken * _Nullable,\n NSError * _Nullable))handler {\n dispatch_async(dispatch_get_main_queue(), ^{\n // Logic to exchange proof of authenticity for an App Check token.\n // ...\n\n // Create FIRAppCheckToken object.\n NSTimeInterval exp = expirationFromServer;\n FIRAppCheckToken *token\n = [[FIRAppCheckToken alloc] initWithToken:tokenFromServer\n expirationDate:[NSDate dateWithTimeIntervalSince1970:exp]];\n\n // Pass the token or error to the completion handler.\n handler(token, nil);\n });\n}\n\n@end\n```\n\nAlso, implement a `AppCheckProviderFactory` class that creates instances of your\n`AppCheckProvider` implementation: \n\nSwift \n\n```swift\nclass YourCustomAppCheckProviderFactory: NSObject, AppCheckProviderFactory {\n func createProvider(with app: FirebaseApp) -\u003e AppCheckProvider? {\n return YourCustomAppCheckProvider(withFirebaseApp: app)\n }\n}\n```\n\nObjective-C \n\n```objective-c\n@interface YourCustomAppCheckProviderFactory : NSObject \u003cFIRAppCheckProviderFactory\u003e\n@end\n\n@implementation YourCustomAppCheckProviderFactory\n\n- (nullable id\u003cFIRAppCheckProvider\u003e)createProviderWithApp:(FIRApp *)app {\n return [[YourCustomAppCheckProvider alloc] initWithApp:app];\n}\n\n@end\n```\n\n3. Initialize App Check\n\nAdd the following initialization code to your app delegate or app initializer: \n\nSwift \n\n```swift\nlet providerFactory = YourAppCheckProviderFactory()\nAppCheck.setAppCheckProviderFactory(providerFactory)\n\nFirebaseApp.configure()\n```\n\nObjective-C \n\n```objective-c\nYourAppCheckProviderFactory *providerFactory =\n [[YourAppCheckProviderFactory alloc] init];\n[FIRAppCheck setAppCheckProviderFactory:providerFactory];\n\n[FIRApp configure];\n```\n\nNext steps\n\nOnce the App Check library is installed in your app, start distributing the\nupdated app to your users.\n\nThe updated client app will begin sending App Check tokens along with every\nrequest it makes to Firebase, but Firebase products will not require the tokens\nto be valid until you enable enforcement in the App Check section of the\nFirebase console.\n\nMonitor metrics and enable enforcement\n\nBefore you enable enforcement, however, you should make sure that doing so won't\ndisrupt your existing legitimate users. On the other hand, if you're seeing\nsuspicious use of your app resources, you might want to enable enforcement\nsooner.\n\nTo help make this decision, you can look at App Check metrics for the\nservices you use:\n\n- [Monitor App Check request metrics](/docs/app-check/monitor-metrics) for Firebase AI Logic, Data Connect, Realtime Database, Cloud Firestore, Cloud Storage, Authentication, Google Identity for iOS, Maps JavaScript API, and Places API (New).\n- [Monitor App Check request metrics for Cloud Functions](/docs/app-check/monitor-functions-metrics).\n\nEnable App Check enforcement\n\nWhen you understand how App Check will affect your users and you're ready to\nproceed, you can enable App Check enforcement:\n\n- [Enable App Check enforcement](/docs/app-check/enable-enforcement) for Firebase AI Logic, Data Connect, Realtime Database, Cloud Firestore, Cloud Storage, Authentication, Google Identity for iOS, Maps JavaScript API, and Places API (New).\n- [Enable App Check enforcement for Cloud Functions](/docs/app-check/cloud-functions).\n\nUse App Check in debug environments\n\nIf, after you have registered your app for App Check, you want to run your\napp in an environment that App Check would normally not classify as valid,\nsuch as a simulator during development, or from a continuous integration (CI)\nenvironment, you can create a debug build of your app that uses the\nApp Check debug provider instead of a real attestation provider.\n\nSee [Use App Check with the debug provider on Apple platforms](/docs/app-check/ios/debug-provider)."]]