appiceflutter 1.0.3 copy "appiceflutter: ^1.0.3" to clipboard
appiceflutter: ^1.0.3 copied to clipboard

appice flutter plugin

example/lib/main.dart

import 'dart:async';
import 'package:appiceflutter/appiceflutter.dart';
import 'package:appiceflutter/appiceinboxmesssage.dart';
import 'package:flutter/material.dart';

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

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

class _MyAppState extends State<MyApp> {

  @override
  void initState() {
    super.initState();
    //initialise the SDK
    appICEInit();

    //Receive the payload from PUSH Notification
    Appiceflutter.myChannel.setMethodCallHandler((call) async {
      switch (call.method) {
        case Appiceflutter.AppICEPushNotificationClicked:
          print('Received event: ${call.arguments}');
          break;
          case Appiceflutter.AppICEInAppClicked:
          print('Received event from AppICEInAppClicked : ${call.arguments}');
          break;
      }
    });
  }

  // Record an Event
  Future<void> sendEvent() async {
    Map<String, String> map = {
      "onClick": "true",
      "name": "Rahulk",
      "testevent": "Event Rose"
    };
    var tagEvent = await Appiceflutter.tagEvent('EventName', map);
    print("inside send event");
  }

// Initialize the AppICE SDK
  Future<void> appICEInit() async {
    final List<String> certs = <String>[''];
    await Appiceflutter.initSDK(
        "app_id",
        "app_key",
        "api_key",
        "region",
        "baseurl",
        certs);
  }

// Set user information
  Future<void> setUser() async {
    Map map = <dynamic, dynamic>{};
    map[Appiceflutter.name] = 'Test';
    map[Appiceflutter.email] = 'Test@email';
    map[Appiceflutter.phone] = '45674557455';
    map[Appiceflutter.age] = 23;
    map[Appiceflutter.gender] = 'M';
    map[Appiceflutter.educationType] = 'Education';
    Appiceflutter.setUser(map);
    print(map);
  }

// Set user IDs
  Future<void> setUserId() async {
    List<String> arr = <String>[];
    arr.add("354345YGJKSH");
    arr.add("YHGJKSGH787JH");
    Appiceflutter.setUserId(arr);
  }

// Set custom variable with string
  Future<void> setCustommVarString() async {
    await Appiceflutter.setCustomVariableWithString('mobNo', 'Developer');
  }

// Receive push notification
  Future<void> pushNotificationReceived() async {
    await Appiceflutter.pushNotificationReceived("message");
  }

// Set custom variable with boolean
  Future<void> setCustommVarBoolean() async {
    await Appiceflutter.setCustomVariableWithBoolean('isAwesome', true);
  }

// Set custom variable with integer
  Future<void> setCustommVarInt() async {
    await Appiceflutter.setCustomVariableWithInteger('device_id', 1234567890);
  }

// Stop AppICE context
  Future<void> stopContext() async {
    await Appiceflutter.stopContext();
  }

// Set custom variable with long
  Future<void> setCustommVarLong() async {
    await Appiceflutter.setCustomVariableWithLong('myLong', 1254343423243567892);
  }

// Set custom variable with float
  Future<void> setCustommVarFloat() async {
    await Appiceflutter.setCustomVariableWithFloat('myFloat', 12.0);
  }

// Get session timeout
  Future<void> getSessionTimeout() async {
    await Appiceflutter.getSessionTimeout();
  }

// Validate AppICE integration
  Future<void> validateIntegration() async {
    var flg = await Appiceflutter.validateIntegration();
    print('$flg');
  }

// Set session timeout
  Future<void> setSessionTimeout() async {
    await Appiceflutter.setSessionTimeout(18000);
  }

// Set as a test device
  Future<void> setAsTestDevice() async {
    await Appiceflutter.setAsTestDevice(true);
  }

// Get test device status
  Future<void> getIsTestDevice() async {
    await Appiceflutter.getIsTestDevice();
  }

// Remove as a test device
  Future<void> removeAsTestDevice() async {
    await Appiceflutter.removeAsTestDevice();
  }

// Open Play Service update
  Future<void> openPlayServiceUpdate() async {
    await Appiceflutter.openPlayServiceUpdate();
  }

// Get AppICE SDK version
  Future<void> getSdkVersion() async {
    var intv = await Appiceflutter.getSdkVersion();
    print('$intv');
  }

// Get AppICE SDK int version
  Future<void> getSdkIntVersion() async {
    await Appiceflutter.getSdkIntVersion();
  }

// Set device ID
  Future<void> setDeviceId() async {
    String id = "abc";
    await Appiceflutter.setDeviceId(id);
  }

// Check if it's a geofence campaign
  Future<void> isGeofenceCamp() async {
    String id = "454HHFkljI";
    await Appiceflutter.isGeofenceCamp(id);
  }

// Get device ID
  Future<void> getDeviceId() async {
    await Appiceflutter.getDeviceId();
  }

// Get Android ID
  Future<void> getAndroidId() async {
    await Appiceflutter.getAndroidId();
  }

// Get AppICE SDK app key
  Future<void> getAppKey() async {
    await Appiceflutter.getAppKey();
  }

// Get AppICE SDK API key
  Future<void> getApiKey() async {
    await Appiceflutter.getApiKey();
  }

// Get current context
  Future<void> getCurrentContext() async {
    await Appiceflutter.getCurrentContext();
  }

// Get AppICE SDK app ID
  Future<void> getAppId() async {
    var appid = await Appiceflutter.getAppId();
    print('$appid');
  }

// Set alias
  Future<void> setAlias() async {
    await Appiceflutter.setAlias("False_Name");
  }

// Synchronize AppICE inbox
  Future<void> synchronizeInbox() async {
    var result = await Appiceflutter.synchronizeInbox(0);
    var callbackValue = result["callbackValue"];
    print("Callback Value: $callbackValue");
  }

// Get message by campaign ID with user ID
  Future<void> getMessageByCampaignIdWithUserId() async {
    String msgId = '123';
    String usrId = '123';
    await Appiceflutter.getMessageByCampaignIdWithUserId(msgId, usrId);
  }

// Get message by campaign ID
  Future<void> getMessageByCampaignId() async {
    String msgId = '63bd1779d58e53bc7333c42b';
    await Appiceflutter.getMessageByCampaignId(msgId);
  }

// Get message count
  Future<void> getMessageCount() async {
    int msgType = 1; // 1=all
    var data = await Appiceflutter.getMessageCount(msgType);
    print("Received message count : $data");
  }

// Get message count data with user ID
  Future<void> getMessageCountDataWithUserId() async {
    int msgType = 123;
    List<String> arr = ['myUser'];
    await Appiceflutter.getMessageCountDataWithUserId(msgType, arr);
  }

// Get inbox message data
  Future<void> getInboxMessageData() async {
    int msgType = 1;
    List<AppICEInboxData>? list =
    await Appiceflutter.getInboxMessageData(msgType);
  }

// Get inbox message for ID
  Future<void> getInboxMessageForId() async {
    String messageId = 'GivA5k6VJqqvK3aZRXyez2qgoAOLzJvCui';
    await Appiceflutter.getInboxMessageForId(messageId);
  }

// Update inbox message
  Future<void> updateInboxMessage() async {
    int Type = 1;
    String messageId = 'GivA5k6VJqqvK3aZRXyez2qgoAOLzJvCui';
    await Appiceflutter.updateInboxMessage(Type, messageId);
  }

// Get alias
  Future<void> getAlias() async {
    await Appiceflutter.getAlias();
  }

// Get user data
  Future<void> getUser() async {
    try {
      Map<String, dynamic>? userData = await Appiceflutter.getUser();
      print("User data received: $userData");
    } catch (e) {
      print("Error fetching user data: $e");
    }
  }

// Set child ID
  Future<void> setChildId() async {
    String child = "CHILD1234";
    await Appiceflutter.setChildId(child);
  }

// Set installer
  Future<void> setInstaller() async {
    String install = "INSTALL2344";
    await Appiceflutter.setInstaller(install);
  }

// Get custom variable
  Future<void> getCustomVariable() async {
    try {
      Map<String, dynamic>? userData = await Appiceflutter.getCustomVariable();
      print("CustomVariable received: $userData");
    } catch (e) {
      print("Error fetching CustomVariable: $e");
    }
  }

  // Remove custom variable
  Future<void> removeCustomVariable() async {
    String cvar = "Remove Custom Variable";
    await Appiceflutter.removeCustomVariable(cvar);
  }

// Set small icon path
  Future<void> setSmallIcon() async {
    String path = "path to small icon";
    await Appiceflutter.setSmallIcon(path);
  }

// Handle open link URL
  Future<void> handleOpenLinkUrl() async {
    String path = "https://panel.appice.io/login";
    await Appiceflutter.handleOpenLinkUrl(path);
  }

// Check if payload has an external URL
  Future<void> isPayloadHaveExternalUrl() async {
    String path = "https://panel.appice.io/login";
    await Appiceflutter.isPayloadHaveExternalUrl(path);
  }

// Check if device is registered
  Future<void> isDeviceRegistered() async {
    await Appiceflutter.isDeviceRegistered("Device Registered");
  }

// Check if SSL pinning is enabled
  Future<void> isSSLPinningEnabled() async {
    await Appiceflutter.isSSLPinningEnabled();
  }

// Get SDK configuration information
  Future<void> getSdkConfigInfo() async {
    await Appiceflutter.getSdkConfigInfo("getSdkConfigInfo");
  }

// Get limited tracking status
  Future<void> getIsLimitedTracking() async {
    await Appiceflutter.getSdkConfigInfo("getIsLimitedTracking");
  }

// Get custom device ID
  Future<void> customDeviceId() async {
    await Appiceflutter.getSdkConfigInfo("customDeviceId");
  }

// Get advertising ID
  Future<void> getAdvertisingId() async {
    await Appiceflutter.getAdvertisingId();
  }

// Set session ID
  Future<void> setSessionID() async {
    await Appiceflutter.setSessionID();
  }

// Get base URL
  Future<void> getBaseUrl() async {
    await Appiceflutter.getBaseUrl();
  }

// Get user ID
  Future<void> getUserId() async {
    await Appiceflutter.getUserId();
  }

// Get installer information
  Future<void> getInstaller() async {
    await Appiceflutter.getInstaller();
  }

// Set referrer
  Future<void> setReferrer() async {
    await Appiceflutter.setReferrer("myreferrer");
  }

// Get referrer information
  Future<void> getReferrer() async {
    await Appiceflutter.getReferrer();
  }

// Set install referrer
  Future<void> setInstallReferrer() async {
    await Appiceflutter.setInstallReferrer("install_referrrer");
  }

// Get install referrer information
  Future<void> getInstallReferrer() async {
    await Appiceflutter.getInstallReferrer();
  }

// Check if Semusi Sensing is enabled
  Future<void> isSemusiSensing() async {
    await Appiceflutter.isSemusiSensing();
  }

  Widget cButton(String btnName,Function()?  method){
    return
      Container(
        margin: const EdgeInsets.all(2),
        child:  SizedBox(
          width: double.infinity ,
          child: TextButton(
              child: Text(btnName, style: const TextStyle(fontSize: 15.0),),
              onPressed: method
          ),
        ),
      );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin example app'),
          ),
          body: Center(child: ListView(children: <Widget>[
            cButton("INIT", () => appICEInit()),
            cButton("STOP CONTEXT", () => stopContext()),
            cButton("getAppId", () => getAppId()),
            cButton("TagEvent", () => sendEvent()),
            cButton("SetUser", () => setUser()),
            cButton("getUSer", () => getUser()),
            cButton("SetUserId", () => setUserId()),
            cButton("setCustomString", () => setCustommVarString()),
            cButton("setCustomBoolean", () => setCustommVarBoolean()),
            cButton("setCustomInt", () => setCustommVarInt()),
            cButton("setCustomLong", () => setCustommVarLong()),
            cButton("setCustomFloat", () => setCustommVarFloat()),
            cButton("getSessionTimeout", () => getSessionTimeout()),
            cButton("setSessionTimeout", () => setSessionTimeout()),
            cButton("setAsTestDevice", () => setAsTestDevice()),
            cButton("removeAsTestDevice", () => removeAsTestDevice()),
            cButton("getIsTestDevice", () => getIsTestDevice()),
            cButton("isSemusiSensing", () => isSemusiSensing()),
            cButton("getSdkVersion", () => getSdkVersion()),
            cButton("validateIntegration", () => validateIntegration()),
            cButton("Synchronise Inbox", () => synchronizeInbox()),
            cButton('getMessageCount', () => getMessageCount()),
            cButton('getMessageByCampaignId', () => getMessageByCampaignId()),
            cButton('getInboxMessageData', () => getInboxMessageData()),
            cButton('getInboxMessageForId', () => getInboxMessageForId()),
            cButton('updateInboxMessage', () => updateInboxMessage()),
            cButton('openPlayServiceUpdate', () => openPlayServiceUpdate()),
            cButton('setDeviceId', () => setDeviceId()),
            cButton('getDeviceId', () => getDeviceId()),
            cButton('setAlias', () => setAlias()),
            cButton('getAlias', () => getAlias()),
            cButton('getAndroidId', () => getAndroidId()),
            cButton('getAppKey', () => getAppKey()),
            cButton('getAPIKey', () => getApiKey()),
            cButton('getCurrentContext', () => getCurrentContext()),
            cButton('setChildId', () => setChildId()),
            cButton('getReferrer', () => getReferrer()),
            cButton('setReferrer', () => setReferrer()),
            cButton('setInstallReferrer', () => setInstallReferrer()),
            cButton('getInstallReferrer', () => getInstallReferrer()),
            cButton('setInstaller', () => setInstaller()),
            cButton('getInstaller', () => getInstaller()),
            cButton('getCustomVariable', () => getCustomVariable()),
            cButton('removeCustomVariable', () => removeCustomVariable()),
            cButton('setSmallIcon', () => setSmallIcon()),
            cButton('isDeviceRegistered', () => isDeviceRegistered()),
            cButton('setSessionID', () => setSessionID()),
            cButton('getBaseUrl', () => getBaseUrl()),
            cButton('getUserId', () => getUserId()),
            cButton('pushNotificationReceived', () => pushNotificationReceived()),
            cButton('isSSLPinningEnabled', () => isSSLPinningEnabled()),
            cButton('handleOpenLinkUrl', () => handleOpenLinkUrl()),
            cButton('isPayloadHaveExternalUrl', () => isPayloadHaveExternalUrl()),
            cButton('isGeofenceCamp', () => isGeofenceCamp()),
            cButton('getSdkConfigInfo', () => getSdkConfigInfo()),
            cButton('getIsLimitedTracking', () => getIsLimitedTracking()),
            cButton('getAdvertisingId', () => getAdvertisingId()),
            cButton('customDeviceId', () => customDeviceId()),
            Container(
              margin: const EdgeInsets.all(1),
              child: TextButton(
                child: const Text('getSdkIntVersion', style: TextStyle(fontSize: 15.0),),
                onPressed: () {getSdkIntVersion();},
              ),
            ),
          ]
          )),
        ));
  }
}
0
likes
120
points
17
downloads

Publisher

verified publisherappice.io

Weekly Downloads

appice flutter plugin

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

flutter

More

Packages that depend on appiceflutter

Packages that implement appiceflutter