> For the complete documentation index, see [llms.txt](https://docs.electricbolt.co.nz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.electricbolt.co.nz/getting-started/react-native-integration/ios-native-module-integration.md).

# iOS native module integration

In your Xcode project create a new Objective-C class named `RCTAppfiguratePlugin`.

> Example `RCTAppfiguratePlugin.h` header file

```objectivec
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>

NS_ASSUME_NONNULL_BEGIN

@interface RCTAppfigurateModule : RCTEventEmitter<RCTBridgeModule>
@end

NS_ASSUME_NONNULL_END
```

> Example `RCTAppfiguratePlugin.m` implementation file

```objectivec
#import "RCTAppfigurateModule.h"
@import AppfigurateLibrary;

@interface APLConfiguration ()
- (NSDictionary*) dictionaryFromConfiguration;
@end

@implementation RCTAppfigurateModule {
  NSDictionary* cachedConfiguration;
  BOOL observing;
}

RCT_EXPORT_MODULE();

- (instancetype) init {
  self = [super init];
  if (self) {
    cachedConfiguration = [[APLConfiguration sharedConfiguration] dictionaryFromConfiguration];
    APLAddConfigurationUpdatedBlock(^(NSNotification* notification) {
      self->cachedConfiguration = [[APLConfiguration sharedConfiguration] dictionaryFromConfiguration];
      if (self->observing) {
        NSObject* action = notification.userInfo[APLConfigurationUpdatedAction];
        if (action == nil) {
          action = [NSNull null];
        }
        [self sendEventWithName: @"APLConfigurationUpdated" body:
          @{@"APLConfigurationUpdatedAction": action}];
      }
    });
  }
  return self;
}

RCT_EXPORT_METHOD(nativeValue: (NSString*) propertyName resolver: (RCTPromiseResolveBlock) resolve rejecter: (RCTPromiseRejectBlock) reject) {
  resolve([cachedConfiguration objectForKey: propertyName]);
}

RCT_EXPORT_METHOD(description: (RCTPromiseResolveBlock) resolve rejecter: (RCTPromiseRejectBlock) reject) {
  resolve([[APLConfiguration sharedConfiguration] description]);
}

RCT_EXPORT_METHOD(modifications: (RCTPromiseResolveBlock) resolve rejecter: (RCTPromiseRejectBlock) reject) {
  resolve([[APLConfiguration sharedConfiguration] modifications]);
}

RCT_EXPORT_METHOD(version: (RCTPromiseResolveBlock) resolve rejecter: (RCTPromiseRejectBlock) reject) {
  resolve(APLVersion());
}

RCT_EXPORT_METHOD(setLogging: (BOOL) logging resolve: (RCTPromiseResolveBlock) resolve rejecter: (RCTPromiseRejectBlock) reject) {
  APLSetLogging(logging);
  resolve(nil);
}

RCT_EXPORT_METHOD(saveConfiguration: (RCTPromiseResolveBlock) resolve rejecter: (RCTPromiseRejectBlock) reject) {
  APLSaveConfiguration();
  resolve(nil);
}

RCT_EXPORT_METHOD(restoreConfiguration: (RCTPromiseResolveBlock) resolve rejecter: (RCTPromiseRejectBlock) reject) {
  APLRestoreConfiguration();
  resolve(nil);
}

- (void) startObserving {
  observing = YES;
}

- (void) stopObserving {
  observing = NO;
}

- (NSArray<NSString*>*) supportedEvents {
  return @[@"APLConfigurationUpdated"];
}

@end

```

The iOS native module is now integrated. Now jump to [JavaScript integration](/getting-started/react-native-integration/javascript-integration.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.electricbolt.co.nz/getting-started/react-native-integration/ios-native-module-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
