postTopics method
Future<RequestFcmModel>
postTopics({
- required String topics,
- required MessageModel notification,
- Map<
String, String> ? data,
Implementation
Future<RequestFcmModel> postTopics({
required String topics,
required MessageModel notification,
Map<String, String>? data,
}) async {
var result = await http.post(
Uri.parse('$url/send'),
body: jsonEncode(
{
'to': '/topics/$topics',
'notification': notification.toMap(),
'data': data,
"android": {
"notification": {"image": notification.image}
},
"apns": {
"payload": {
"aps": {"mutable-content": 1}
},
"fcm_options": {"image": notification.image}
},
},
),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer $tokenServer'
},
);
return RequestFcmModel(
body: result.body,
isSend: result.statusCode == 200,
);
}