package cn.jpush.api.push.model.notification;
|
|
import com.google.gson.JsonElement;
|
import com.google.gson.JsonObject;
|
import com.google.gson.JsonPrimitive;
|
|
import java.util.Map;
|
|
/**
|
* <p><b>Windows Phone 通知类</b></p>
|
* <br>
|
* 具体使用方法请参考官方文档 https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#platform
|
* 支持 Winphone Notification 的参数:
|
* <ul>
|
* <li>alert: 继承自父类 PlatformNotification 的 alert 属性;本类设置则覆盖。</li>
|
* <li>title: 支持 setTitle(string) 方法来设置;可替换通知标题。 </li>
|
* <li>_open_page: 支持 setOpenPage(String) 方法来设置;可设置点击打开的页面名称</li>
|
* <li>extras: 继承自父类 PlatformNotification 的 extras 属性;支持通过 addExtra(key, value) 来添加自定义字段,具体看代码。 </li>
|
* </ul>
|
* <br>
|
*/
|
public class WinphoneNotification extends PlatformNotification {
|
private static final String NOTIFICATION_WINPHONE = "winphone";
|
|
private static final String TITLE = "title";
|
private static final String _OPEN_PAGE = "_open_page";
|
|
private final String title;
|
private final String openPage;
|
|
private WinphoneNotification(Object alert, String title, String openPage,
|
Map<String, String> extras,
|
Map<String, Number> numberExtras,
|
Map<String, Boolean> booleanExtras,
|
Map<String, JsonObject> jsonExtras,
|
Map<String, JsonPrimitive> customData) {
|
super(alert, extras, numberExtras, booleanExtras, jsonExtras, customData);
|
|
this.title = title;
|
this.openPage = openPage;
|
}
|
|
public static Builder newBuilder() {
|
return new Builder();
|
}
|
|
public static WinphoneNotification alert(String alert) {
|
return newBuilder().setAlert(alert).build();
|
}
|
|
|
@Override
|
public String getPlatform() {
|
return NOTIFICATION_WINPHONE;
|
}
|
|
@Override
|
public JsonElement toJSON() {
|
JsonObject json = super.toJSON().getAsJsonObject();
|
|
if (null != title) {
|
json.add(TITLE, new JsonPrimitive(title));
|
}
|
if (null != openPage) {
|
json.add(_OPEN_PAGE, new JsonPrimitive(openPage));
|
}
|
|
return json;
|
}
|
|
|
public static class Builder extends PlatformNotification.Builder<WinphoneNotification, Builder> {
|
private String title;
|
private String openPage;
|
|
@Override
|
protected Builder getThis() {
|
return this;
|
}
|
|
public Builder setTitle(String title) {
|
this.title = title;
|
return this;
|
}
|
|
public Builder setOpenPage(String openPage) {
|
this.openPage = openPage;
|
return this;
|
}
|
|
@Override
|
public Builder setAlert(Object alert) {
|
this.alert = alert;
|
return this;
|
}
|
|
|
public WinphoneNotification build() {
|
return new WinphoneNotification(alert, title, openPage,
|
extrasBuilder, numberExtrasBuilder, booleanExtrasBuilder, jsonExtrasBuilder, super.customData);
|
}
|
}
|
}
|