package org.wso2.carbon.device.mgt.ios.apns.service.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.ios.apns.exception.APNSException;

import java.io.InputStream;

public class PushNotificationSenderService {

    private static PushNotificationSenderService pushNotificationSenderService;
    private static final Log log = LogFactory.getLog(PushNotificationSenderService.class);

    public static PushNotificationSenderService getInstance() {

        if (pushNotificationSenderService == null) {
            pushNotificationSenderService = new PushNotificationSenderService();
        }

        return pushNotificationSenderService;
    }

    public void sendNotification(InputStream inputStream, String certPassword, boolean isProductionMode,
                                 String token, String title, String message) throws APNSException {

        PushNotificationSender pushNotificationSender =
                new PushNotificationSender(inputStream, certPassword, isProductionMode);
        pushNotificationSender.pushToAPNS(token, title, message);

    }

    public void sendSilentNotification(InputStream inputStream, String certPassword, boolean isProductionMode,
                                 String token, String operationCode, int operationId) throws APNSException {

        PushNotificationSender pushNotificationSender =
                new PushNotificationSender(inputStream, certPassword, isProductionMode);
        pushNotificationSender.silentPushToAPNS(token, operationCode, operationId);

    }
}
