Appfigurate™️
HomeDocumentation
  • Introducing Appfigurate™️ 3
  • Getting Started
    • Getting Started
    • Examples
    • Upgrade guide
      • v1.4.0 to v2.2.0
      • v2.1.1 to v2.2.0
      • v2.2.1 to v3.0.0
      • v3.2.1 to v4.0.0
    • iOS native app integration
      • iOS app extension integration
    • watchOS app integration
      • watchOS app extension integration
    • Android native app integration
    • Mobile Flutter integration
      • Flutter iOS
      • Flutter Android
    • React Native integration
      • iOS native module integration
      • Android native module integration
      • JavaScript integration
    • Third party remote configuration providers
      • Firebase Remote Config
      • Launch Darkly
      • Other third party remote configuration providers
  • Configuration subclasses
    • Supported property types
      • Boolean
      • Integer
      • Float
      • Double
      • Plain String
      • Encrypted String
    • Custom executable actions
    • Slider icon types
  • Additional reading
    • Info.plist options
    • AndroidManifest.xml options
    • Displaying overridden configuration
    • Security
      • Best practice
      • Encryption
      • Export compliance
      • App Store compliance
      • PrivacyInfo.xcprivacy
      • Rotating your private key
  • Automation testing
    • iOS native app automation testing
    • Android native automation testing
  • API
    • iOS and watchOS API
    • Android API
    • Mobile Flutter API
    • React Native API
  • Appfigurate User Guide
    • Introduction
    • Main menu
    • Select app
    • Add app
    • Import app
    • Install example apps
    • Settings
      • Passcode Lock
      • Restore
      • Backup
      • Delete all apps and Settings
      • Analytics
    • Edit app
    • Configure app
    • Permissions
  • Appfigurate SE user guide
    • Introduction
    • Manual encryption
      • ENCRYPTED_STRING macro/function
      • ENCRYPTED_STRING_IOS_WATCHOS macro/function
    • Setup iOS Simulator app
    • Setup Android Emulator app
    • Xcode source editor extension
      • Troubleshooting
    • Real device cloud testing services
      • BrowserStack
  • LEGAL
    • License Agreement
    • Privacy Policy
    • Release History
    • Third party notices
Powered by GitBook
On this page
  1. Configuration subclasses

Custom executable actions

PreviousEncrypted StringNextSlider icon types

Last updated 5 months ago

Action UI

Allows the custom executable action to be executed by Appfigurate. Any configuration properties you modify in the action method are persisted. Actions appear below properties in the Appfigurate UI.

Swift prototype

As you cannot annotate a Swift method with a property wrapper, your action methods must be specified manually.

Replace XXX with the name of your action (e.g. freshInstall)

func XXXDescription() -> String
func XXXAction()
func XXXRestart() -> Bool

If you return true from your XXXRestart() method, then the app will be restarted after the action method is executed.

Swift example

@objcMembers class Configuration: APLConfiguration {

    func freshInstallDescription() -> String {
        return "Resets application to fresh install state"
    }
    
    func freshInstallAction() {
        let defs = UserDefaults.standard
        let dict = defs.dictionaryRepresentation()
        for key in dict.keys {
            defs.removeObject(forKey: key)
        }
        defs.synchronize()
    }

    func freshInstallRestart() -> Bool {
        return false
    }
    ...

Objective-C prototype

ACTION_METHOD(actionName, description, restart) { ... }

If restart is YES then the app will be restarted after the action method is executed.

Objective-C example

@implementation Configuration

ACTION_METHOD(freshInstall, "Resets application to fresh install state", NO) {
    NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
    NSDictionary* dict = [defs dictionaryRepresentation];
    for (id key in dict) {
        [defs removeObjectForKey: key];
    }
    [defs synchronize];
}
...

Kotlin prototype

@ActionMethod(description, restart)

If restart is true then the app will be restarted after the action method is executed.

Kotlin example

@ActionMethod(description = "Resets application to fresh install state", restart = false)
fun freshInstall() {
    var preferences = context.getSharedPreferences("storage", Context.MODE_PRIVATE)
    var editor = preferences.edit()
    editor.clear()
    editor.apply()
}

Java prototype

@ActionMethod(description, restart)

If restart is true then the app will be restarted after the action method is executed.

Java example

@ActionMethod(description = "Resets application to fresh install state", restart = false)
public void freshInstall() {
    SharedPreferences preferences = context.getSharedPreferences("storage", MODE_PRIVATE);
    SharedPreferences.Editor editor = preferences.edit();
    editor.clear();
    editor.apply();
}

Dart example

import 'package:appfigurateflutter/appfigurateflutter.dart';

class ExampleConfiguration extends APLNativeConfiguration {
  factory ExampleConfiguration() => _instance;

  static final ExampleConfiguration _instance = ExampleConfiguration._internal();

  ExampleConfiguration._internal();

  @override
  void actionExecuted(String action) {
    if (action == 'freshInstall') {
      ...
    }
  }
...

JavaScript example

import {
  NativeModules,
  NativeEventEmitter,
} from 'react-native';

const {Appfigurate} = NativeModules;
const AppfigurateEvents = new NativeEventEmitter(NativeModules.Appfigurate);

AppfigurateEvents.addListener('APLConfigurationUpdated', result => {
  if (result.APLConfigurationUpdatedAction == "freshInstall") {
    ...
  }
});

When an action is executed in the underlying native (iOS) or (Android) subclass, Flutter is also notified. Override the method in as follows to receive the action:

When an action is executed in the underlying native (iOS) or (Android) subclass, React Native is also notified. Subscribe to an event emitter to receive the action:

APLConfiguration
nz.co.electricbolt.appfiguratelibrary.Configuration
actionExecuted(action)
APLNativeConfiguration
APLConfiguration
nz.co.electricbolt.appfiguratelibrary.Configuration