package com.yeshi.fanli.util.factory;
|
|
import com.yeshi.fanli.controller.admin.PushController;
|
|
import net.sf.json.JSONObject;
|
|
public class IOSPushFactory {
|
/**
|
* IOS商品推送 返回JSON的字符串长度小于等于256
|
*
|
* @param auctionId
|
* 淘宝商品ID
|
* @param title
|
* @param body
|
* @return
|
*/
|
public static JSONObject createGoodsPush(Long auctionId, String title, String body) {
|
JSONObject alert = new JSONObject();
|
alert.put("title", title);
|
alert.put("body", body);
|
alert.put("badge", "1");
|
alert.put("sound", "default");
|
alert.put("url", "http://id=" + auctionId);
|
alert.put("type", PushController.GOODS);
|
JSONObject aps = new JSONObject();
|
aps.put("alert", alert);
|
JSONObject json = new JSONObject();
|
json.put("aps", aps);
|
return json;
|
}
|
|
/**
|
* IOS站内信推送 返回JSON的字符串长度小于等于256
|
*
|
* @param title
|
* @param body
|
* @return
|
*/
|
public static JSONObject createZNXPush(String title, String body) {
|
JSONObject alert = new JSONObject();
|
alert.put("title", title);
|
alert.put("body", body);
|
alert.put("badge", "1");
|
alert.put("sound", "default");
|
alert.put("type", PushController.ZNX);
|
JSONObject aps = new JSONObject();
|
aps.put("alert", alert);
|
JSONObject json = new JSONObject();
|
json.put("aps", aps);
|
return json;
|
}
|
|
/**
|
* IOS链接推送 返回JSON的字符串长度小于等于256
|
*
|
* @param shortUrl
|
* 短链
|
* @param title
|
* @param body
|
* @return
|
*/
|
public static JSONObject createURLPush(String shortUrl, String title, String body) {
|
JSONObject alert = new JSONObject();
|
alert.put("title", title);
|
alert.put("body", body);
|
alert.put("badge", "1");
|
alert.put("sound", "default");
|
alert.put("type", PushController.URL);
|
alert.put("url", shortUrl);
|
|
JSONObject aps = new JSONObject();
|
aps.put("alert", alert);
|
JSONObject json = new JSONObject();
|
json.put("aps", aps);
|
return json;
|
}
|
|
}
|