From 6a4d58a65e916323b1ea11b36b27e47943482f18 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 15 十二月 2018 15:44:33 +0800
Subject: [PATCH] 添加IOS的weex,百川推送支持

---
 fanli/src/main/java/com/yeshi/fanli/util/factory/IOSPushFactory.java |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 53 insertions(+), 4 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..08e33d1 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
@@ -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();
 			}
@@ -113,4 +114,52 @@
 		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", PushController.WEEX);
+		alert.put("url", shortUrl);
+
+		JSONObject aps = new JSONObject();
+		aps.put("alert", alert);
+		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", PushController.BAICHUAN);
+		alert.put("url", shortUrl);
+
+		JSONObject aps = new JSONObject();
+		aps.put("alert", alert);
+		JSONObject json = new JSONObject();
+		json.put("aps", aps);
+		return filterPushContent(json);
+	}
+
 }

--
Gitblit v1.8.0