Search in sources :

Example 1 with IosModel

use of org.lpw.ranch.push.ios.IosModel 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;
}
Also used : PayloadBuilder(com.notnoop.apns.PayloadBuilder) IosModel(org.lpw.ranch.push.ios.IosModel) ApnsService(com.notnoop.apns.ApnsService)

Aggregations

ApnsService (com.notnoop.apns.ApnsService)1 PayloadBuilder (com.notnoop.apns.PayloadBuilder)1 IosModel (org.lpw.ranch.push.ios.IosModel)1