flutter_shieldfraud 1.0.7 flutter_shieldfraud: ^1.0.7 copied to clipboard
Flutter plugin for Shield SDK. SHIELD SDK helps developers to assess malicious activities performed on mobile devices and return risk intelligence based on user's behaviour.
import 'dart:collection';
import 'package:flutter/material.dart';
import 'package:flutter_shieldfraud/plugin_shieldfraud.dart';
import 'package:flutter_shieldfraud/shield_config.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
initShield();
// Shield.latestDeviceResult.then((latestDeviceResult) => {
// if (latestDeviceResult == null)
// {print("error ${Shield.latestError?.message}")}
// else
// {print("result $latestDeviceResult")}
// });
}
void initShield() async {
ShieldCallback shieldCallback =
ShieldCallback((Map<String, dynamic> result) {
print("callback result: $result");
}, (ShieldError error) {
print("callback error: ${error.message}");
});
var data = <String, String>{};
data["user_id"] = "12345";
final valueInt = await Shield.isShieldInitialized;
ShieldConfig config = ShieldConfig(
siteID: "f090f742649c84aa50bc40cdb559b55eb85def43",
key: "9ce44f88a25272b6d9cbb430ebbcfcf1",
shieldCallback: shieldCallback,
environment: ShieldEnvironment.dev,
logLevel: ShieldLogLevel.verbose);
if (!valueInt) {
Shield.initShield(config);
Future.delayed(const Duration(seconds: 2), () async {
final valueInt = await Shield.isShieldInitialized;
if (valueInt) {
Shield.sendAttributes("login", data);
}
});
} else {
Shield.sendAttributes("login", data);
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: MaterialButton(
onPressed: () {
Shield.sendDeviceSignature("test sending device signature").then(
(value) => print(
"sending device signature in real time successful: $value"));
},
child: const Text("Send attributes"),
)),
),
);
}
}