sendNotificationViaCloud static method
Calls secureOps Cloud Function to send a push notification server-side.
Targets a device token or, alternatively, an FCM topic (e.g. 'allUsers').
Returns true if sent successfully, false otherwise.
Implementation
static Future<bool> sendNotificationViaCloud({
String token = '',
String topic = '',
required String title,
required String body,
Map<String, String>? data,
}) async {
if (token.isEmpty && topic.isEmpty) return false;
try {
final result = await callSecureOps({
'action': 'sendNotification',
if (token.isNotEmpty) 'token': token,
if (topic.isNotEmpty) 'topic': topic,
'title': title,
'body': body,
'data': data ?? {},
});
return result['success'] == true;
} catch (e, st) {
NeomErrorLogger.recordError(e, st, module: 'neom_core', operation: 'sendNotificationViaCloud');
return false;
}
}