Stay organized with collections
Save and categorize content based on your preferences.
ExperimentController
classExperimentController:NSObject
This class is for Firebase services to handle experiments updates to Firebase Analytics.
Experiments can be set, cleared and updated through this controller.
Updates the list of experiments with an optional completion handler. Experiments already
existing in payloads are not affected, whose state and payload is preserved. This method
compares whether the experiments have changed or not by their variant ID. This runs in a
background queue and calls the completion handler when finished executing.
Parameters
origin
The originating service affected by the experiment.
events
A list of event names to be used for logging experiment lifecycle events,
if they are not defined in the payload.
policy
The policy to handle new experiments when slots are full.
lastStartTime
The last known experiment start timestamp for this affected service.
(Timestamps are specified by the number of seconds from 00:00:00 UTC on 1
January 1970.).
payloads
List of experiment metadata.
completionHandler
Code to be executed after experiments are updated in the background
thread.
Returns the latest experiment start timestamp given a current latest timestamp and a list of
experiment payloads. Timestamps are specified by the number of seconds from 00:00:00 UTC on 1
January 1970.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2021-02-11 UTC."],[],[],null,["# FirebaseABTesting Framework Reference\n\nExperimentController\n====================\n\n class ExperimentController : NSObject\n\nThis class is for Firebase services to handle experiments updates to Firebase Analytics.\nExperiments can be set, cleared and updated through this controller.\n- `\n ``\n ``\n `\n\n ### [sharedInstance()](#/c:objc(cs)FIRExperimentController(cm)sharedInstance)\n\n `\n ` \n Returns the FIRExperimentController singleton. \n\n #### Declaration\n\n Swift \n\n class func sharedInstance() -\u003e ExperimentController\n\n- `\n ``\n ``\n `\n\n ### [-updateExperimentsWithServiceOrigin:events:policy:lastStartTime:payloads:completionHandler:](#/c:objc(cs)FIRExperimentController(im)updateExperimentsWithServiceOrigin:events:policy:lastStartTime:payloads:completionHandler:)\n\n `\n ` \n Updates the list of experiments with an optional completion handler. Experiments already\n existing in payloads are not affected, whose state and payload is preserved. This method\n compares whether the experiments have changed or not by their variant ID. This runs in a\n background queue and calls the completion handler when finished executing. \n\n #### Parameters\n\n |---------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*origin*` ` | The originating service affected by the experiment. |\n | ` `*events*` ` | A list of event names to be used for logging experiment lifecycle events, if they are not defined in the payload. |\n | ` `*policy*` ` | The policy to handle new experiments when slots are full. |\n | ` `*lastStartTime*` ` | The last known experiment start timestamp for this affected service. (Timestamps are specified by the number of seconds from 00:00:00 UTC on 1 January 1970.). |\n | ` `*payloads*` ` | List of experiment metadata. |\n | ` `*completionHandler*` ` | Code to be executed after experiments are updated in the background thread. |\n\n- `\n ``\n ``\n `\n\n ### [latestExperimentStartTimestampBetweenTimestamp(_:andPayloads:)](#/c:objc(cs)FIRExperimentController(im)latestExperimentStartTimestampBetweenTimestamp:andPayloads:)\n\n `\n ` \n Returns the latest experiment start timestamp given a current latest timestamp and a list of\n experiment payloads. Timestamps are specified by the number of seconds from 00:00:00 UTC on 1\n January 1970. \n\n #### Declaration\n\n Swift \n\n func latestExperimentStartTimestampBetweenTimestamp(_ timestamp: TimeInterval, andPayloads payloads: [Data]) -\u003e TimeInterval\n\n #### Parameters\n\n |-------------------|----------------------------------------------------------------------------------------------|\n | ` `*timestamp*` ` | Current latest experiment start timestamp. If not known, affected service should specify -1; |\n | ` `*payloads*` ` | List of experiment metadata. |\n\n- `\n ``\n ``\n `\n\n ### [validateRunningExperiments(forServiceOrigin:running:)](#/c:objc(cs)FIRExperimentController(im)validateRunningExperimentsForServiceOrigin:runningExperimentPayloads:)\n\n `\n ` \n Expires experiments that aren't in the list of running experiment payloads. \n\n #### Declaration\n\n Swift \n\n func validateRunningExperiments(forServiceOrigin origin: String, running payloads: [ABTExperimentPayload])\n\n #### Parameters\n\n |------------------|-----------------------------------------------------|\n | ` `*origin*` ` | The originating service affected by the experiment. |\n | ` `*payloads*` ` | The list of valid, running experiments. |\n\n- `\n ``\n ``\n `\n\n ### [activateExperiment(_:forServiceOrigin:)](#/c:objc(cs)FIRExperimentController(im)activateExperiment:forServiceOrigin:)\n\n `\n ` \n Directly sets a given experiment to be active. \n\n #### Declaration\n\n Swift \n\n func activateExperiment(_ experimentPayload: ABTExperimentPayload, forServiceOrigin origin: String)\n\n #### Parameters\n\n |---------------------------|----------------------------------------------------------|\n | ` `*experimentPayload*` ` | The payload for the experiment that should be activated. |\n | ` `*origin*` ` | The originating service affected by the experiment. |"]]