للسماح للمستخدمين بالاشتراك أو الانسحاب من استخدام مراقبة أداء Firebase ، قد ترغب في تكوين تطبيقك بحيث يمكنك تمكين وتعطيل مراقبة الأداء. قد تجد أيضًا أن هذه الإمكانية مفيدة أثناء تطوير التطبيق واختباره.
فيما يلي بعض الخيارات التي يجب مراعاتها:
يمكنك تعطيل SDK لمراقبة الأداء عند إنشاء تطبيقك ، مع خيار إعادة تمكينه في وقت التشغيل.
يمكنك إنشاء تطبيقك مع تمكين SDK لمراقبة الأداء ولكن لديك خيار تعطيله في وقت التشغيل باستخدام Firebase Remote Config.
يمكنك إلغاء تنشيط SDK لمراقبة الأداء تمامًا ، مع عدم وجود خيار لتمكينه في وقت التشغيل.
تعطيل مراقبة الأداء أثناء عملية بناء التطبيق الخاص بك
أحد المواقف التي قد يكون فيها تعطيل مراقبة الأداء أثناء عملية إنشاء التطبيق مفيدًا هو تجنب الإبلاغ عن بيانات الأداء من إصدار ما قبل الإصدار لتطبيقك أثناء تطوير التطبيق واختباره.
لتعطيل أو إلغاء تنشيط مراقبة الأداء ، يمكنك إضافة مفتاح من مفتاحين إلى ملف قائمة الخصائص ( Info.plist
) لتطبيق Apple الخاص بك:
لتعطيل مراقبة الأداء ، مع السماح لتطبيقك بتمكينها في وقت التشغيل ، اضبط
firebase_performance_collection_enabled
علىfalse
في ملفInfo.plist
الخاص بتطبيقك.لإلغاء تنشيط مراقبة الأداء تمامًا ، مع عدم وجود خيار لتمكينها في وقت التشغيل ، قم بتعيين
firebase_performance_collection_deactivated
إلىtrue
في ملفInfo.plist
الخاص بتطبيقك.
قم بتعطيل التطبيق الخاص بك في وقت التشغيل باستخدام Remote Config
يتيح لك Firebase Remote Config إجراء تغييرات على سلوك ومظهر تطبيقك ، لذا فهو يوفر طريقة مثالية للسماح لك بتعطيل مراقبة الأداء في الحالات المنشورة لتطبيقك.
لتعطيل جمع بيانات مراقبة الأداء في المرة التالية التي يبدأ فيها تطبيق Apple الخاص بك ، استخدم مثال الرمز الموضح أدناه. لمزيد من المعلومات حول استخدام Remote Config في تطبيق Apple ، راجع استخدام Firebase Remote Config على أنظمة Apple الأساسية .
تأكد من استخدام Remote Config في
Podfile
الخاص بك:pod 'Firebase/RemoteConfig'
أضف ما يلي إلى أعلى ملف
AppDelegate
الخاص بتطبيقك:سويفت
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.import FirebaseRemoteConfig
ج موضوعية
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.@import FirebaseRemoteConfig;
في ملف
AppDelegate
، أضف الكود التالي إلى عباراتlaunchOptions
فيapplication:didFinishLaunchingWithOptions:
طريقة المثيل:سويفت
ملاحظة: هذا المنتج غير متوفر على أهداف macOS و Mac Catalyst و watchOS.remoteConfig = RemoteConfig.remoteConfig() // You can change the "false" below to "true" to permit more fetches when validating // your app, but you should change it back to "false" or remove this statement before // distributing your app in production. let remoteConfigSettings = RemoteConfigSettings(developerModeEnabled: false) remoteConfig.configSettings = remoteConfigSettings! // Load in-app defaults from a plist file that sets perf_disable to false until // you update values in the Firebase console. remoteConfig.setDefaultsFromPlistFileName("RemoteConfigDefaults") // Important! This needs to be applied before FirebaseApp.configure() if !remoteConfig["perf_disable"].boolValue { // The following line disables all automatic (out-of-the-box) monitoring Performance.sharedInstance().isInstrumentationEnabled = false // The following line disables all custom monitoring Performance.sharedInstance().isDataCollectionEnabled = false } else { Performance.sharedInstance().isInstrumentationEnabled = true Performance.sharedInstance().isDataCollectionEnabled = true } // Use Firebase library to configure APIs FirebaseApp.configure()
ج موضوعية
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.self.remoteConfig = [FIRRemoteConfig remoteConfig]; // You can change the NO below to YES to permit more fetches when validating // your app, but you should change it back to NO or remove this statement before // distributing your app in production. FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:NO]; self.remoteConfig.configSettings = remoteConfigSettings; // Load in-app defaults from a plist file that sets perf_disable to false until // you update values in the Firebase console. [self.remoteConfig setDefaultsFromPlistFileName:@"RemoteConfigDefaults"]; // Important! This needs to be applied before [FIRApp configure] if (!self.remoteConfig[@"perf_disable"].numberValue.boolValue) { // The following line disables all automatic (out-of-the-box) monitoring [FIRPerformance sharedInstance].instrumentationEnabled = NO; // The following line disables all custom monitoring [FIRPerformance sharedInstance].dataCollectionEnabled = NO; } else { [FIRPerformance sharedInstance].instrumentationEnabled = YES; [FIRPerformance sharedInstance].dataCollectionEnabled = YES; } // Use Firebase library to configure APIs [FIRApp configure];
في
ViewController.m
، أو ملف تنفيذ آخر يستخدمه تطبيقك ، أضف الكود التالي لجلب قيم Remote Config وتنشيطها:سويفت
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.//RemoteConfig fetch and activation in your app, shortly after startup remoteConfig.fetch(withExpirationDuration: TimeInterval(30.0)) { (status, error) -> Void in if status == .success { print("Config fetched!") self.remoteConfig.activateFetched() } else { print("Config not fetched") print("Error \(error!.localizedDescription)") } }
ج موضوعية
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.//RemoteConfig fetch and activation in your app, shortly after startup [self.remoteConfig fetchWithExpirationDuration:30.0 completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *error) { if (status == FIRRemoteConfigFetchStatusSuccess) { NSLog(@"Config fetched!"); [self.remoteConfig activateFetched]; } else { NSLog(@"Config not fetched"); NSLog(@"Error %@", error.localizedDescription); } }];
لتعطيل مراقبة الأداء في وحدة تحكم Firebase ، أنشئ معلمة perf_disable في مشروع تطبيقك ، ثم اضبط قيمتها على
true
.إذا قمت بتعيين قيمة perf_disable على
false
، تظل مراقبة الأداء ممكَّنة.
تعطيل جمع البيانات التلقائي أو المخصص بشكل منفصل
يمكنك إجراء بعض التغييرات على الشفرة الموضحة أعلاه وفي وحدة تحكم Firebase للسماح لك بتعطيل جميع المراقبة التلقائية (خارج الصندوق) بشكل منفصل عن المراقبة المخصصة.
أضف الكود التالي إلى عبارات
launchOptions
فيapplication:didFinishLaunchingWithOptions:
طريقة المثيل (بدلاً من ما هو معروض أعلاه لنفس طريقة المثيل):سويفت
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.remoteConfig = FIRRemoteConfig.remoteConfig() let remoteConfigSettings = FIRRemoteConfigSettings(developerModeEnabled: true) remoteConfig.configSettings = remoteConfigSettings! // Important! This needs to be applied before FirebaseApp.configure() if remoteConfig["perf_disable_auto"].boolValue { // The following line disables all automatic (out-of-the-box) monitoring Performance.sharedInstance().isInstrumentationEnabled = false } else { Performance.sharedInstance().isInstrumentationEnabled = true } if remoteConfig["perf_disable_manual"].boolValue { // The following line disables all custom monitoring Performance.sharedInstance().isDataCollectionEnabled = false } else { Performance.sharedInstance().isDataCollectionEnabled = true } // Use Firebase library to configure APIs FirebaseApp.configure()
ج موضوعية
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.self.remoteConfig = [FIRRemoteConfig remoteConfig]; FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:YES]; self.remoteConfig.configSettings = remoteConfigSettings; // Important! This needs to be applied before [FirebaseApp configure] if (self.remoteConfig[@"perf_disable_auto"].numberValue.boolValue) { // The following line disables all automatic (out-of-the-box) monitoring [FIRPerformance sharedInstance].instrumentationEnabled = NO; } else { [FIRPerformance sharedInstance].instrumentationEnabled = YES; } if (self.remoteConfig[@"perf_disable_manual"].numberValue.boolValue) { // The following line disables all custom monitoring [FIRPerformance sharedInstance].dataCollectionEnabled = NO; } else { [FIRPerformance sharedInstance].dataCollectionEnabled = YES; } // Use Firebase library to configure APIs [FirebaseApp configure];
أكمل ما يلي في وحدة تحكم Firebase:
- لتعطيل كل المراقبة التلقائية (خارج الصندوق) ، أنشئ معلمة perf_disable_auto في مشروع تطبيقك ، ثم اضبط قيمتها على
true
. - لتعطيل كل المراقبة المخصصة ، أنشئ معلمة perf_disable_manual في مشروع تطبيقك ، ثم اضبط قيمتها على
true
.
- لتعطيل كل المراقبة التلقائية (خارج الصندوق) ، أنشئ معلمة perf_disable_auto في مشروع تطبيقك ، ثم اضبط قيمتها على
للسماح للمستخدمين بالاشتراك أو الانسحاب من استخدام مراقبة أداء Firebase ، قد ترغب في تكوين تطبيقك بحيث يمكنك تمكين وتعطيل مراقبة الأداء. قد تجد أيضًا أن هذه الإمكانية مفيدة أثناء تطوير التطبيق واختباره.
فيما يلي بعض الخيارات التي يجب مراعاتها:
يمكنك تعطيل SDK لمراقبة الأداء عند إنشاء تطبيقك ، مع خيار إعادة تمكينه في وقت التشغيل.
يمكنك إنشاء تطبيقك مع تمكين SDK لمراقبة الأداء ولكن لديك خيار تعطيله في وقت التشغيل باستخدام Firebase Remote Config.
يمكنك إلغاء تنشيط SDK لمراقبة الأداء تمامًا ، مع عدم وجود خيار لتمكينه في وقت التشغيل.
تعطيل مراقبة الأداء أثناء عملية بناء التطبيق الخاص بك
أحد المواقف التي قد يكون فيها تعطيل مراقبة الأداء أثناء عملية إنشاء التطبيق مفيدًا هو تجنب الإبلاغ عن بيانات الأداء من إصدار ما قبل الإصدار لتطبيقك أثناء تطوير التطبيق واختباره.
لتعطيل أو إلغاء تنشيط مراقبة الأداء ، يمكنك إضافة مفتاح من مفتاحين إلى ملف قائمة الخصائص ( Info.plist
) لتطبيق Apple الخاص بك:
لتعطيل مراقبة الأداء ، مع السماح لتطبيقك بتمكينها في وقت التشغيل ، اضبط
firebase_performance_collection_enabled
علىfalse
في ملفInfo.plist
الخاص بتطبيقك.لإلغاء تنشيط مراقبة الأداء تمامًا ، مع عدم وجود خيار لتمكينها في وقت التشغيل ، قم بتعيين
firebase_performance_collection_deactivated
إلىtrue
في ملفInfo.plist
الخاص بتطبيقك.
قم بتعطيل التطبيق الخاص بك في وقت التشغيل باستخدام Remote Config
يتيح لك Firebase Remote Config إجراء تغييرات على سلوك ومظهر تطبيقك ، لذا فهو يوفر طريقة مثالية للسماح لك بتعطيل مراقبة الأداء في الحالات المنشورة لتطبيقك.
لتعطيل جمع بيانات مراقبة الأداء في المرة التالية التي يبدأ فيها تطبيق Apple الخاص بك ، استخدم مثال الرمز الموضح أدناه. لمزيد من المعلومات حول استخدام Remote Config في تطبيق Apple ، راجع استخدام Firebase Remote Config على أنظمة Apple الأساسية .
تأكد من استخدام Remote Config في
Podfile
الخاص بك:pod 'Firebase/RemoteConfig'
أضف ما يلي إلى أعلى ملف
AppDelegate
الخاص بتطبيقك:سويفت
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.import FirebaseRemoteConfig
ج موضوعية
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.@import FirebaseRemoteConfig;
في ملف
AppDelegate
، أضف الكود التالي إلى عباراتlaunchOptions
فيapplication:didFinishLaunchingWithOptions:
طريقة المثيل:سويفت
ملاحظة: هذا المنتج غير متوفر على أهداف macOS و Mac Catalyst و watchOS.remoteConfig = RemoteConfig.remoteConfig() // You can change the "false" below to "true" to permit more fetches when validating // your app, but you should change it back to "false" or remove this statement before // distributing your app in production. let remoteConfigSettings = RemoteConfigSettings(developerModeEnabled: false) remoteConfig.configSettings = remoteConfigSettings! // Load in-app defaults from a plist file that sets perf_disable to false until // you update values in the Firebase console. remoteConfig.setDefaultsFromPlistFileName("RemoteConfigDefaults") // Important! This needs to be applied before FirebaseApp.configure() if !remoteConfig["perf_disable"].boolValue { // The following line disables all automatic (out-of-the-box) monitoring Performance.sharedInstance().isInstrumentationEnabled = false // The following line disables all custom monitoring Performance.sharedInstance().isDataCollectionEnabled = false } else { Performance.sharedInstance().isInstrumentationEnabled = true Performance.sharedInstance().isDataCollectionEnabled = true } // Use Firebase library to configure APIs FirebaseApp.configure()
ج موضوعية
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.self.remoteConfig = [FIRRemoteConfig remoteConfig]; // You can change the NO below to YES to permit more fetches when validating // your app, but you should change it back to NO or remove this statement before // distributing your app in production. FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:NO]; self.remoteConfig.configSettings = remoteConfigSettings; // Load in-app defaults from a plist file that sets perf_disable to false until // you update values in the Firebase console. [self.remoteConfig setDefaultsFromPlistFileName:@"RemoteConfigDefaults"]; // Important! This needs to be applied before [FIRApp configure] if (!self.remoteConfig[@"perf_disable"].numberValue.boolValue) { // The following line disables all automatic (out-of-the-box) monitoring [FIRPerformance sharedInstance].instrumentationEnabled = NO; // The following line disables all custom monitoring [FIRPerformance sharedInstance].dataCollectionEnabled = NO; } else { [FIRPerformance sharedInstance].instrumentationEnabled = YES; [FIRPerformance sharedInstance].dataCollectionEnabled = YES; } // Use Firebase library to configure APIs [FIRApp configure];
في
ViewController.m
، أو ملف تنفيذ آخر يستخدمه تطبيقك ، أضف الكود التالي لجلب قيم Remote Config وتنشيطها:سويفت
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.//RemoteConfig fetch and activation in your app, shortly after startup remoteConfig.fetch(withExpirationDuration: TimeInterval(30.0)) { (status, error) -> Void in if status == .success { print("Config fetched!") self.remoteConfig.activateFetched() } else { print("Config not fetched") print("Error \(error!.localizedDescription)") } }
ج موضوعية
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.//RemoteConfig fetch and activation in your app, shortly after startup [self.remoteConfig fetchWithExpirationDuration:30.0 completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *error) { if (status == FIRRemoteConfigFetchStatusSuccess) { NSLog(@"Config fetched!"); [self.remoteConfig activateFetched]; } else { NSLog(@"Config not fetched"); NSLog(@"Error %@", error.localizedDescription); } }];
لتعطيل مراقبة الأداء في وحدة تحكم Firebase ، أنشئ معلمة perf_disable في مشروع تطبيقك ، ثم اضبط قيمتها على
true
.إذا قمت بتعيين قيمة perf_disable على
false
، تظل مراقبة الأداء ممكَّنة.
تعطيل جمع البيانات التلقائي أو المخصص بشكل منفصل
يمكنك إجراء بعض التغييرات على الشفرة الموضحة أعلاه وفي وحدة تحكم Firebase للسماح لك بتعطيل جميع المراقبة التلقائية (خارج الصندوق) بشكل منفصل عن المراقبة المخصصة.
أضف الكود التالي إلى عبارات
launchOptions
فيapplication:didFinishLaunchingWithOptions:
طريقة المثيل (بدلاً من ما هو معروض أعلاه لنفس طريقة المثيل):سويفت
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.remoteConfig = FIRRemoteConfig.remoteConfig() let remoteConfigSettings = FIRRemoteConfigSettings(developerModeEnabled: true) remoteConfig.configSettings = remoteConfigSettings! // Important! This needs to be applied before FirebaseApp.configure() if remoteConfig["perf_disable_auto"].boolValue { // The following line disables all automatic (out-of-the-box) monitoring Performance.sharedInstance().isInstrumentationEnabled = false } else { Performance.sharedInstance().isInstrumentationEnabled = true } if remoteConfig["perf_disable_manual"].boolValue { // The following line disables all custom monitoring Performance.sharedInstance().isDataCollectionEnabled = false } else { Performance.sharedInstance().isDataCollectionEnabled = true } // Use Firebase library to configure APIs FirebaseApp.configure()
ج موضوعية
ملاحظة: لا يتوفر منتج Firebase هذا على أهداف macOS و Mac Catalyst و watchOS.self.remoteConfig = [FIRRemoteConfig remoteConfig]; FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:YES]; self.remoteConfig.configSettings = remoteConfigSettings; // Important! This needs to be applied before [FirebaseApp configure] if (self.remoteConfig[@"perf_disable_auto"].numberValue.boolValue) { // The following line disables all automatic (out-of-the-box) monitoring [FIRPerformance sharedInstance].instrumentationEnabled = NO; } else { [FIRPerformance sharedInstance].instrumentationEnabled = YES; } if (self.remoteConfig[@"perf_disable_manual"].numberValue.boolValue) { // The following line disables all custom monitoring [FIRPerformance sharedInstance].dataCollectionEnabled = NO; } else { [FIRPerformance sharedInstance].dataCollectionEnabled = YES; } // Use Firebase library to configure APIs [FirebaseApp configure];
أكمل ما يلي في وحدة تحكم Firebase:
- لتعطيل كل المراقبة التلقائية (خارج الصندوق) ، أنشئ معلمة perf_disable_auto في مشروع تطبيقك ، ثم اضبط قيمتها على
true
. - لتعطيل كل المراقبة المخصصة ، أنشئ معلمة perf_disable_manual في مشروع تطبيقك ، ثم اضبط قيمتها على
true
.
- لتعطيل كل المراقبة التلقائية (خارج الصندوق) ، أنشئ معلمة perf_disable_auto في مشروع تطبيقك ، ثم اضبط قيمتها على
للسماح للمستخدمين بالاشتراك أو الانسحاب من استخدام مراقبة أداء Firebase ، قد ترغب في تكوين تطبيقك بحيث يمكنك تمكين وتعطيل مراقبة الأداء. قد تجد أيضًا أن هذه الإمكانية مفيدة أثناء تطوير التطبيق واختباره.
فيما يلي بعض الخيارات التي يجب مراعاتها:
يمكنك تعطيل SDK لمراقبة الأداء عند إنشاء تطبيقك ، مع خيار إعادة تمكينه في وقت التشغيل.
يمكنك إنشاء تطبيقك مع تمكين SDK لمراقبة الأداء ولكن لديك خيار تعطيله في وقت التشغيل باستخدام Firebase Remote Config.
يمكنك إلغاء تنشيط SDK لمراقبة الأداء تمامًا ، مع عدم وجود خيار لتمكينه في وقت التشغيل.
تعطيل مراقبة الأداء أثناء عملية بناء التطبيق الخاص بك
أحد المواقف التي قد يكون فيها تعطيل مراقبة الأداء أثناء عملية إنشاء التطبيق مفيدًا هو تجنب الإبلاغ عن بيانات الأداء من إصدار ما قبل الإصدار لتطبيقك أثناء تطوير التطبيق واختباره.
To disable or deactivate Performance Monitoring, you can add one of two keys to the property list file ( Info.plist
) for your Apple app:
To disable Performance Monitoring, but allow your app to enable it at runtime, set
firebase_performance_collection_enabled
tofalse
in your app'sInfo.plist
file.To completely deactivate Performance Monitoring, with no option to enable it at runtime, set
firebase_performance_collection_deactivated
totrue
in your app'sInfo.plist
file.
Disable your app at runtime using Remote Config
Firebase Remote Config lets you make changes to the behavior and appearance of your app, so it provides an ideal way to let you disable Performance Monitoring in deployed instances of your app.
To disable Performance Monitoring data collection the next time that your Apple app starts, use the example code shown below. For more information about using Remote Config in an Apple app, see Use Firebase Remote Config on Apple platforms .
Ensure that Remote Config is used in your
Podfile
:pod 'Firebase/RemoteConfig'
Add the following to the top of your app's
AppDelegate
file:سويفت
Note: This Firebase product is not available on macOS, Mac Catalyst, watchOS targets.import FirebaseRemoteConfig
ج موضوعية
Note: This Firebase product is not available on macOS, Mac Catalyst, watchOS targets.@import FirebaseRemoteConfig;
In your
AppDelegate
file, add the following code to thelaunchOptions
statements in theapplication:didFinishLaunchingWithOptions:
instance method:سويفت
Note: This product is not available on macOS, Mac Catalyst, watchOS targets.remoteConfig = RemoteConfig.remoteConfig() // You can change the "false" below to "true" to permit more fetches when validating // your app, but you should change it back to "false" or remove this statement before // distributing your app in production. let remoteConfigSettings = RemoteConfigSettings(developerModeEnabled: false) remoteConfig.configSettings = remoteConfigSettings! // Load in-app defaults from a plist file that sets perf_disable to false until // you update values in the Firebase console. remoteConfig.setDefaultsFromPlistFileName("RemoteConfigDefaults") // Important! This needs to be applied before FirebaseApp.configure() if !remoteConfig["perf_disable"].boolValue { // The following line disables all automatic (out-of-the-box) monitoring Performance.sharedInstance().isInstrumentationEnabled = false // The following line disables all custom monitoring Performance.sharedInstance().isDataCollectionEnabled = false } else { Performance.sharedInstance().isInstrumentationEnabled = true Performance.sharedInstance().isDataCollectionEnabled = true } // Use Firebase library to configure APIs FirebaseApp.configure()
ج موضوعية
Note: This Firebase product is not available on macOS, Mac Catalyst, watchOS targets.self.remoteConfig = [FIRRemoteConfig remoteConfig]; // You can change the NO below to YES to permit more fetches when validating // your app, but you should change it back to NO or remove this statement before // distributing your app in production. FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:NO]; self.remoteConfig.configSettings = remoteConfigSettings; // Load in-app defaults from a plist file that sets perf_disable to false until // you update values in the Firebase console. [self.remoteConfig setDefaultsFromPlistFileName:@"RemoteConfigDefaults"]; // Important! This needs to be applied before [FIRApp configure] if (!self.remoteConfig[@"perf_disable"].numberValue.boolValue) { // The following line disables all automatic (out-of-the-box) monitoring [FIRPerformance sharedInstance].instrumentationEnabled = NO; // The following line disables all custom monitoring [FIRPerformance sharedInstance].dataCollectionEnabled = NO; } else { [FIRPerformance sharedInstance].instrumentationEnabled = YES; [FIRPerformance sharedInstance].dataCollectionEnabled = YES; } // Use Firebase library to configure APIs [FIRApp configure];
In
ViewController.m
, or another implementation file used by your app, add the following code to fetch and activate Remote Config values:سويفت
Note: This Firebase product is not available on macOS, Mac Catalyst, watchOS targets.//RemoteConfig fetch and activation in your app, shortly after startup remoteConfig.fetch(withExpirationDuration: TimeInterval(30.0)) { (status, error) -> Void in if status == .success { print("Config fetched!") self.remoteConfig.activateFetched() } else { print("Config not fetched") print("Error \(error!.localizedDescription)") } }
ج موضوعية
Note: This Firebase product is not available on macOS, Mac Catalyst, watchOS targets.//RemoteConfig fetch and activation in your app, shortly after startup [self.remoteConfig fetchWithExpirationDuration:30.0 completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *error) { if (status == FIRRemoteConfigFetchStatusSuccess) { NSLog(@"Config fetched!"); [self.remoteConfig activateFetched]; } else { NSLog(@"Config not fetched"); NSLog(@"Error %@", error.localizedDescription); } }];
To disable Performance Monitoring in the Firebase console, create a perf_disable parameter in your app's project, then set its value to
true
.If you set the value of perf_disable to
false
, Performance Monitoring remains enabled.
Disable automatic or custom data collection separately
You can make some changes to the code shown above and in the Firebase console to let you disable all automatic (out-of-the-box) monitoring separately from custom monitoring.
Add the following code to the
launchOptions
statements in theapplication:didFinishLaunchingWithOptions:
instance method (instead of what's shown above for the same instance method):سويفت
Note: This Firebase product is not available on macOS, Mac Catalyst, watchOS targets.remoteConfig = FIRRemoteConfig.remoteConfig() let remoteConfigSettings = FIRRemoteConfigSettings(developerModeEnabled: true) remoteConfig.configSettings = remoteConfigSettings! // Important! This needs to be applied before FirebaseApp.configure() if remoteConfig["perf_disable_auto"].boolValue { // The following line disables all automatic (out-of-the-box) monitoring Performance.sharedInstance().isInstrumentationEnabled = false } else { Performance.sharedInstance().isInstrumentationEnabled = true } if remoteConfig["perf_disable_manual"].boolValue { // The following line disables all custom monitoring Performance.sharedInstance().isDataCollectionEnabled = false } else { Performance.sharedInstance().isDataCollectionEnabled = true } // Use Firebase library to configure APIs FirebaseApp.configure()
ج موضوعية
Note: This Firebase product is not available on macOS, Mac Catalyst, watchOS targets.self.remoteConfig = [FIRRemoteConfig remoteConfig]; FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:YES]; self.remoteConfig.configSettings = remoteConfigSettings; // Important! This needs to be applied before [FirebaseApp configure] if (self.remoteConfig[@"perf_disable_auto"].numberValue.boolValue) { // The following line disables all automatic (out-of-the-box) monitoring [FIRPerformance sharedInstance].instrumentationEnabled = NO; } else { [FIRPerformance sharedInstance].instrumentationEnabled = YES; } if (self.remoteConfig[@"perf_disable_manual"].numberValue.boolValue) { // The following line disables all custom monitoring [FIRPerformance sharedInstance].dataCollectionEnabled = NO; } else { [FIRPerformance sharedInstance].dataCollectionEnabled = YES; } // Use Firebase library to configure APIs [FirebaseApp configure];
Complete the following in the Firebase console:
- To disable all automatic (out-of-the-box) monitoring, create a perf_disable_auto parameter in your app's project, then set its value to
true
. - To disable all custom monitoring, create a perf_disable_manual parameter in your app's project, then set its value to
true
.
- To disable all automatic (out-of-the-box) monitoring, create a perf_disable_auto parameter in your app's project, then set its value to