- 09 Jan 2025
- 1 Minute à lire
- SombreLumière
- PDF
Callbacks
- Mis à jour le 09 Jan 2025
- 1 Minute à lire
- SombreLumière
- PDF
When App Shielding performs security checks, it can either be configured to exit the application when a security problem is detected (e.g., [exitOnHookingFrameworks]), 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.
Delegate callbacks currently occur when the application registers an observer with the PRMShieldEventManager class from the Shield SDK during application launch, and when the application is moved to the foreground.
Follow these steps to implement callbacks:
To implement callbacks
Ensure the required security feature is enabled in the configuration (e.g., check Jailbreak) and that the feature is not configured to exit the application when this security problem is detected (e.g., exitOnJailbreak).
Add the App Shielding framework to your project. For more information, see Adding the framework.
Import the ShieldSDK/Shield.h umbrella header into any Objective-c source files that will interact with the callback APIs.
Create a class that implements the PRMShieldEventDelegate protocol defined in ShieldEvent.h.
This protocol defines delegate methods that, when implemented, are called when different security checks are finished. These callback functions are explained below. Note that the delegate methods are triggered on the main thread so it is possible to perform UI operations directly from the delegate methods.
Lastly, register an object of the class implementing the PRMShieldEventDelegate protocol by calling the (void)addObserver: method of the PRMShieldEventManager class.
This registration should be performed as early as possible because many security checks are performed right after the application has launched. Ideally, the registration is performed in the didFinishLaunchingWithOptions method of the application delegate.
Observers can also be removed with the removeObserver method of the PRMShieldEventManager API. However, App Shielding retains observers that were added with the legacy ShieldCallbackManager API indefinitely. They cannot be removed, and their callbacks remain active for as long as the application is running.