Integration of SDK APIs
  • 20 Jan 2025
  • 1 Minute à lire
  • Sombre
    Lumière
  • PDF

Integration of SDK APIs

  • Sombre
    Lumière
  • PDF

The content is currently unavailable in French. You are viewing the default English version.
Résumé de l’article

Android integration

First, add the ShieldSDK-config Maven dependency to your Android project. This can be found in the SDK/maven/ directory of the App Shielding package. For more information on importing App Shielding libraries, refer to the "Shield APIs" section in OneSpan App Shielding for Android Reference Documentation.pdf.

You can then use the ShieldConfig class with the following methods:

Methods for ShieldConfig class

Method

Description

requestUpdate()

Triggers App Shielding to download a configuration update.

setUpdateCustomId(token)

Sets the X-update-custom-id header for configuration requests. The provided NSData is stored and used for any future request to the server.

setUpdateCallbacks(callback)

Registers a listener that is invoked whenever the app downloads a configuration update. The callback receives a time stamp value that reflects the embedded time stamp from the downloaded configuration.

The following example demonstrates how these methods can be used:

ShieldConfig.requestUpdate();
ShieldConfig.setUpdateCustomId("my-token".getBytes(StandardCharsets.UTF_8));

ShieldConfig.setUpdateCallbacks(new UpdateCallbacks() {
    @Override
    public void configUpdateReceived(String timestamp) {
        // handle callback logic
        ...
    }
});

iOS integration

First, add the ShieldSDK.xcframework bundle from the App Shielding package to your iOS project. For more information on importing App Shielding libraries, see Adding the framework.  

You can then use the PRMShieldConfig class with the following methods:

Methods for ShieldConfig class

Method

Description

requestUpdate()

Triggers App Shielding to download a configuration update.

setUpdateCustomId(token)

Sets the X-update-custom-id header for configuration requests. The provided NSData is stored and used for any future request to the server.

setUpdateCallbacks(callback)

Registers a listener that is invoked whenever the app downloads a configuration update. The callback receives a time stamp value that reflects the embedded time stamp from the downloaded configuration.

The following example demonstrates how these methods can be used:

[PRMShieldConfig requestUpdate];
[PRMShieldConfig setUpdateCustomId:[NSData dataWithBytes:"my-token" length:8]];

For callbacks, you can start with the ConfigUpdateCallbacks interface.

Objective-C example

@interface ConfigUpdateCallbacks : NSObject <PRMShieldConfigUpdateCallbacks>
@end 

@implementation ConfigUpdateCallbacks
- (void)configUpdateReceived:(NSString *)timestamp 
{
  // handle callback logic
  ... 
}
@end

During the app initialization (e.g., in didFinishLaunchingWithOptions), call the setUpdateCallbacks method in the following manner:

[PRMShieldConfig setUpdateCallbacks:[[ConfigUpdateCallbacks alloc] init]];

Swift example

If you are using Swift instead of Objective-C, you can set up the callback as follows:

class ConfigUpdateCallbacks: NSObject, PRMShieldConfigUpdateCallbacks {
  func configUpdateReceived(_ timestamp: String) { 
    // handle callback logic
      ... 
    }
  }

...
PRMShieldConfig.setUpdateCallbacks(ConfigUpdateCallbacks())


Cet article vous a-t-il été utile ?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Ozzy, facilitant la découverte de connaissances grâce à l’intelligence conversationnelle