use of com.notnoop.apns.PayloadBuilder in project ranch by heisedebaise.
the class IosSenderImpl method send.
@Override
public boolean send(PushModel push, String receiver, JSONObject args) {
IosModel ios = iosService.find(push.getAppCode(), args.getIntValue("destination"));
if (ios == null)
return false;
ApnsService service = iosService.getApnsService(ios.getAppCode(), ios.getDestination());
if (service == null)
return false;
PayloadBuilder payloadBuilder = APNS.newPayload();
payloadBuilder.alertTitle(pushService.parse(PushService.Type.Subject, push.getKey(), push.getSubject(), args));
payloadBuilder.alertBody(pushService.parse(PushService.Type.Content, push.getKey(), push.getContent(), args));
payloadBuilder.badge((json.containsKey(args, "badge") ? args.getIntValue("badge") : 1) + 1);
payloadBuilder.sound(json.containsKey(args, "sound") ? args.getString("sound") : "default");
service.push(receiver, payloadBuilder.build());
return true;
}
use of com.notnoop.apns.PayloadBuilder in project onebusaway-application-modules by camsys.
the class AlarmServiceImpl method getDataAsApnsPayload.
private String getDataAsApnsPayload(String alarmId, JSONObject data) {
PayloadBuilder b = PayloadBuilder.newPayload();
b.customField("alarmId", alarmId);
try {
if (data.has("actionKey"))
b.actionKey(data.getString("actionKey"));
if (data.has("alertBody"))
b.alertBody(data.getString("alertBody"));
if (data.has("badge"))
b.badge(data.getInt("badge"));
if (data.has("sound"))
b.sound(data.getString("sound"));
} catch (JSONException e) {
throw new InvalidArgumentServiceException("data", e.getMessage());
}
return b.build();
}
Aggregations