use of org.infobip.mobile.messaging.geo.Area in project mobile-messaging-sdk-android by infobip.
the class GeoReportHelper method createNewMessageForReport.
/**
* Creates new message based on geofencing report
*
* @param report geofencing report for any supported event
* @param reportingResult result of reporting geo events to server
* @param originalMessage original signaling message
* @return new message based on triggering event, area and original signaling message
*/
private static Message createNewMessageForReport(@NonNull final GeoReport report, @NonNull GeoReportingResult reportingResult, @NonNull Message originalMessage) {
GeoLatLng triggeringLocation = report.getTriggeringLocation();
if (triggeringLocation == null) {
triggeringLocation = new GeoLatLng(null, null);
}
List<Area> areas = new ArrayList<>();
if (report.getArea() != null) {
areas.add(report.getArea());
}
Geo geo;
Geo originalMessageGeo = GeoDataMapper.geoFromInternalData(originalMessage.getInternalData());
if (originalMessageGeo != null) {
geo = new Geo(triggeringLocation.getLat(), triggeringLocation.getLng(), originalMessageGeo.getDeliveryTime(), originalMessageGeo.getExpiryTime(), originalMessageGeo.getStartTime(), originalMessageGeo.getCampaignId(), areas, originalMessageGeo.getEvents(), originalMessage.getSentTimestamp(), originalMessage.getContentUrl());
} else {
geo = new Geo(triggeringLocation.getLat(), triggeringLocation.getLng(), null, null, null, null, areas, null, Time.now(), originalMessage.getContentUrl());
}
String internalData = GeoDataMapper.geoToInternalData(geo);
return new Message(getMessageIdFromReport(report, reportingResult), originalMessage.getTitle(), originalMessage.getBody(), originalMessage.getSound(), originalMessage.isVibrate(), originalMessage.getIcon(), // enforcing non-silent
false, originalMessage.getCategory(), originalMessage.getFrom(), Time.now(), 0, Time.now(), originalMessage.getCustomPayload(), internalData, originalMessage.getDestination(), originalMessage.getStatus(), originalMessage.getStatusMessage(), originalMessage.getContentUrl());
}
Aggregations