helpshift_wrapper 0.0.5
helpshift_wrapper: ^0.0.5 copied to clipboard
Flutter plugin to integrate Helpshift Support SDK into your flutter app.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:helpshift_wrapper/helpshift_wrapper.dart';
import 'package:helpshift_wrapper_example/src/constants.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
setupHelpShiftSdk();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
.then((_) {
runApp(const MyApp());
});
}
/// configure HelpShift SDK for Native Platforms
void setupHelpShiftSdk() async {
await HelpshiftWrapper.setUpHelpShiftSDK(
helpShiftApiKey: Constants.helpShiftApiKey(),
helpShiftAppId: Constants.helpShiftAppId(),
helpShiftDomain: Constants.helpShiftDomain,
);
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('HelpShift Wrapper'),
centerTitle: true,
),
body: SingleChildScrollView(
child: Center(
child: Column(
children: [
const SizedBox(height: 20),
Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 20),
child: ElevatedButton(
onPressed: () {
HelpshiftWrapper.showAllConversation(
configMap: getConfigmap());
},
child: const Text('Show All Conversation'),
),
),
const SizedBox(
height: 10,
),
ElevatedButton(
onPressed: () {
HelpshiftWrapper.showAllConversation(
configMap: getConfigmap());
},
child: const Text('Show All Conversation'),
),
ElevatedButton(
onPressed: () {
HelpshiftWrapper.openFAQsScreen(
configMap: getCustomIssueFieldMap());
},
child: const Text('FAQs'),
),
ElevatedButton(
onPressed: () {
HelpshiftWrapper.openSingleFAQScreen(
sectionId: "1", configMap: getConfigmap());
},
child: const Text('Order FAQs'),
),
ElevatedButton(
onPressed: () {
HelpshiftWrapper.openSingleFAQScreen(
sectionId: "2", configMap: getConfigmap());
},
child: const Text('Returns and Exchanges FAQs'),
),
ElevatedButton(
onPressed: () {
HelpshiftWrapper.openSingleFAQScreen(
sectionId: "3", configMap: getConfigmap());
},
child: const Text('Shipping and Delivery FAQs'),
),
ElevatedButton(
onPressed: () {
HelpshiftWrapper.openSingleFAQScreen(
sectionId: "4", configMap: getConfigmap());
},
child: const Text('Payment FAQs'),
),
ElevatedButton(
onPressed: () {
HelpshiftWrapper.openSinglePublishedFAQDetail(
publishId: "8", configMap: getConfigmap());
},
child: const Text('What Payment Methods do you accept?'),
),
],
),
),
),
),
);
}
/// setup your config map according to your need
getConfigmap() {
var config = {};
// set tags for tracking
config["tags"] = ["foo", "bar"];
// set custom issue fields
var cifMap = {};
var isPro = {};
isPro["type"] = "boolean";
isPro["value"] = "true";
cifMap["is_pro"] = isPro;
config["customIssueFields"] = cifMap;
return config;
}
/// setup your customIssueFiled Map
getCustomIssueFieldMap() {
var joiningDate = {};
joiningDate["type"] = "date";
joiningDate["value"] = 1505927361535;
var stockLevel = {};
stockLevel["type"] = "number";
stockLevel["value "] = "1505";
var employeeName = {};
employeeName["type"] = "singleline";
employeeName["value"] = "Bugs helpshift";
var isPro = {};
isPro["type"] = "boolean";
isPro["value"] = "true";
var cifMap = {};
cifMap["joining_date"] = joiningDate;
cifMap["stock_level"] = stockLevel;
cifMap["employee_name"] = employeeName;
cifMap["is_pro"] = isPro;
var config = {};
config["customIssueFields"] = cifMap;
return config;
}
}