lemnisk_flutter 1.0.5 copy "lemnisk_flutter: ^1.0.5" to clipboard
lemnisk_flutter: ^1.0.5 copied to clipboard

The Lemnisk Flutter Plugin allows you to track user event data from your Android or IOS app. The Plugin can be easily imported into any Android or iOS app. Based on the data it receives from the user [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:lemnisk_flutter/flutter_wrapper_method_channel.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:webview_flutter_android/webview_flutter_android.dart';
import 'package:webview_flutter_wkwebview/webview_flutter_wkwebview.dart';

void main() {
  runApp( MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyButtonScreen(),
    );
  }
}

class MyButtonScreen extends StatefulWidget {
  @override
  _MyButtonScreenState createState() => _MyButtonScreenState();
}

class _MyButtonScreenState extends State<MyButtonScreen> {
  WebViewController? _webViewController;
  // WebView? webView;
  @override
  void initState() {
    super.initState();
    _registerForPush();

    late final PlatformWebViewControllerCreationParams params;
    if (WebViewPlatform.instance is WebKitWebViewPlatform) {
      params = WebKitWebViewControllerCreationParams(
        allowsInlineMediaPlayback: true,
        mediaTypesRequiringUserAction: const <PlaybackMediaTypes>{},
      );
    } else {
      params = const PlatformWebViewControllerCreationParams();
    }

    final WebViewController controller =
    WebViewController.fromPlatformCreationParams(params);
    controller
      // ..setJavaScriptMode(JavaScriptMode.unrestricted)
      ..setNavigationDelegate(
        NavigationDelegate(
            onProgress: (int progress) {
              debugPrint('WebView is loading (progress : $progress%)');
            },
            onPageStarted: (String url) {
              debugPrint('Page started loading: $url');
            },
            onPageFinished: (String url) {
              LemniskFlutter.setDeviceIdToWebview( "flutter.dev");
              debugPrint('Page finished loading: $url');
            }))
      ..loadRequest(Uri.parse('https://flutter.dev'));

    if (controller.platform is AndroidWebViewController) {
      AndroidWebViewController.enableDebugging(true);
      (controller.platform as AndroidWebViewController)
          .setMediaPlaybackRequiresUserGesture(false);
    }
    // #enddocregion platform_features

    _webViewController = controller;

  }

  void _openWebView() {
    Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) => Scaffold(
          appBar: AppBar(
            title: Text('WebView Example'),
          ),
          body: WebViewWidget(controller: _webViewController!)
        ),
      ),
    );
    }
  

  void _trackEvent() async {
    await LemniskFlutter.track("testEvent", {
      "eventType": 'product-click',
      "category": 'loans',
      "subCategory": 'personal-loan',
      "test" : {"1" : "3",
      "2": {"1":"4"}}
    }, {});
  }

  void _screenEvent() async {
    await LemniskFlutter.screen("Home Page", {
      "pageType": 'personal-loan-product',
      "category": 'loans',
      "subCategory": 'personal-loan',
    }, {});
  }

  void _identifyEvent() async {
    await LemniskFlutter.identify("27te87test", {
      "name": 'test',
      "Email": 'test@test.com',
      "Phone": '1234567890',
    }, {});
  }

  void _registerForPush() async {
    await LemniskFlutter.registerForPushNotifications(null, null);
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Lemnisk Tracking and Push Testing Example'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: _trackEvent,
              child: Text('Track Event'),
            ),
            SizedBox(height: 16),
            ElevatedButton(
              onPressed: _screenEvent,
              child: Text('Screen Event'),
            ),
            SizedBox(height: 16),
            ElevatedButton(
              onPressed: _identifyEvent,
              child: Text('Identify Event'),
            ),
            SizedBox(height: 16),
            ElevatedButton(
              onPressed: _registerForPush,
              child: Text('Register For Push'),
            ),
            SizedBox(height: 16),
            ElevatedButton(
              onPressed: _openWebView,
              child: Text('Open WebView'),
            )
          ],
        ),
      ),
    );
  }
}
0
likes
110
pub points
77%
popularity

Publisher

verified publisherlemnisk.co

The Lemnisk Flutter Plugin allows you to track user event data from your Android or IOS app. The Plugin can be easily imported into any Android or iOS app. Based on the data it receives from the user activity, it sends real-time personalized push notifications to the users about the services and products that our clients provide.

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter, plugin_platform_interface, webview_flutter

More

Packages that depend on lemnisk_flutter