From 21c1c197ec0dba6da332bf4119c262267dcfb191 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期二, 26 五月 2020 10:29:03 +0800
Subject: [PATCH] 粉丝信息同步调整
---
fanli/src/main/java/com/yeshi/fanli/util/factory/IOSPushFactory.java | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 107 insertions(+), 8 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/util/factory/IOSPushFactory.java b/fanli/src/main/java/com/yeshi/fanli/util/factory/IOSPushFactory.java
index 4e137e7..fa7b643 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/factory/IOSPushFactory.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/factory/IOSPushFactory.java
@@ -2,7 +2,7 @@
import java.io.UnsupportedEncodingException;
-import com.yeshi.fanli.controller.admin.PushController;
+import com.yeshi.fanli.dto.push.PushTypeEnum;
import com.yeshi.fanli.util.StringUtil;
import net.sf.json.JSONObject;
@@ -12,7 +12,7 @@
private static JSONObject filterPushContent(JSONObject json) {
if (json != null)
try {
- boolean ischange= false;
+ boolean ischange = false;
while (json.toString().getBytes("UTF-8").length > 253) {
// 棣栧厛鍓婂噺鍐呭锛岀劧鍚庡墛鍑忔爣棰�
String title = json.optJSONObject("aps").optJSONObject("alert").optString("title");
@@ -26,16 +26,17 @@
}
} else {
ischange = true;
- json.optJSONObject("aps").optJSONObject("alert").put("body", body.substring(0, body.length() - 1));
+ json.optJSONObject("aps").optJSONObject("alert").put("body",
+ body.substring(0, body.length() - 1));
continue;
}
}
-
+
if (ischange) {
String body = json.optJSONObject("aps").optJSONObject("alert").optString("body");
json.optJSONObject("aps").optJSONObject("alert").put("body", body + "...");
}
-
+
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
@@ -58,10 +59,11 @@
alert.put("badge", "1");
alert.put("sound", "default");
alert.put("url", "http://id=" + auctionId);
- alert.put("type", PushController.GOODS);
+ alert.put("type",PushTypeEnum.goodsdetail.getCode());
JSONObject aps = new JSONObject();
aps.put("alert", alert);
+ //aps.put("badge", 1);
JSONObject json = new JSONObject();
json.put("aps", aps);
return filterPushContent(json);
@@ -80,9 +82,10 @@
alert.put("body", body);
alert.put("badge", "1");
alert.put("sound", "default");
- alert.put("type", PushController.ZNX);
+ alert.put("type", PushTypeEnum.ZNX.getCode());
JSONObject aps = new JSONObject();
aps.put("alert", alert);
+ //aps.put("badge", 1);
JSONObject json = new JSONObject();
json.put("aps", aps);
return filterPushContent(json);
@@ -103,14 +106,110 @@
alert.put("body", body);
alert.put("badge", "1");
alert.put("sound", "default");
- alert.put("type", PushController.URL);
+ alert.put("type",PushTypeEnum.url.getCode());
alert.put("url", shortUrl);
JSONObject aps = new JSONObject();
aps.put("alert", alert);
+ //aps.put("badge", 1);
JSONObject json = new JSONObject();
json.put("aps", aps);
return filterPushContent(json);
}
+ /**
+ * WEEX椤甸潰鎺ㄩ��
+ *
+ * @param shortUrl
+ * @param title
+ * @param body
+ * @return
+ */
+ public static JSONObject createWEEXPush(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", PushTypeEnum.weex.getCode());
+ alert.put("url", shortUrl);
+
+ JSONObject aps = new JSONObject();
+ aps.put("alert", alert);
+ //aps.put("badge", 1);
+ JSONObject json = new JSONObject();
+ json.put("aps", aps);
+ return filterPushContent(json);
+ }
+
+ /**
+ * 鐧惧窛缃戦〉鎺ㄩ��
+ *
+ * @param shortUrl
+ * @param title
+ * @param body
+ * @return
+ */
+ public static JSONObject createBaiChuanPush(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", PushTypeEnum.baichuan.getCode());
+ alert.put("url", shortUrl);
+
+ JSONObject aps = new JSONObject();
+ aps.put("alert", alert);
+ //aps.put("badge", 1);
+ JSONObject json = new JSONObject();
+ json.put("aps", aps);
+ return filterPushContent(json);
+ }
+
+ /**
+ * 绂忓埄涓績鎺ㄩ��
+ * @param title
+ * @param body
+ * @return
+ */
+ public static JSONObject createWelfarePush( 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", PushTypeEnum.welfare.getCode());
+
+ JSONObject aps = new JSONObject();
+ aps.put("alert", alert);
+ //aps.put("badge", 1);
+ JSONObject json = new JSONObject();
+ json.put("aps", aps);
+ return filterPushContent(json);
+ }
+
+
+ /**
+ * 鐢ㄦ埛绛惧埌
+ * @param title
+ * @param body
+ * @return
+ */
+ public static JSONObject createUserSignInPush( 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", PushTypeEnum.signin.getCode());
+
+ JSONObject aps = new JSONObject();
+ aps.put("alert", alert);
+ //aps.put("badge", 1);
+ JSONObject json = new JSONObject();
+ json.put("aps", aps);
+ return filterPushContent(json);
+ }
+
}
--
Gitblit v1.8.0