init method
Future<String?>
init({
- IOSInfo? iosInfo,
- AndroidInfo? androidInfo,
- required MetaInfo metaData,
- required BuildContext context,
Initialize the service Must be called first, before using any other DeepLynks method returns a unique app ID for your app. This ID remains same until application id or bundle id is changed
Implementation
Future<String?> init({
IOSInfo? iosInfo,
AndroidInfo? androidInfo,
required MetaInfo metaData,
required BuildContext context,
}) async {
assert(
androidInfo != null || iosInfo != null,
ErrorStrings.appInfoMissing,
);
if (_appId != null) return _appId;
_devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
final res = await _apiService.request(
method: ApiMethod.post,
endpoint: ApiEndpoints.registerApp,
body: {
ApiKeys.meta: metaData.toMap(),
if (iosInfo != null) ApiKeys.iOS: iosInfo.toMap(),
if (androidInfo != null) ApiKeys.android: androidInfo.toMap(),
},
);
if (res.success) {
try {
_appId = res.data[ApiKeys.data][ApiKeys.id];
final ipLookups = (res.data[ApiKeys.data][ApiKeys.ipLookupURLs] as List)
.map((e) => IpLookupModel.fromJSON(e))
.toList();
_searchClick(ipLookups);
} catch (e, st) {
_logService.logError(e, st);
}
}
return _appId;
}