package com.ifish.jpush; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.gson.JsonObject; import com.ifish.jpush.common.resp.APIConnectionException; import com.ifish.jpush.common.resp.APIRequestException; import com.ifish.jpush.push.PushResult; public class JPushNotification { protected final Logger LOG = LoggerFactory.getLogger(JPushNotification.class); JPushClient jpushClient = null; public JPushNotification(String appKey,String masterSecret,boolean productionModel){ jpushClient = new JPushClient(masterSecret, appKey , productionModel ,86400); } public void sendIosNotification(String[] alias,String title,String body,Map extras) { try { JsonObject json = new JsonObject(); json.addProperty("title", title); json.addProperty("body", body); PushResult result = jpushClient.sendIosNotificationWithAlias(json, extras, alias); } catch (APIConnectionException e) { LOG.error("Connection error. Should retry later. ", e); } catch (APIRequestException e) { LOG.error("Error Message: " + e.getMessage()); } } /*public void sendAndroidNotification(String[] alias,String title,String alert,Map map) { try { PushResult result = jpushClient.sendAndroidNotificationWithAlias(title ,alert, map, alias); } catch (APIConnectionException e) { LOG.error("Connection error. Should retry later. ", e); } catch (APIRequestException e) { LOG.error("Error Message: " + e.getMessage()); } }*/ }