APLConfiguration

Objective-C

@interface APLConfiguration : NSObject

Swift

class APLConfiguration : NSObject

Target availability: iOS apps, iOS app extensions, watchOS apps, watchOS app extensions.

Subclass APLConfiguration and declare/implement properties to be configured using the Appfigurate app (Simulator or App Store) with the BOOL_PROPERTY, INT_PROPERTY_XXXX, FLOAT_PROPERTY_XXXX, DOUBLE_PROPERTY_XXXX, STRING_PROPERTY_XXXX, ENCRYPTED_STRING_PROPERTY_LIST_EDIT, REMOTE_BOOL_PROPERTY_EDIT, REMOTE_INT_PROPERTY_EDIT, REMOTE_DOUBLE_PROPERTY_EDIT or REMOTE_STRING_PROPERTY_EDIT macros (Objective-C) or @BoolProperty, @IntPropertyXXXX, @FloatPropertyXXXX, @StringPropertyXXXX, @EncryptedStringPropertyListEdit, @RemoteBoolProperty, @RemoteIntPropertyEdit, @RemoteDoublePropertyEdit or @RemoteStringPropertyEdit property wrappers (Swift). You must override the -[APLConfiguration publicKey], -[APLConfiguration reset] and -[APLConfiguration allowInvalidSignatures] methods.

  • Target availability: iOS apps, iOS app extensions, watchOS apps, watchOS app extensions.

    The singleton instance of the APLConfiguration subclass. The instance is automatically instantiated on application, extension or XCUITest bundle startup. It is permissible to have a multi-level class hierarchy if required. e.g. AppConfiguration ‣ CommonConfiguration ‣ APLConfiguration.

    Declaration

    Objective-C

    + (APLConfiguration *_Nonnull)sharedConfiguration;

    Swift

    class func shared() -> APLConfiguration
  • Target availability: iOS apps, iOS app extensions, watchOS apps, watchOS app extensions.

    Override to return the public key for this application. Use the Appfigurate app (Simulator or App Store) to output the public key.

    AppfigurateLibraryException will be thrown if you do not override this method.

    Objective-C example (abbreviated)

    - (NSString*) publicKey {
      // 41 36 87 71 0D 05
      return @"-----BEGIN PUBLIC KEY-----\n" \
        "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5s2YXfKStHzgUEkY+KDm\n" \
        ...
        "6QIDAQAB\n" \
        "-----END PUBLIC KEY-----\n";
    }
    

    Swift example (abbreviated)

    override func publicKey() -> String {
      // 41 36 87 71 0D 05
      return "-----BEGIN PUBLIC KEY-----\n" +
        "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5s2YXfKStHzgUEkY+KDm\n" +
        ...
        "6QIDAQAB\n" +
        "-----END PUBLIC KEY-----\n"
    }
    

    Declaration

    Objective-C

    - (NSString *_Nonnull)publicKey;

    Swift

    func publicKey() -> String
  • Target availability: iOS apps, iOS app extensions, watchOS apps, watchOS app extensions.

    Return YES if invalid digital signatures are allowed to apply configuration (Debug builds), or NO if only a correct digital signature is acceptable (Release builds).

    AppfigurateLibraryException will be thrown if you do not override this method.

    For Swift, ensure that DEBUG is defined in your: App target ‣ Build Settings ‣ Swift Compiler - Custom Flags ‣ Active Compilation Conditions for the Debug build configuration.

    Objective-C example

    - (BOOL) allowInvalidSignatures {
      #if DEBUG
        return YES;
      #else
        return NO;
      #endif
    }
    

    Swift example

    override func allowInvalidSignatures() -> Bool {
      #if DEBUG
        return true
      #else
        return false
      #endif
    }
    

    Declaration

    Objective-C

    - (BOOL)allowInvalidSignatures;

    Swift

    func allowInvalidSignatures() -> Bool
  • Target availability: iOS apps, iOS app extensions, watchOS apps, watchOS app extensions.

    Optionally override to return a list of environment tags in the order you want them to appear in a segmented control in Appfigurates “Configure app” screen. Environment tags are case insensitive.

    AppfigurateLibraryException will be thrown if there are environment tags specified in the values of XXXX_PROPERTY_LIST, XXXX_PROPERTY_LIST_EDIT macros (Objective-C) or @XXXXPropertyList, or @XXXXPropertyListEdit property wrappers (Swift) that are not returned in the list from this method.

    Objective-C example

    - (NSArray<NSString*>*) environmentTags {
      return @[@"Dev", @"Test", @"Prod"];
    }
    

    Swift example

    override func environmentTags() -> [String] {
      return ["Dev", "Test", "Prod"]
    }
    

    Declaration

    Objective-C

    - (NSArray<NSString *> *_Nullable)environmentTags;

    Swift

    func environmentTags() -> [String]?
  • Target availability: iOS apps, iOS app extensions, watchOS apps, watchOS app extensions.

    Returns the textual representation of all properties. Property names are shortened to camel case and appended with the value, except for NSString* properties which omit the property name. Example: debugLog=5 would be returned as DL=5.

    Declaration

    Objective-C

    - (NSString *_Nonnull)description;

    Swift

    func description() -> String
  • Target availability: iOS apps, iOS app extensions, watchOS apps, watchOS app extensions.

    Returns the textual representation of all local properties that have non default values, and all remote properties that are locally overridden that have non default values. Property names are shortened to camel case and appended with the non default value, except for NSString* properties which omit the property name. Example: userInteractionTimeout=60.0 would be returned as UIT=60.0. See also APLConfigurationLabel class.

    Declaration

    Objective-C

    - (NSString *_Nonnull)modifications;

    Swift

    func modifications() -> String
  • Target availability: iOS apps, iOS app extensions, watchOS apps, watchOS app extensions.

    Set default values into your properties. You should ensure that all reset values conform to minimum and maximum values, list entries and regular expressions. Any values that are non-conforming will be output to the console.

    AppfigurateLibraryException will be thrown if you do not override this method.

    Objective-C example

    - (void) reset {
      self.decibelLimit = 5.1;
      self.foregroundColorHex = @"fa3bcc";
    }
    

    Swift example

    override func reset() {
      decibelLimit = 5.1
      foregroundColorHex = "fa3bcc"
    }
    

    Declaration

    Objective-C

    - (void)reset;

    Swift

    func reset()
  • Target availability: iOS apps, iOS app extensions.

    Returns a dictionary of remote properties default values as set in the -[APLConfiguration reset] method. Used when integrating with select third party remote configuration providers. See also APLFetchRemoteConfiguration().

    Objective-C Firebase Remote Config example

    [self.remoteConfig setDefaults: [[APLConfiguation sharedConfiguration] remoteDefaults]];
    

    Swift Firebase Remote Config example

    remoteConfig.setDefaults(APLConfiguration.shared().remoteDefaults())
    

    Objective-C Launch Darkly example

    Not applicable for Launch Darkly.

    Swift Launch Darkly example

    Not applicable for Launch Darkly.

    Declaration

    Objective-C

    - (NSDictionary<NSString *, NSObject *> *_Nonnull)remoteDefaults;

    Swift

    func remoteDefaults() -> [String : NSObject]
  • Target availability: iOS XCUITest automation testing.

    Generates a string that can be passed as launch arguments to the app under test, to apply configuration. The -[APLConfiguration allowInvalidSignatures] method in the app under test must return YES for this configuration to be applied (e.g. a Debug build).

    Objective-C example

    - (void) setUp {
      [super setUp];
      Configuration* c = [Configuration new];
      c.webserviceURL = "https://localhost:443/api";
      XCUIApplication* app = [XCUIApplication new];
      app.launchArguments = [c automationLaunchArguments]; // Convert apply operation to launch arguments.
      [app launch];
    }
    

    Swift example

    func setUp() {
      super.setUp()
      let c = Configuration()
      c.webserviceURL = "https://localhost:443/api"
      let app = XCUIApplication()
      app.launchArguments = c.automationLaunchArguments() // Convert apply operation to launch arguments.
      app.launch()
    }
    

    Declaration

    Objective-C

    - (NSArray<NSString *> *_Nonnull)automationLaunchArguments;

    Swift

    func automationLaunchArguments() -> [String]
  • Target availability: iOS XCUITest automation testing.

    Generates a string that can be passed as launch arguments to the app under test, to reset the configuration to defaults.

    Objective-C example

    - (void)setUp {
      [super setUp];
      Configuration* c = [Configuration new];
      XCUIApplication* app = [XCUIApplication new];
      app.launchArguments = [c automationLaunchArgumentsReset]; // Convert reset operation to launch arguments.
      [app launch];
    }
    

    Swift example

    func setUp() {
      super.setUp()
      let c = Configuration()
      let app = XCUIApplication()
      app.launchArguments = c.automationLaunchArgumentsReset() // Convert reset operation to launch arguments.
      app.launch()
    }
    

    Declaration

    Objective-C

    - (NSArray<NSString *> *_Nonnull)automationLaunchArgumentsReset;

    Swift

    func automationLaunchArgumentsReset() -> [String]
  • Target availability: iOS XCUITest automation testing.

    Generates a string that can be passed as launch arguments to the app under test, to execute a custom action. The -[APLConfiguration allowInvalidSignatures] method in the app under test must return YES for this action to be executed (e.g. a Debug build). See also -[APLConfiguration automationSendReadConfiguration].

    Objective-C example

    - (void)setUp {
      [super setUp];
      Configuration* c = [Configuration new];
      XCUIApplication* app = [XCUIApplication new];
      app.launchArguments = [c automationLaunchArgumentsWithAction: @"zeroLogs"]; // Convert execute action operation to launch arguments.
      [app launch];
    }
    

    Swift example

    func setUp() {
      super.setUp()
      let c = Configuration()
      let app = XCUIApplication()
      app.launchArguments = c.automationLaunchArguments(withAction: "zeroLogs") // Convert execute action operation to launch arguments.
      app.launch()
    }
    

    Declaration

    Objective-C

    - (NSArray<NSString *> *_Nonnull)automationLaunchArgumentsWithAction:
        (NSString *_Nonnull)action;

    Swift

    func automationLaunchArguments(withAction action: String) -> [String]
  • Target availability: iOS XCUITest automation testing.

    Applies this configuration to the app under test. The -[APLConfiguration allowInvalidSignatures] method in the app under test must return YES for this configuration to be applied (e.g. a Debug build). An AppfigurateLibraryException will be thrown after 10.0 seconds if the app under test fails to respond.

    Objective-C example

    - (void) testURL {
      XCUIApplication* app = [XCUIApplication new];
      [app launch];
      Configuration* c = [Configuration new];
      c.webserviceURL = "https://localhost:443/api"; // Change URL to mock server.
      [c automationSendConfiguration];               // Apply this configuration to the app under test.
      ...
    

    Swift example

    func testURL() {
      let app = XCUIApplication()
      app.launch()
      let c = Configuration()
      c.webServiceURL = "https://localhost:443/api" // Change URL to mock server.
      c.automationSendConfiguration()               // Apply this configuration to the app under test.
      ...
    

    Declaration

    Objective-C

    - (void)automationSendConfiguration;

    Swift

    func automationSendConfiguration()
  • Target availability: iOS XCUITest automation testing.

    Resets the configuration to defaults in the app under test. The -[APLConfiguration allowInvalidSignatures] method in the app under test must return YES for this configuration to be reset (e.g. a Debug build). An AppfigurateLibraryException will be thrown after 10.0 seconds if the app under test fails to respond.

    Objective-C example

    - (void) testURL {
      XCUIApplication* app = [XCUIApplication new];
      [app launch];
      Configuration* c = [Configuration new];
      [c automationSendResetConfiguration]; Resets the configuration to defaults in the app under test.
      ...
    

    Swift example

    func testURL() {
      let app = XCUIApplication()
      app.launch()
    
      let c = Configuration()
      c.automationSendResetConfiguration() Resets the configuration to defaults in the app under test.
      ...
    

    Declaration

    Objective-C

    - (void)automationSendConfigurationReset;

    Swift

    func automationSendConfigurationReset()
  • Target availability: iOS XCUITest automation testing.

    Execute a custom action in the app under test. The -[APLConfiguration allowInvalidSignatures] method in the app under test must return YES for this configuration to be applied (e.g. a Debug build). An AppfigurateLibraryException will be thrown after 10.0 seconds if the app under test fails to respond.

    Objective-C example

    - (void) testURL {
      XCUIApplication* app = [XCUIApplication new];
      [app launch];
    
      Configuration* c = [Configuration new];
      [c automationSendConfigurationWithAction: @"zeroLogs"]; // Execute a custom action in the app under test.
      ...
    

    Swift example

    func testURL() {
      let app = XCUIApplication()
      app.launch()
    
      let c = Configuration()
      c.debugLogging = true
      c.serverURL = "https://m.electricbolt.co.nz/test"
      c.automationSendConfiguration(withAction: "zeroLogs") // Execute a custom action in the app under test.
      ...
    

    Declaration

    Objective-C

    - (void)automationSendConfigurationWithAction:(NSString *_Nonnull)action;

    Swift

    func automationSendConfiguration(withAction action: String)
  • Target availability: iOS XCUITest automation testing.

    Updates this configuration by reading the configuration from the app under test. The -[APLConfiguration allowInvalidSignatures] method in the app under test must return YES for this method to succeed (e.g. a Debug build). An AppfigurateLibraryException will be thrown after 10.0 seconds if the app under test fails to respond. You should use this method after -[APLConfiguration automationLaunchArgumentsWithAction:] if the action in the app under test changes property values.

    Objective-C example

    - (void) testURL {
      Configuration* c = [Configuration new];
      XCUIApplication* app = [XCUIApplication new];
      app.launchArguments = [c automationLaunchArgumentsWithAction: @"zeroLogs"];
      [app launch];
      [c automationSendReadConfiguration]; // Updates this configuration by reading the configuration from the app under test.
      ...
    

    Swift example

    func testURL() {
      super.setUp()
      let c = Configuration()
      let app = XCUIApplication()
      app.launchArguments = c.automationLaunchArgumentsWithAction("zeroLogs")
      app.launch()
      c.automationSendReadConfiguration() // Updates this configuration by reading the configuration from the app under test.
      ...
    

    Declaration

    Objective-C

    - (void)automationSendReadConfiguration;

    Swift

    func automationSendReadConfiguration()