using IPQualityScore.UnitySDK;
* A simple example for how to use the IPQualityScore.UnitySDK
* - Place your IPQS API key int the constant "API_KEY"
* - Place the IPQualityScore.UnitySDK.<Platform>.dll file
* in the folder Assets/Plugins
* Do not run ipqsUnitySDK.GetScore(OnCompletion) asynchronously.
* Everything in the SDK that can run asynchronously is already
* There are a few important items that will crash if not
* ran on the main thread.
public class IPQS_Interface
private const string API_KEY = "<< YOUR KEY HERE >>";
private static IPQSUnitySDK ipqsUnitySDK = new IPQSUnitySDK(API_KEY);
// The IPQualityScore fraud score
private static IPQSResults? ipqsResults;
* Method for receiving a fraud score
* Set custom fingerprint settings: Optional
* parameter = bool: true obtains a better fraud score,
* return = bool indicating what the fingerprinter
* WARNING!!! If FindUserLocation or CopyUserClipboard are
* true you must prompt the user BEFORE
* Otherwise that data will not be collected.
ipqsUnitySDK.FindUserLocation(false);
ipqsUnitySDK.FindUserAdvertisingID(false);
ipqsUnitySDK.CopyUserClipboard(false);
ipqsUnitySDK.SetIsEnhancedScore(false);
* Add all custom variables.
* Not necessary if not collecting additional data
* These custom keys must be set up in your IPQualityScore
* AddCustomVariable(<String> key, <String?> value)
* return = bool. true = the fingerprinter actually contains
* the given key and value. false otherwise
* An alternative way of doing this is given at the bottom
ipqsUnitySDK.AddCustomVariable("Key #1", "Value #1");
ipqsUnitySDK.AddCustomVariable("Key #2", "Value #2");
ipqsUnitySDK.AddCustomVariable("Key #3", "Value #3");
ipqsUnitySDK.AddCustomVariable("Key #4", "Value #4");
* Customize HTTPS Timeout Length: OPTIONAL
* Must be set before getting score to see effect
* SetHttpsTimeout(<int> length)
* Parameter = custom length of time in seconds
* return = true if time length setting was properly set,
ipqsUnitySDK.SetHttpsTimeout(15);
* Gets the device fingerprint and fraud score.
* This MUST be executed on the main thread
* Parameter: A callback method (illustrated below)
ipqsUnitySDK.GetScore(OnCompletion);
* This log will help diagnose any unexpected
* exceptions: please include
UnityEngine.Debug.Log("IPQualityScore.IPQS_Interface:GetScore: "
* Callback Method for GetScore(<callback method>)
* This is ran once the SDK receives a fraud
* Parameter results = a copy of the fraud score results
* as an IPQSResults object
private static void OnCompletion(IPQSResults results) {
* Run any methods necessary to your project that
* utilize the fraud score
* This log will help diagnose any unexpected
* exceptions: please include
UnityEngine.Debug.Log("IPQualityScore.IPQS_Interface:OnCompletion: "
* Alternative way to add custom variables from elsewhere
* true if key/value pair successfully added
public bool AddCustomVariable(String key, String? value) {
return ipqsUnitySDK.AddCustomVariable(key, value);
* A simple getter method for the fraud score after a
* null if fraud score has not been obtained yet.
* NOT REQUIRED if using the fraud score results in the
* call back method above, onCompletion(<IPQSResults>).
public static IPQSResults? GetIPQSResults() {