Search in sources :

Example 1 with ApplePushNotificationService

use of org.onebusaway.api.services.apns.ApplePushNotificationService in project onebusaway-application-modules by camsys.

the class AlarmServiceImpl method fireAlarm.

@Override
public void fireAlarm(String alarmId) {
    AlarmDetails details = _alarmsById.remove(alarmId);
    if (details == null)
        return;
    if (details instanceof ApnsAlarmDetails) {
        ApnsAlarmDetails apnsDetails = (ApnsAlarmDetails) details;
        JSONObject data = getDataAsJson(apnsDetails.getData());
        String payload = getDataAsApnsPayload(alarmId, data);
        boolean isProduction = isProduction(data);
        for (ApplePushNotificationService service : _applePushNotificationServices) {
            if (service.isProduction() == isProduction) {
                service.pushNotification(apnsDetails.getDeviceToken(), payload);
                return;
            }
        }
        _log.warn("no appropriate ApplePushNotificationService found for alarm: production=" + isProduction);
    }
}
Also used : AlarmDetails(org.onebusaway.api.services.AlarmDetails) JSONObject(org.json.JSONObject) ApplePushNotificationService(org.onebusaway.api.services.apns.ApplePushNotificationService)

Aggregations

JSONObject (org.json.JSONObject)1 AlarmDetails (org.onebusaway.api.services.AlarmDetails)1 ApplePushNotificationService (org.onebusaway.api.services.apns.ApplePushNotificationService)1