openCommonNotification static method
void
openCommonNotification({})
Implementation
static void openCommonNotification(
{required Map<String, dynamic> data,
required String appToken,
bool inBack = false}) async {
if (InngageProperties.isInOpen) return;
InngageProperties.isInOpen = true;
Future.delayed(const Duration(seconds: 4))
.then((value) => InngageProperties.isInOpen = false);
if (InngageProperties.getDebugMode()) {
debugPrint("openCommonNotification: $data");
}
String? notificationId = '';
if (data.containsKey('notId')) {
notificationId = data['notId'];
}
processUTMParameters(data);
try {
await InngageService.registerNotification(
notId: notificationId!, appToken: appToken);
} catch (e) {
debugPrint(e.toString());
}
final String type = data['type'] ?? '';
final String url = data['url'] ?? '';
final titleNotification = data['title'];
final messageNotification = data['message'];
if (type.isEmpty) {
return;
}
switch (type) {
case 'deep':
if (!InngageProperties.blockDeepLink) {
await InngageUtils.launchURL(url);
}
return;
case 'inapp':
if (inBack) {
Future.delayed(const Duration(seconds: 3))
.then((value) => _showCustomNotification(
messageNotification: messageNotification,
titleNotification: titleNotification,
url: url,
));
} else {
_showCustomNotification(
messageNotification: messageNotification,
titleNotification: titleNotification,
url: url,
);
}
break;
}
}