Logo
Initialize SDK and get device details
To initialise the SDK add the below line of code with the public key you retrieved from Sense client panel. If you don't have a public key create new one and call that below function.
How to Install
  1. Add Dependency in pubspec.yaml
    copy-icon
    copy-icon
    sense_flutter_plugin : 1.0.7
  2. Import Package
    copy-icon
    copy-icon
    import 'package:sense_flutter_plugin/sense_flutter_plugin.dart';
  3. Initialize SDK
    Add the following line of code to initialize it with the api key you obtained from the Sense Client panel. If you don't have a api key create new one.
    copy-icon
    copy-icon
    Sense.initSDK({
      "publicKey": "YOUR_PUBLIC_KEY",
      "senseInfo": true,
      "allowGeoLocation": false,
      "tag": "HomeFlutter",
      // "metaInfo" : {
      //   "phone" : "9xxxxxxxxx",
      //   "name" : "xxxxxxxxx"
      // } 
      // A collection of key-value pairs intended for storing supplementary data related 
      // to the request. The set supports up to 15 pairs, with each key and value limited 
      // to a maximum of 256 characters.
    });
  4. Get Device Details
    Use the below code to get the Device Details
    copy-icon
    copy-icon
    Sense.getSenseDetails()
  5. Location Permission (optional)
    Android
    You have to add this permission in AndroidManifest.xml to get Device Location Information and to get Retrieve call state, Network state, Network information, Sim datas from READ_PHONE_STATE and READ_PRIVILEGED_PHONE_STATE.
    copy-icon
    copy-icon
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
    tools:ignore="ProtectedPermissions"/>
    iOS
    You have to add this permission in Info.plist to get Device Location Information.
    copy-icon
    copy-icon
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>This app needs access to your location to provide location-based services.</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>Location access is required for enhanced app functionality.</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Require to get user location</string>
  6. Installed Apps (Optional for iOS)
    If you need to know Installed Applications in our SDK, kindly update your Info.plist like below. You can add those apps that you need to check whether it's installed or not.
    copy-icon
    copy-icon
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>whatsapp</string>
        <string>tez</string>
        <string>phonepe</string>
        <string>cred</string>
        <string>amazon</string>
    </array>
  7. Progurad Rules (Optional)
    If you encounter any problem in your integration related to Proguard, you can use add the below lines Proguard Rules.
    copy-icon
    copy-icon
    -keep,allowobfuscation,allowshrinking interface retrofit2.Call
    -keep,allowobfuscation,allowshrinking class retrofit2.Response
    -keep,allowobfuscation,allowshrinking class kotlin.coroutines.** { *; }
    -dontwarn ai.gosense.**
    -keep class ai.gosense.** {*;}
  8. Sample Program
    Here you can find the demonstration to do the integration.
    copy-icon
    copy-icon
    import 'package:sense_flutter_plugin/sense_flutter_plugin.dart';
    
    class _SenseAppState extends State<SenseApp> {
      late Sense sense;
      @override
      void initState() {
        super.initState();
        _initSDK();
      }
    
      void _initSDK() {
        sense = Sense.initSDK({
          "publicKey": "YOUR_PUBLIC_KEY",
          "senseInfo": true,
          "allowGeoLocation": false,
          "tag": "HomeFlutter",
          // "metaInfo" : {
          //   "phone" : "9xxxxxxxxx",
          //   "name" : "xxxxxxxxx"
          // }
          // A collection of key-value pairs intended for storing supplementary data related to 
          // the request. The set supports up to 15 pairs, with each key and value limited 
          // to a maximum of 256 characters.
        });
      }
    
      void getSenseDetails() async {
        try {
          const deviceDetails = await sense.getSenseDetails();
          print('Sense Details:'+ deviceDetails);
        } on PlatformException catch (e) {
          
        }
      }
    }