updateNewsFeeds static method
Update the read/shown flag of the news feed.
Implementation
static Future<void> updateNewsFeeds(List<NewsFeedEntry> newsFeeds) async {
var jsonList = <String>[];
var stringMapList = <Map>[];
for (var entry in newsFeeds) {
var mapEntry = {
'newsfeed_id': entry.id,
'device_id': entry.deviceID,
'title': entry.title,
'summary': entry.summary,
'body': entry.body,
'link_url': entry.linkUrl,
'link_url_string': entry.linkUrlString,
'image_url': entry.imageUrl,
'image_url_string': entry.imageUrlString,
'delivered_at': entry.rawDeliveredAt,
'shown': entry.shown,
'read': entry.read
};
if (Platform.isAndroid) {
String json = jsonEncode(mapEntry);
jsonList.add(json); // Convert JSON string to NewsFeedEntry on the Java side.
} else if (Platform.isIOS) {
stringMapList.add(mapEntry);
}
}
if (Platform.isAndroid) {
await _invokeMethod<String>('updateNewsFeeds', jsonList);
} else if (Platform.isIOS) {
await _invokeMethod('updateNewsFeeds', stringMapList);
}
}