genius_sdk 1.0.8
genius_sdk: ^1.0.8 copied to clipboard
A flutter plugin for GeniusSDK
genius_sdk #
A GeniusSDK Flutter plugin project.
Installation #
flutter pub add genius_sdk
Configuration #
Android #
First of all go to your android folder and in there go to your project's build.gradle and in the repositories block add:
maven {
url=uri("https://jitpack.io")
}
For deep links to be configured you need to first associate your website domain with your app and then add an intent filter in the app's AndroidManifest.xml:
<intent-filter android:autoVerify="true" >
<data android:host="your-apps-domain"
android:scheme="https" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
iOS: #
(For development) To add local GeniusSDKFramework add to genius_sdk.podspec:
s.dependency 'GeniusSDKFramework'
and to example project's Podfile before the end of 'Runner':
pod 'GeniusSDKFramework', :path => '../../../IOS/GeniusSDKFrameworkPod'
Usage #
To only use the install attribution and data extraction, add the following in main.dart:
final geniusSdk = GeniusSdk();
try {
var initialData = await geniusSdk.connect();
print(initialData);
print(initialData["deviceName"]);
} on PlatformException {
// ignore: avoid_print
print("Failed to connect to GeniusSDK");
}
To use dynamic links aswell, add the following:
import 'package:genius_sdk/genius_sdk.dart';
// ...
final geniusSdk = GeniusSdk();
try {
var initialData = await geniusSdk.connect();
print(initialData);
print(initialData["deviceName"]);
// final data = await geniusSdk.getDynamicLinkData();
await geniusSdk.dynamicLinkInit((data) {
print("Dynamic Link callback triggered");
print(data);
print(geniusSdk.dynamicLinkData);
});
// print("dynamic link in main: ${data}");
} on PlatformException {
// ignore: avoid_print
print("Failed to connect to GeniusSDK");
}
To log an event along with all data:
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
final geniusSdk = GeniusSdk();
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: ElevatedButton(
onPressed: () async {
await geniusSdk.logEvent(
EventName.custom('Custom Event flutter'),
{"userName": "Bob"});
},
child: const Text("Log Event")
)
),
),
);
}
}
To add an event listener to listen to events invoked by the Genius:
class _MyAppState extends State<MyApp> {
final Map<String, StreamSubscription<Map<String, dynamic>>> subscriptions =
{};
@override
void initState() {
super.initState();
// Listen for events
subscriptions[GeniusEvents.firstEvent] =
widget.geniusSdk.onEvent.listen((event) {
if (event['eventName'] == GeniusEvents.firstEvent) {
print('First event triggered: ${event['params']}');
}
});
}
@override
void dispose() {
// Clean up all subscriptions
for (var sub in subscriptions.values) {
sub.cancel();
}
super.dispose();
}
// ...
}
Getting Started #
This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.
For help getting started with Flutter development, view the online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.