Skip to content

Commit b161980

Browse files
committed
iosAlert add subtitle
1 parent 0332236 commit b161980

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

src/main/java/cn/jpush/api/push/model/notification/IosAlert.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
public class IosAlert implements PushModel {
1212

1313
private final String title;
14+
private final String subtitle;
1415
private final String body;
1516
private final String title_loc_key;
1617
private final String[] title_loc_args;
@@ -19,9 +20,10 @@ public class IosAlert implements PushModel {
1920
private final String[] loc_args;
2021
private final String launch_image;
2122

22-
private IosAlert(String title, String body, String title_loc_key, String[] title_loc_args,
23+
private IosAlert(String title, String subtitle, String body, String title_loc_key, String[] title_loc_args,
2324
String action_loc_key, String loc_key, String[] loc_args, String launch_image) {
2425
this.title = title;
26+
this.subtitle = subtitle;
2527
this.body = body;
2628
this.title_loc_key = title_loc_key;
2729
this.title_loc_args = title_loc_args;
@@ -43,6 +45,10 @@ public JsonElement toJSON() {
4345
json.addProperty("title", title);
4446
}
4547

48+
if ( StringUtils.isNotEmpty(subtitle) ) {
49+
json.addProperty("subtitle", subtitle);
50+
}
51+
4652
if( StringUtils.isNotEmpty(body) ) {
4753
json.addProperty("body", body);
4854
}
@@ -87,6 +93,7 @@ public String toString() {
8793

8894
public static class Builder {
8995
private String title;
96+
private String subtitle;
9097
private String body;
9198
private String title_loc_key;
9299
private String[] title_loc_args;
@@ -95,8 +102,9 @@ public static class Builder {
95102
private String[] loc_args;
96103
private String launch_image;
97104

98-
public Builder setTitleAndBody(String title, String body){
105+
public Builder setTitleAndBody(String title, String subtitle, String body){
99106
this.title = title;
107+
this.subtitle = subtitle;
100108
this.body = body;
101109
return this;
102110
}
@@ -124,7 +132,7 @@ public Builder setLaunchImage(String launch_image) {
124132
}
125133

126134
public IosAlert build() {
127-
return new IosAlert(title, body, title_loc_key, title_loc_args, action_loc_key,
135+
return new IosAlert(title, subtitle, body, title_loc_key, title_loc_args, action_loc_key,
128136
loc_key, loc_args, launch_image);
129137
}
130138
}

src/main/java/cn/jpush/api/push/model/notification/IosNotification.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public class IosNotification extends PlatformNotification {
3636
private static final String SOUND = "sound";
3737
private static final String CONTENT_AVAILABLE = "content-available";
3838
private static final String MUTABLE_CONTENT = "mutable-content";
39-
private static final String SUBTITLE = "subtitle";
4039
private static final String CATEGORY = "category";
4140

4241
private static final String ALERT_VALID_BADGE = "Badge number should be 0~99999, "
@@ -50,12 +49,11 @@ public class IosNotification extends PlatformNotification {
5049
private final boolean contentAvailable;
5150
private final String category;
5251
private final boolean mutableContent;
53-
private final String subtitle;
5452

5553

5654
private IosNotification(Object alert, String sound, String badge,
5755
boolean contentAvailable, boolean soundDisabled, boolean badgeDisabled,
58-
String category, boolean mutableContent, String subtitle,
56+
String category, boolean mutableContent,
5957
Map<String, String> extras,
6058
Map<String, Number> numberExtras,
6159
Map<String, Boolean> booleanExtras,
@@ -69,7 +67,6 @@ private IosNotification(Object alert, String sound, String badge,
6967
this.badgeDisabled = badgeDisabled;
7068
this.category = category;
7169
this.mutableContent = mutableContent;
72-
this.subtitle = subtitle;
7370
}
7471

7572
public static Builder newBuilder() {
@@ -113,11 +110,7 @@ public JsonElement toJSON() {
113110
if (mutableContent) {
114111
json.add(MUTABLE_CONTENT, new JsonPrimitive(1));
115112
}
116-
if (null != subtitle) {
117-
json.add(SUBTITLE, new JsonPrimitive(subtitle));
118-
}
119113

120-
121114
return json;
122115
}
123116

@@ -130,8 +123,7 @@ public static class Builder extends PlatformNotification.Builder<IosNotification
130123
private boolean badgeDisabled = false;
131124
private String category;
132125
private boolean mutableContent;
133-
private String subtitle;
134-
126+
135127
protected Builder getThis() {
136128
return this;
137129
}
@@ -202,15 +194,10 @@ public Builder setMutableContent(boolean mutableContent) {
202194
return this;
203195
}
204196

205-
public Builder setSubtitle(String subtitle) {
206-
this.subtitle = subtitle;
207-
return this;
208-
}
209-
210197

211198
public IosNotification build() {
212199
return new IosNotification(alert, sound, badge, contentAvailable,
213-
soundDisabled, badgeDisabled, category, mutableContent, subtitle,
200+
soundDisabled, badgeDisabled, category, mutableContent,
214201
extrasBuilder, numberExtrasBuilder, booleanExtrasBuilder, jsonExtrasBuilder);
215202
}
216203
}

0 commit comments

Comments
 (0)