fluttersdkplugin 1.0.12 copy "fluttersdkplugin: ^1.0.12" to clipboard
fluttersdkplugin: ^1.0.12 copied to clipboard

Plug-ins first gained popularity in the 1990s as software and microprocessors became more powerful. One of the first programs to make extensive use of plug-ins was Adobe Photoshop, an image-processing [...]

example/lib/main.dart

import 'dart:collection';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:fluttersdkplugin/fluttersdkplugin.dart';
import 'package:fluttersdkplugin/fluttersdkplugin_method_channel.dart';
import 'package:fluttersdkplugin_example/poc.dart';
import 'package:fluttersdkplugin_example/screen1.dart';
import 'package:logger/logger.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:provider/provider.dart';

import 'Screen2.dart';
import 'bloc.dart';


//
// @pragma('vm:entry-point')
// Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
//   // If you're going to use other Firebase services in the background, such as Firestore,
//   // make sure you call `initializeApp` before using other Firebase services.
//   await Firebase.initializeApp();
//
//   _fluttersdkpluginPlugin.onMessageReceived(message);
// }


final _fluttersdkpluginPlugin = Fluttersdkplugin();
main() async {
  WidgetsFlutterBinding.ensureInitialized();
  //FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
  // await Firebase.initializeApp();

  runApp(PocApp());
}
class PocApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    DeepLinkBloc _bloc = DeepLinkBloc();
    return MaterialApp(
        routes:{
          'screen1' :(BuildContext contxt)=> Screen1(),
          'screen2' :(BuildContext contxt)=> Screen2()
        },
        title: 'Flutter and Deep Links PoC',
        theme: ThemeData(
            primarySwatch: Colors.blue,
            textTheme: TextTheme(
              subtitle1: TextStyle(
                fontWeight: FontWeight.w300,
                color: Colors.blue,
                fontSize: 25.0,
              ),
            )),
        home: Scaffold(
            body: Provider<DeepLinkBloc>(
                create: (context) => _bloc,
                dispose: (context, bloc) => bloc.dispose(),
                child: PocWidget())
        ));
  }
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});
  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  TextEditingController controller1 = TextEditingController();
  String _platformVersion = 'Unknown',
      token = "ezyY7vF9TSqiwA3wxwJmYC:APA91bENxHnr2Z2XFHRpbu7GVJklVnDjs7phmEh2M4YNcxxxrPNRw1wtlvwAkGES_uEH8-wRAck30oBkvOwlZ0fJOyVYbcuOAaiOlHGwA9LTLxFnT5iAPAQEGN2LIgfyh6Ax9Iw5Kcf7";
  int notificationCount = 0,
      _counter = 0;
  late String cid;
  late String nList;
   late var navigationParameter;
  String data = "";

  var logger = Logger();
  late Timer _timer;

  static const events = EventChannel(
      'com.example.fluttersdkplugin_example/channell');
  static const methodChannel = MethodChannel("flutter/test/platformChannels");

// void onMethodCall(MethodCall call){
//   if (call.method=="callFromAndroid") {
//     print("method called from android");
//   }
// }

  @override
  void initState() {
    super.initState();

    if(DeeplinkData.link!=""){
      print("via DeeplinkDate");
      Uri uri = Uri.parse(DeeplinkData.link);
      setState((){
        navigationParameter = uri.pathSegments.first;
        print("Deeplink Received :: ${uri.toString()}");
      });
      // if(navigationParameter=="scrollpage")
      //   Navigator.push(context,
      //       MaterialPageRoute(builder: (context) => const Screen1()));
      // else
      //   Navigator.push(context,
      //       MaterialPageRoute(builder: (context) => const Screen2()));
    }
    else
      {
        setState(() {
          navigationParameter="No data received";
        });
      }



    // Firebase.initializeApp();
    // FirebaseMessaging.instance.getToken().then((newToken) {
    //   print("FCM token: ");
    //   print(newToken);
    //   FirebaseMessaging.onMessage.listen((RemoteMessage message) {
    //     print('Got a message whilst in the foreground!');
    //     print('Message data: ${message.notification} ');
    //   });
    // });


    initPlatformState();
    startTimer();
    //eventTriggered();
    //_fluttersdkpluginPlugin.setEventChannelID("example.com/channel");
    // handlePlatformChannelMethods();
    //onListenBattery();
  }

  void showAlert(BuildContext context,String link) {
    showDialog(
        context: context,
        builder: (context) {
          Future.delayed(Duration(seconds: 2), () {
            Navigator.of(context).pop(true);
          });
          return AlertDialog(
            title: Text('DeepLink Launch'),
            content: Text("Received Link :: $link)"),
          );
        });
  }
  handleDeepLink(){
    print("Deeplink handler called");
    if(DeeplinkData.link!=''){
      Uri uri = Uri.parse(DeeplinkData.link);
      setState((){
        navigationParameter = uri.pathSegments.first;
        print("NavigationParameter :: $navigationParameter");
      });
      showAlert(context, uri.toString());
      // if(navigationParameter=="scrollpage"){
      //   Navigator.of(context).pushNamed('screen1');
      //   //Get.toNamed('graduation');
      // }
      // else if(navigationParameter=="LP53")
      // {
      //   Navigator.of(context).pushNamed('screen2');
      // }

    }
  }
  void startTimer() {
    _timer = Timer.periodic(Duration(seconds: 1), (timer) {
      listenForMsg();
    });
  }

  listenForMsg() {
    events.receiveBroadcastStream().listen((dataa) {
      setState(() {
        data = dataa;
      });
      if (data != "") {
        logger.e("EventChannel :: $data");
      }
    }, onError: (error) {
      print("Error: $error");
    });
  }

  passLocation() {
    double lat = 13.0827;
    double lang = 80.2707;
    _fluttersdkpluginPlugin.pushLocation(lat, lang);
  }

  newNotification() {
    var notificationTitle = "sample Title";
    var notificationBody = "sample Body";
    _fluttersdkpluginPlugin.addNewNotification(
        notificationTitle, notificationBody);
  }

  ontrackEvent() {
    var content = "On Track Event called!!!";
    _fluttersdkpluginPlugin.onTrackEvent(content);
  }

  deleteNotificationByCampaignid() {
    setCidState();
    _fluttersdkpluginPlugin.deleteNotificationByCampaignId(cid);
  }

  setCidState() {
    setState(() {
      cid ="k2S||FaV|vV|T_tX7N6|1003123|Bulk|20221115060533";
    });
  }

  readnotification() {
    setCidState();
    _fluttersdkpluginPlugin.readNotification(cid);
  }

  unreadNotification() {
    setCidState();
    _fluttersdkpluginPlugin.unReadNotification(cid);
  }

  appconversionTracking() {
    _fluttersdkpluginPlugin.appConversionTracking();
  }

  formdataCapture() {
    Map param = {
      "Name": "vishwa",
      "EmailID": "abc@gmail.com",
      "MobileNo": 9329222922,
      "Gender": "Male",
      "formid": 101, // required
      "apikey": "api_key_b78db6rb3-9462-4132-a4d3-894db10b3782",
      "City": "Chennai" // required
    };
    String formData = jsonEncode(param);
    _fluttersdkpluginPlugin.formDataCapture(formData);
  }

  onTrackEventwithData() {
    var data = {
      "name": "payment",
      "data": {"id": "2d43", "price": "477"}
    };
    String eventData = jsonEncode(data);
    _fluttersdkpluginPlugin.onTrackEventwithData(eventData, "Purchase");
  }

    updatepushToken() {
      _fluttersdkpluginPlugin.updatePushToken(token);
    }
    ondeviceRegister() {
      _fluttersdkpluginPlugin.onDeviceUserRegister(
          '123',
          'vishwa',
          '24',
          'abc@gmail.com',
          '9893839383',
          'Male',
          token,
          'www.google.com',
          '2/8/2005',
          'BE',
          true,
          false,
          "At_928jw8");
    }
    getdeepLinkData() {
      _fluttersdkpluginPlugin.deepLinkData();
    }
    Future<int?> readnotificationCount() async {
      var rnCount = await _fluttersdkpluginPlugin.readNotificationCount()!;
      setState(() {
        notificationCount = rnCount!;
      });
      if (kDebugMode) {
       print("readNotificationCount::$rnCount");
      }
      return null;
    }

    // callToAndroid(){
    //  _fluttersdkpluginPlugin.callFromAndroid();
    // }

    Future<dynamic> handlePlatformChannelMethods() async {
      methodChannel.setMethodCallHandler((methodCall) async {
        if (methodCall.method == "androidMethodName") {
          /// write the code here which you want to implement after  this method call
          print("method call from native code");
          if (methodCall.arguments != null) {
            print(methodCall.arguments);
          }
        }
        else if (methodCall.method == "iosMethodName") {
          /// ...... }
        }
      });
    }

    // eventTriggered(){
    //   events.receiveBroadcastStream().listen((datta) {
    //     if(datta is String){
    //       setState(() {
    //          data=datta;
    //       });
    //     //  print("received integer: $data");
    //     }
    //   }, onError: (error) {
    //     print("Error: $error");
    //   });
    // }
    // Platform messages are asynchronous, so we initialize in an async method.

    Future<void> initPlatformState() async {
      String platformVersion;
      // Platform messages may fail, so we use a try/catch PlatformException.
      // We also handle the message potentially returning null.
      try {
        platformVersion =
            await _fluttersdkpluginPlugin.getPlatformVersion() ??
                'Unknown platform version';
      } on PlatformException {
        platformVersion = 'Failed to get platform version.';
      }

      // If the widget was removed from the tree while the asynchronous platform
      // message was in flight, we want to discard the reply rather than calling
      // setState to update our non-existent appearance.
      if (!mounted) return;

      setState(() {
        _platformVersion = platformVersion;
      });
    }
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
          debugShowCheckedModeBanner: false,
          home: Scaffold(
            resizeToAvoidBottomInset: true,
            appBar: AppBar(
              title: const Text('Plugin example app'),
            ),
            body: SingleChildScrollView(
              child: ConstrainedBox(
                constraints: const BoxConstraints(),
                child:
                Container(
                  child: Column(
                    children: [
                      Center(
                        // child: Text('Running on: $_platformVersion\n'),
                        child: Text('DeepLink ::${DeeplinkData.link.isNotEmpty?DeeplinkData.link:"No data"}'),
                      ),
                      // Center(
                      //   child: Text('Data Passed from NativeCode: $data!'),
                      // ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () { //
                          ondeviceRegister();
                        }, child: Text("On Device User Register"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          updatepushToken();
                        }, child: Text("update Push Token"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          passLocation();
                        }, child: Text("Update Location"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(

                          onPressed: () {
                            newNotification();
                          }, child: Text("Add New Notification"),),
                      ),
                      // TextField(
                      //   controller: controller1,
                      //   keyboardType: TextInputType.number,
                      //   decoration: InputDecoration(
                      //       labelText: "Enter ID",
                      //       border: OutlineInputBorder(
                      //           borderRadius: BorderRadius.circular(20))),),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          readnotification();
                        }, child: Text("Read Notification By Id"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          unreadNotification();
                        }, child: Text("UnRead Notification BY Id"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          setState(() async {
                             nList = await _fluttersdkpluginPlugin
                                .getNotification();
                          });
                          }, child: Text("Get Notifications"),),
                      ),

                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          readnotificationCount();
                        }, child: const Text("Read Notification Count"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          setState(() async {
                            var un_rCount = await _fluttersdkpluginPlugin
                                .unReadNotificationCount();
                            print("unReadNotificationCount:: $un_rCount");
                          });
                        }, child: const Text("Un_Read_Notification_Count"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          deleteNotificationByCampaignid();
                          setState(() {
                            controller1.clear();
                          });
                        }, child: Text("Delete Notification By CampaignId"),),
                      ),

                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          formdataCapture();
                        }, child: Text("form Data Capture"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          ontrackEvent();
                        }, child: Text("OnTrackEvent"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          style:
                          ElevatedButton.styleFrom(
                            minimumSize: Size.fromHeight(40),);
                          onTrackEventwithData();
                        }, child: const Text("OnTrackEventwithData"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          appconversionTracking();
                        }, child: Text("app Conversion Tracking"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          style:
                          ElevatedButton.styleFrom(
                            minimumSize: Size.fromHeight(40),);
                          getdeepLinkData();
                        }, child: Text("Get deepLinkData"),),
                      ),

                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          style:
                          ElevatedButton.styleFrom(
                            minimumSize: Size.fromHeight(40),);
                          _fluttersdkpluginPlugin.screentracking("Screen1");
                          Navigator.push(context,
                              MaterialPageRoute(builder: (context) => const Screen1()));
                        }, child: Text("Screen-1"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          style:
                          ElevatedButton.styleFrom(
                            minimumSize: Size.fromHeight(40),);
                          _fluttersdkpluginPlugin.screentracking("Screen2");
                          Navigator.push(context,
                              MaterialPageRoute(builder: (context) => const Screen2()));

                        }, child: Text("Screen-2"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          style:
                          ElevatedButton.styleFrom(
                            minimumSize: Size.fromHeight(40),);
                          _fluttersdkpluginPlugin.screentracking("Screen3");
                        }, child: Text("Screen-3"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          style:
                          ElevatedButton.styleFrom(
                            minimumSize: Size.fromHeight(40),);
                          _fluttersdkpluginPlugin.qrlink(
                              "http://myolaapp.page.link/start");
                        }, child: Text("QR-Link"),),
                      ),
                      SizedBox(
                        width: double.infinity,
                        child: ElevatedButton(onPressed: () {
                          style:
                          ElevatedButton.styleFrom(
                            minimumSize: Size.fromHeight(40),);
                          _fluttersdkpluginPlugin.notificationCTAClicked(
                              "c_id12", "a_id34");
                        }, child: Text("NotificationCTAClicked"),),
                      ),


                    ],
                  ),
                ),
              ),
            ),
          )
      );
    }
  }
0
likes
100
pub points
0%
popularity

Publisher

unverified uploader

Plug-ins first gained popularity in the 1990s as software and microprocessors became more powerful. One of the first programs to make extensive use of plug-ins was Adobe Photoshop, an image-processing and editing program. Early plug-ins provided enhanced functions such as special effects, filters, and other options for manipulating images within Photoshop.gin package.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

firebase_core, firebase_dynamic_links, firebase_messaging, flutter, get, logger, plugin_platform_interface

More

Packages that depend on fluttersdkplugin