--- title: "Callbacks API" slug: "oapps-igios-callback-capi-9-0-1" updated: 2026-11-19T15:58:50Z published: 2026-11-19T15:58:50Z canonical: "docs.onespan.com/oapps-igios-callback-capi-9-0-1" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.onespan.com/llms.txt > Use this file to discover all available pages before exploring further. # Callbacks API When App Shielding performs security checks, it can either be configured to exit the application when a security problem is detected (e.g., Exit on hooking frameworks), or it can be configured to notify the application via a callback. By handling the callback, you can, for instance, inform the user about the possible security threat. Callbacks currently occur when the application registers an event handler with the Shield SDK’s `prm_event_handler_add()` function, when the application launches, and when the application is moved to the foreground. To implement callbacks 1. Ensure the relevant security feature is enabled in the configuration (e.g., Check jailbreak), and is not configured to exit the application when the security problem is detected (e.g., Exit on jailbreak). 2. Ensure that `SDK/C/ShieldSDK.xcframework` is included in the project. 3. Include the `ShieldSDK/event_manager.h` header in any source files that will interact with the callback APIs. 4. Define a `struct prm_event_cbs` and assign a function to each event you want to handle. `NULL` members are skipped when the corresponding event occurs. 5. Pair the callbacks with a context pointer in a `struct prm_event_handler` and register it by calling `prm_event_handler_add()`. The `ctx` pointer is passed back to every callback, so you can use it to carry your own state. It must remain valid for as long as the handler is registered. Registration should be performed as early as possible, because many security checks are performed right after the application has launched. `prm_event_handler_add()` returns `0` on success and a non-zero value if the handler could not be registered. You can add as many handlers as you like, and each one receives callbacks for as long as the app is running or until the handler is removed. Handlers are removed with `prm_event_handler_del()`. The handler is matched on both the context pointer and every function pointer in the callback struct, so you must pass a `struct prm_event_handler` that is identical to the one you registered. ## Example implementations The following example sets up handlers for jailbreak and screenshot checks. ```c #include ... static void on_jailbreak(void *ctx, bool isjb) {    (void)ctx;    if (isjb)        handle_device_is_jailbroken(); } static void on_screenshot(void *ctx) {    (void)ctx;    handle_screenshot_detected(); } __attribute__((constructor)) static void shield_callbacks_init(void) {    struct prm_event_handler handler = {        .ctx = NULL,        .cbs = {            .jailbreak = on_jailbreak,            .screenshot = on_screenshot,        },    };    prm_event_handler_add(handler); } ``` > Some callbacks, like `jailbreak`, are always triggered and provide a boolean value that indicates whether the security check is positive. Other callbacks, like `screenshot`, are only triggered when the offending event is detected and thus provide nosuch value. ## List of callbacks on iOS The following members of `struct prm_event_cbs` are called after App Shielding has performed its security checks, where every callback receives the registered context pointer as its first argument: | Callback | Description | | --- | --- | | `jailbreak` | Provides a boolean that indicates whether the device on which the application is running is jailbroken. Some detectors for Dopamine RootHide jailbreaks currently do not trigger a callback. | | `sip` | Provides a boolean that indicates whether the app is running on a Mac with System Integrity Protection (SIP) disabled. | | `repackaging` | Provides a boolean that indicates whether the app has been repackaged. If the application is running in a simulator, then this callback is never called. | | `recording` | Provides a boolean that indicates whether one or more screens that the app is using are being recorded. | | `dev_mode` | Provides a boolean that indicates whether Developer Mode is enabled on the device. Developer Mode was added in iOS 16, so this callback always provides `false` on devices running iOS 15 and below. It is never called on non-iOS devices (e.g., tvOS). | | `debugger` | Provides a boolean that indicates whether a debugger is attached to the host application. If App Shielding is configured to block debuggers, then this callback is never called. | | `vpn` | Provides a boolean that indicates whether one of the device’s network connections has a virtual private network (VPN) enabled. | | `emulator` | Called when App Shielding has detected that the application is being run in an emulator. | | `screenshot` | Called when App Shielding discovers that a screenshot of the application has been taken. If the application is running in a simulator, this callback is never called. | | `lib_prevented` | Called when App Shielding has prevented an untrusted library from being injected into the process during runtime. This callback is deprecated and does not trigger on iOS/tvOS 17 or higher and macOS 14 or higher. Instead, the app terminates unexpectedly. | | `lib_detected` | Called when App Shielding has detected that there are untrusted libraries in the process. A repackaged app can also trigger this callback in addition to the repackaging callback. In production, you should configure App Shielding to use the Exit On Library Injection option and not rely on handling a callback. | | `hooking` | Called when App Shielding has detected that there are hooking frameworks in the process. In production, however, you should configure App Shielding to use the the Exit On Hooking Frameworks option and not rely on handling a callback. | > Exit on... security options like Exit on Jailbreak will cause the application to immediately exit before the corresponding callback is triggered. Also note that some of these options, like Exit on Repackaging, are always enabled in release mode. ## Debugging: manual triggering of callbacks For debugging purposes, most callbacks can be manually triggered using the functions declared in the `event_trigger.h` header. Each function takes the delay, in seconds, before the event is delivered. The following example triggers the `jailbreak` callback with a status of `true` (i.e., the device is jailbroken) after a delay of two second: ```c #include ... #ifdef DEBUG    prm_event_trigger_jailbreak(true, 2); #endif ``` To immediately trigger the callback, set `afterDelay` to `0`. > Callback triggers are designed for debugging purposes only and should be conditionally applied to debug builds or removed from the app code entirely before running the Shielding Tool on the app. The app will terminate unexpectedly if callback triggers are present in the App Shielding-protected version of the app. ### Available callback triggers The following functions accept a boolean status value as the first argument and a delay in seconds as the second argument: ```c void prm_event_trigger_jailbreak(bool status, int64_t delay); void prm_event_trigger_repackaging(bool status, int64_t delay); void prm_event_trigger_recording(bool status, int64_t delay); void prm_event_trigger_debugger(bool status, int64_t delay); void prm_event_trigger_vpn(bool status, int64_t delay); void prm_event_trigger_developer_mode(bool status, int64_t delay); ``` The following functions only accept a delay argument: ```c void prm_event_trigger_emulator(int64_t delay); void prm_event_trigger_library_prevented(int64_t delay); void prm_event_trigger_library_detected(int64_t delay); void prm_event_trigger_hooking(int64_t delay); void prm_event_trigger_screenshot(int64_t delay); ``` The `prm_event_trigger_library_prevented()` function is deprecated and will be removed in a future release of App Shielding. When App Shielding performs security checks, it can either be configured to exit the application when a security problem is detected (e.g., Exit on hooking frameworks), or it can be configured to notify the application via a callback. By handling the callback, you can, for instance, inform the user about the possible security threat. Callbacks currently occur when the application registers an event handler with the Shield SDK’s `prm_event_handler_add()` function, when the application launches, and when the application is moved to the foreground. To implement callbacks 1. Ensure the relevant security feature is enabled in the configuration (e.g., Check jailbreak), and is not configured to exit the application when the security problem is detected (e.g., Exit on jailbreak). 2. Ensure that `SDK/C/ShieldSDK.xcframework` is included in the project. 3. Include the `ShieldSDK/event_manager.h` header in any source files that will interact with the callback APIs. 4. Define a `struct prm_event_cbs` and assign a function to each event you want to handle. `NULL` members are skipped when the corresponding event occurs. 5. Pair the callbacks with a context pointer in a `struct prm_event_handler` and register it by calling `prm_event_handler_add()`. The `ctx` pointer is passed back to every callback, so you can use it to carry your own state. It must remain valid for as long as the handler is registered. Registration should be performed as early as possible, because many security checks are performed right after the application has launched. `prm_event_handler_add()` returns `0` on success and a non-zero value if the handler could not be registered. You can add as many handlers as you like, and each one receives callbacks for as long as the app is running or until the handler is removed. Handlers are removed with `prm_event_handler_del()`. The handler is matched on both the context pointer and every function pointer in the callback struct, so you must pass a `struct prm_event_handler` that is identical to the one you registered. ## Example implementations The following example sets up handlers for jailbreak and screenshot checks. ```c #include ... static void on_jailbreak(void *ctx, bool isjb) {    (void)ctx;    if (isjb)        handle_device_is_jailbroken(); } static void on_screenshot(void *ctx) {    (void)ctx;    handle_screenshot_detected(); } __attribute__((constructor)) static void shield_callbacks_init(void) {    struct prm_event_handler handler = {        .ctx = NULL,        .cbs = {            .jailbreak = on_jailbreak,            .screenshot = on_screenshot,        },    };    prm_event_handler_add(handler); } ``` > Some callbacks, like `jailbreak`, are always triggered and provide a boolean value that indicates whether the security check is positive. Other callbacks, like `screenshot`, are only triggered when the offending event is detected and thus provide nosuch value. ## List of callbacks on iOS The following members of `struct prm_event_cbs` are called after Shield has performed its security checks, where every callback receives the registered context pointer as its first argument: | Callback | Description | | --- | --- | | `jailbreak` | Provides a boolean that indicates whether the device on which the application is running is jailbroken. Some detectors for Dopamine RootHide jailbreaks currently do not trigger a callback. | | `sip` | Provides a boolean that indicates whether the app is running on a Mac with System Integrity Protection (SIP) disabled. | | `repackaging` | Provides a boolean that indicates whether the app has been repackaged. If the application is running in a simulator, then this callback is never called. | | `recording` | Provides a boolean that indicates whether one or more screens that the app is using are being recorded. | | `dev_mode` | Provides a boolean that indicates whether Developer Mode is enabled on the device. Developer Mode was added in iOS 16, so this callback always provides `false` on devices running iOS 15 and below. It is never called on non-iOS devices (e.g., tvOS). | | `debugger` | Provides a boolean that indicates whether a debugger is attached to the host application. If App Shielding is configured to block debuggers, then this callback is never called. | | `vpn` | Provides a boolean that indicates whether one of the device’s network connections has a virtual private network (VPN) enabled. | | `emulator` | Called when App Shielding has detected that the application is being run in an emulator. | | `screenshot` | Called when App Shielding discovers that a screenshot of the application has been taken. If the application is running in a simulator, this callback is never called. | | `lib_prevented` | Called when App Shielding has prevented an untrusted library from being injected into the process during runtime. This callback is deprecated and does not trigger on iOS/tvOS 17 or higher and macOS 14 or higher. Instead, the app terminates unexpectedly. | | `lib_detected` | Called when App Shielding has detected that there are untrusted libraries in the process. A repackaged app can also trigger this callback in addition to the repackaging callback. In production, you should configure App Shielding to use the Exit On Library Injection option and not rely on handling a callback. | | `hooking` | Called when App Shielding has detected that there are hooking frameworks in the process. In production, however, you should configure App Shielding to use the the Exit On Hooking Frameworks option and not rely on handling a callback. | > Exit on... security options like Exit on Jailbreak will cause the application to immediately exit before the corresponding callback is triggered. Also note that some of these options, like Exit on Repackaging, are always enabled in release mode. ## Debugging: manual triggering of callbacks For debugging purposes, most callbacks can be manually triggered using the functions declared in the `event_trigger.h` header. Each function takes the delay, in seconds, before the event is delivered. The following example triggers the `jailbreak` callback with a status of `true` (i.e., the device is jailbroken) after a delay of two second: ```c #include ... #ifdef DEBUG    prm_event_trigger_jailbreak(true, 2); #endif ``` To immediately trigger the callback, set `afterDelay` to `0`. > Callback triggers are designed for debugging purposes only and should be conditionally applied to debug builds or removed from the app code entirely before running the Shielding Tool on the app. The app will terminate unexpectedly if callback triggers are present in the App Shielding-protected version of the app. ### Available callback triggers The following functions accept a boolean status value as the first argument and a delay in seconds as the second argument: ```c void prm_event_trigger_jailbreak(bool status, int64_t delay); void prm_event_trigger_repackaging(bool status, int64_t delay); void prm_event_trigger_recording(bool status, int64_t delay); void prm_event_trigger_debugger(bool status, int64_t delay); void prm_event_trigger_vpn(bool status, int64_t delay); void prm_event_trigger_developer_mode(bool status, int64_t delay); ``` The following functions only accept a delay argument: ```c void prm_event_trigger_emulator(int64_t delay); void prm_event_trigger_library_prevented(int64_t delay); void prm_event_trigger_library_detected(int64_t delay); void prm_event_trigger_hooking(int64_t delay); void prm_event_trigger_screenshot(int64_t delay); ``` The `prm_event_trigger_library_prevented()` function is deprecated and will be removed in a future release of App Shielding.