init static method
Implementation
static Future<void> init(String apiKey, {String userIdentifier = ""}) async {
_prefs = await SharedPreferences.getInstance();
_deviceInfo = await DeviceInfoUtils.getDeviceInfo();
PackageInfo packageInfo = await PackageInfo.fromPlatform();
_appVersion = packageInfo.version;
_apiClient = ApiClient();
Feedbacknest._apiKey = apiKey;
if (userIdentifier.isEmpty) {
String userId = _prefs?.getString('userIdentifier') ?? '';
if (userId.isNotEmpty) {
Feedbacknest._userIdentifier = userId;
} else {
final random = Random();
int num = 100000 + random.nextInt(900000);
Feedbacknest._userIdentifier = "user_$num";
_prefs?.setString('userIdentifier', Feedbacknest._userIdentifier!);
}
} else {
Feedbacknest._userIdentifier = userIdentifier;
}
_apiClient?.post("/user/submit/log", apiKey, {
"user_id": Feedbacknest._userIdentifier,
"app_version": _appVersion,
"platform": _deviceInfo?.deviceOS,
"device_model": _deviceInfo?.deviceName,
"device_os_version": _deviceInfo?.deviceOSVersion,
});
}