intializeApp method

  1. @override
Future<bool> intializeApp(
  1. String orgKey,
  2. bool isNetworkLoggingEnabled
)
override

Implementation

@override
Future<bool> intializeApp(String orgKey, bool isNetworkLoggingEnabled) async {
  networkAPI = locator<NetworkAPI>();
  packageDetails = await _getAppDetails();
  return await networkAPI
      .registerApp(packageDetails!.packageName, getAppType(),
          packageDetails!.appName, packageDetails!.version, orgKey)
      .then((response) {
    if (response.statusCode == 200) {
      final responseData = response.data;
      debugPrint(responseData["data"]['reportingToken']);
      debugPrint(responseData["data"]['appId']);
      reportingTokenCall = responseData["data"]['reportingToken'];
      appIdCall = responseData["data"]['appId'];
      orgUniqueKey = orgKey;

      // Start capturing screenshots
      checkAndStartCapturing() ;


      debugPrint('App registered successfully!');
      Fluttertoast.showToast(
          msg: "App registered successfully!",
          toastLength: Toast.LENGTH_SHORT,
          gravity: ToastGravity.CENTER,
          timeInSecForIosWeb: 1,
          backgroundColor: Colors.red,
          textColor: Colors.white,
          fontSize: 16.0
      );

    } else {
      debugPrint('An error occurred while registering app!');
      debugPrint(response.statusCode as String?);
    }
    return true;
  }).catchError((error) {
    return false;
  });
}