Functions

The following functions are available globally.

  • Availability: iOS apps only.

    Appfigurate performs method swizzling on UIApplicationDelegate to automatically invoke APLApplicationDidFinishLaunchingWithOptions().

    Developers who prefer not to use swizzling must do the following:

    • Add the Boolean APLInstallDelegateMethods=NO in your app’s Info.plist file.
    • Call APLApplicationDidFinishLaunchingWithOptions() in your app’s delegate application:didFinishLaunchingWithOptions: method.

    Objective-C example

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      APLApplicationDidFinishLaunchingWithOptions(launchOptions);
      return YES;
    }
    

    Swift example

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
      APLApplicationDidFinishLaunchingWithOptions(launchOptions)
      return true
    }
    

    Declaration

    Objective-C

    extern void APLApplicationDidFinishLaunchingWithOptions(
        NSDictionary *_Nullable launchOptions)
  • Availability: iOS apps only.

    Appfigurate performs method swizzling on UIApplicationDelegate to automatically invoke APLApplicationOpenURL().

    Developers who prefer not to use swizzling must do the following:

    • Add the Boolean APLInstallDelegateMethods=NO in your app’s Info.plist file.
    • Call APLApplicationOpenURL() in your app’s delegate application:openURL:sourceApplication:annotation: method.

    Objective-C example

    - (BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
      if (APLApplicationOpenURL(url) == YES) {
        return YES;
      }
      return NO;
    }
    

    Swift example

    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
      if APLApplicationOpenURL(url) {
        return true
      }
      return false
    }
    

    Declaration

    Objective-C

    extern BOOL APLApplicationOpenURL(NSURL *_Nonnull url)
  • Availability: watchOS extensions only.

    Appfigurate performs method swizzling on WKExtensionDelegate to automatically invoke APLApplicationDidFinishLaunching().

    Developers who prefer not to use swizzling must do the following:

    • Add the Boolean APLInstallDelegateMethods=NO in your extension’s Info.plist file.
    • Call APLApplicationDidFinishLaunching() in your extension’s delegate applicationDidFinishLaunching method.

    Objective-C example

    - (void) applicationDidFinishLaunching {
        APLApplicationDidFinishLaunching();
    }
    

    Swift example

    func applicationDidFinishLaunching() {
      APLApplicationDidFinishLaunching()
    }
    

    Declaration

    Objective-C

    extern void APLApplicationDidFinishLaunching()
  • Availability: watchOS extensions only.

    Receives configuration commands and payloads from the paired iPhone’s Appfigurate app.

    If your watch app has its own WCSessionDelegate, then call the APLSessionDidReceiveMessage() function from within your session:didReceiveMessage:replyHandler: method (see examples below). If your watch app does not have its own WCSessionDelegate then you do not need to do anything - Appfigurate library installs a WCSessionDelegate and calls APLSessionDidReceiveMessage() automatically.

    Objective-C example

    - (void) session: (WCSession*) session didReceiveMessage: (NSDictionary<NSString*,id>*) message
       replyHandler: (void (^)(NSDictionary<NSString*,id>*)) replyHandler {
       NSDictionary* reply = APLSessionDidReceiveMessage(message);
       if (reply != nil)
           replyHandler(reply);
       else
          ...
    

    Swift example

    func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) {
      let reply = APLSessionDidReceiveMessage(message)
      if reply != nil {
        replyHandler(reply)
      } else {
        ...
    

    Declaration

    Objective-C

    extern NSDictionary *_Nullable APLSessionDidReceiveMessage(
        NSDictionary<NSString *, id> *_Nonnull message)
  • Availability: All.

    Returns the version of the Appfigurate library in the format major.minor.patch. e.g. 5.1.2

    Declaration

    Objective-C

    extern NSString *_Nonnull APLVersion()
  • Availability: All.

    Registers a delegate method that will be called back when Appfigurate has updated the configuration of the app or extension. See also APLAddConfigurationUpdatedBlock() function for block based callback.

    Declaration

    Objective-C

    extern void APLAddConfigurationUpdatedListener(
        id<APLConfigurationUpdated> _Nonnull target)
  • Availability: All.

    Registers a block that will be called back when Appfigurate has updated the configuration of the app or extension. Returns: an opaque object to act as the observer. See also APLRemoveConfigurationUpdatedBlock(observer).

    Declaration

    Objective-C

    extern id<NSObject> _Nonnull APLAddConfigurationUpdatedBlock(
        APLConfigurationUpdatedBlock _Nonnull block)
  • Availability: All.

    Unregisters the delegate method that will be called back when Appfigurate has updated the configuration of the application. iOS8: you must call this method before deallocating the target. iOS9+: you may optionally call this method before the target is deallocated.

    Declaration

    Objective-C

    extern void APLRemoveConfigurationUpdatedListener(
        id<APLConfigurationUpdated> _Nonnull target)
  • Availability: All.

    Unregisters the block that will be called back when Appfigurate has updated the configuration of the application. You must call this method before the block is deallocated. The observer argument is the result of APLAddConfigurationUpdatedBlock(block).

    Declaration

    Objective-C

    extern void APLRemoveConfigurationUpdatedBlock(id<NSObject> _Nonnull observer)
  • Availability: All.

    When YES, Appfigurate library debugging messages will be output to the console. The default is NO. It is best practice to release applications with logging set to NO. Also see APLLogging key in the Info.plist file.

    Declaration

    Objective-C

    extern void APLSetLogging(BOOL logging)
  • Availability: All.

    Saves the configuration persisted in the keychain into temporary storage. Some apps have functionality to erase the keychain to reset apps back to ‘factory defaults’. This has the side effect of removing any Appfigurate configuration persisted in the keychain. Usage example:

    Objective-C example

    - (void) eraseKeychain {
       APLSaveConfiguration();
       NSArray* secItemClasses = @[(__bridge id) kSecClassGenericPassword,
         (__bridge id) kSecClassInternetPassword,
         (__bridge id) kSecClassCertificate,
         (__bridge id) kSecClassKey,
         (__bridge id) kSecClassIdentity];
       for (id secItemClass in secItemClasses) {
         NSDictionary *spec = @{(__bridge id)kSecClass: secItemClass};
         SecItemDelete((__bridge CFDictionaryRef)spec);
       }
       APLRestoreConfiguration();
    }
    

    Declaration

    Objective-C

    extern void APLSaveConfiguration()
  • Availability: All.

    Restores the configuration from temporary storage back into the keychain. See APLSaveConfiguration() for more details and usage example.

    Declaration

    Objective-C

    extern void APLRestoreConfiguration()