swaarm_sdk 0.1.7 copy "swaarm_sdk: ^0.1.7" to clipboard
swaarm_sdk: ^0.1.7 copied to clipboard

Swaarm SDK

Swaarm SDK #

Installation #

flutter pub add swaarm_sdk

Configuration #

in android/app/build.gradle, set android.defaultConfig.minSdkVersion to 18 and dependencies.implementation to "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0"

...
android {
...
  defaultConfig {
      // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
      applicationId "com.example.test123"
      // You can update the following values to match your application needs.
      // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
      minSdkVersion 18
      targetSdkVersion flutter.targetSdkVersion
      versionCode flutterVersionCode.toInteger()
      versionName flutterVersionName
  }

  buildTypes {
      release {
          // TODO: Add your own signing config for the release build.
          // Signing with the debug keys for now, so `flutter run --release` works.
          signingConfig signingConfigs.debug
      }
  }
}

flutter {
  source '../..'
}

dependencies {
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0"
}


copied to clipboard

In your main.dart, init the swaarm client singleton with the factory method await SwaarmClient.init("<domain>", "<token>"); inside your main method. In the same file inside the build function returning the Widget, set the context SwaarmClient.context = context; and wrap the App with a RepaintBoundary.

void main() async {
  runApp(const TabBarApp());
  var sc = await SwaarmClient.init("<domain>",
      "<token>");
}

class TabBarApp extends StatelessWidget {
  const TabBarApp({super.key});

  @override
  Widget build(BuildContext context) {
    SwaarmClient.context = context;
    return RepaintBoundary(
       child: MaterialApp(
      theme: ThemeData(useMaterial3: true),
      home: const TabBarExample(),
    )
    );
  }
}

copied to clipboard

Usage #

The SDK determines if an app was installed before by checking and setting a keychain flag on first start. if it's indeed a reinstall, the __reinstall event is sent in lieu of the initial one.

sent events will automatically be enriched with some userdata, e.g. os_version, vendorId and - if available - idfa. On devices using ios14 and up, tracking needs to be specifically requested to be able to get a non-zero idfa. To enable the idfa, tracking needs to be requested from a visible app, as per https://stackoverflow.com/a/72287836/1768607

with purchase you can supply revenue, currency and the receipt/transactionId to verify a purchase instead of using event and supplying aggregatedValue and customValue.

    SwaarmClient.event(typeId: "premium_currency", aggregatedValue: 25.0, customValue: "yay")
    SwaarmClient.purchase(typeId: "subscription", revenue: 11.0, currency: "USD", receipt: "base64ReceiptDataOrTransactionId")
copied to clipboard