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

import org.wso2.carbon.device.mgt.ios.apns.exception.APNSException;

import java.io.InputStream;

public class MDMPushNotificationSenderService {

    private static MDMPushNotificationSenderService pushNotificationSenderService;

    public static MDMPushNotificationSenderService getInstance() {

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

        return  pushNotificationSenderService;
    }

    public void sendNotification(InputStream inputStream, String certPassword, boolean isProductionMode,
                                 String deviceToken, String magicToken) throws APNSException {

        if (deviceToken == null || magicToken == null) {
            throw new APNSException("Device token and magic token cannot be null");
        }

        MDMPushNotificationSender mdmPushNotificationSender =
                new MDMPushNotificationSender(inputStream, certPassword, isProductionMode);
        mdmPushNotificationSender.pushToAPNS(deviceToken, magicToken);

    }
}
