记得上下班打卡 | git大法好,push需谨慎

Commit 94c34eb5 authored by jiangxiulong's avatar jiangxiulong

推送增加 badge

parent 17b80e87
...@@ -189,6 +189,7 @@ public class AdminUpushServiceImpl extends ServiceImpl<AdminUpushMapper, AdminUp ...@@ -189,6 +189,7 @@ public class AdminUpushServiceImpl extends ServiceImpl<AdminUpushMapper, AdminUp
AdminUpush updatePush = new AdminUpush(); AdminUpush updatePush = new AdminUpush();
try { try {
AndroidBroadcast broadcast = new AndroidBroadcast(androidAppkey, androidAppMasterSecret); AndroidBroadcast broadcast = new AndroidBroadcast(androidAppkey, androidAppMasterSecret);
broadcast.setBadge(1);
broadcast.setTicker(adminUpush.getPushTitle()); broadcast.setTicker(adminUpush.getPushTitle());
broadcast.setTitle(adminUpush.getPushTitle()); broadcast.setTitle(adminUpush.getPushTitle());
broadcast.setText(adminUpush.getPushContent()); broadcast.setText(adminUpush.getPushContent());
...@@ -257,7 +258,7 @@ public class AdminUpushServiceImpl extends ServiceImpl<AdminUpushMapper, AdminUp ...@@ -257,7 +258,7 @@ public class AdminUpushServiceImpl extends ServiceImpl<AdminUpushMapper, AdminUp
IOSBroadcast broadcast = new IOSBroadcast(iosAppkey, iosAppMasterSecret); IOSBroadcast broadcast = new IOSBroadcast(iosAppkey, iosAppMasterSecret);
//alert的值设置为字典 //alert的值设置为字典
broadcast.setAlert(adminUpush.getPushTitle(), "", adminUpush.getPushContent()); broadcast.setAlert(adminUpush.getPushTitle(), "", adminUpush.getPushContent());
broadcast.setBadge(0); broadcast.setBadge(1);
broadcast.setSound("default"); broadcast.setSound("default");
if (Arrays.asList(LnsEnum.ENV.dev.name(), LnsEnum.ENV.test.name()).contains(environment.getProperty(CurrentUtil.CK_ENV_ACTIVE))) { if (Arrays.asList(LnsEnum.ENV.dev.name(), LnsEnum.ENV.test.name()).contains(environment.getProperty(CurrentUtil.CK_ENV_ACTIVE))) {
broadcast.setTestMode(); broadcast.setTestMode();
......
...@@ -13,7 +13,7 @@ public abstract class AndroidNotification extends UmengNotification { ...@@ -13,7 +13,7 @@ public abstract class AndroidNotification extends UmengNotification {
// Keys can be set in the body level // Keys can be set in the body level
protected static final HashSet<String> BODY_KEYS = new HashSet<String>(Arrays.asList(new String[]{ protected static final HashSet<String> BODY_KEYS = new HashSet<String>(Arrays.asList(new String[]{
"ticker", "title", "text", "builder_id", "icon", "largeIcon", "img", "play_vibrate", "play_lights", "play_sound", "ticker", "title", "text", "builder_id", "icon", "largeIcon", "img", "play_vibrate", "play_lights", "play_sound",
"sound", "after_open", "url", "activity", "custom"})); "sound", "after_open", "url", "activity", "custom", "badge"}));
public enum DisplayType{ public enum DisplayType{
NOTIFICATION{public String getValue(){return "notification";}},///通知:消息送达到用户设备后,由友盟SDK接管处理并在通知栏上显示通知内容。 NOTIFICATION{public String getValue(){return "notification";}},///通知:消息送达到用户设备后,由友盟SDK接管处理并在通知栏上显示通知内容。
...@@ -81,6 +81,10 @@ public abstract class AndroidNotification extends UmengNotification { ...@@ -81,6 +81,10 @@ public abstract class AndroidNotification extends UmengNotification {
} }
return true; return true;
} }
public void setBadge(Integer badge) throws Exception {
setPredefinedKeyValue("badge", badge);
}
// Set extra key/value for Android notification // Set extra key/value for Android notification
public boolean setExtraField(String key, String value) throws Exception { public boolean setExtraField(String key, String value) throws Exception {
...@@ -102,8 +106,7 @@ public abstract class AndroidNotification extends UmengNotification { ...@@ -102,8 +106,7 @@ public abstract class AndroidNotification extends UmengNotification {
extraJson.put(key, value); extraJson.put(key, value);
return true; return true;
} }
//
public void setDisplayType(DisplayType d) throws Exception { public void setDisplayType(DisplayType d) throws Exception {
setPredefinedKeyValue("display_type", d.getValue()); setPredefinedKeyValue("display_type", d.getValue());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment