@Override public Map<String, Date> getInactiveDevices() throws NetworkIOException { return service.getInactiveDevices(); }
@Override public void run() { Map<String, Date> inactiveDevices = pushApnService.getInactiveDevices(); inactiveDevices.putAll(voipApnService.getInactiveDevices()); for (String registrationId : inactiveDevices.keySet()) { Optional<String> device = redisGet(registrationId); if (device.isPresent()) { logger.warn("Got APN unregistered notice!"); String[] parts = device.get().split(".", 2); if (parts.length == 2) { String number = parts[0]; int deviceId = Integer.parseInt(parts[1]); long timestamp = inactiveDevices.get(registrationId).getTime(); unregisteredQueue.put(new UnregisteredEvent(registrationId, null, number, deviceId, timestamp)); } else { logger.warn("APN unregister event for device with no parts: " + device.get()); } } else { logger.warn("APN unregister event received for uncached ID: " + registrationId); } } } }
private List<InactiveDevice> getInactiveDevices() { ApnsEndpoint ae = getEndpoint(); Map<String, Date> inactiveDeviceMap = ae.getApnsService().getInactiveDevices(); List<InactiveDevice> inactiveDeviceList = new ArrayList<>(); for (Entry<String, Date> inactiveDeviceEntry : inactiveDeviceMap.entrySet()) { String deviceToken = inactiveDeviceEntry.getKey(); Date date = inactiveDeviceEntry.getValue(); InactiveDevice inactiveDevice = new InactiveDevice(deviceToken, date); inactiveDeviceList.add(inactiveDevice); } return inactiveDeviceList; }