Commit 7a3b3adf by giaogiao

添加极光推送-安卓

parent 3f5570ad
......@@ -7,26 +7,13 @@ import java.util.HashSet;
public abstract class AndroidNotification extends UmengNotification {
// Keys can be set in the payload level
protected static final HashSet<String> PAYLOAD_KEYS = new HashSet<String>(Arrays.asList(new String[]{
"display_type"}));
protected static final HashSet<String> PAYLOAD_KEYS = new HashSet<String>(Arrays.asList("display_type"));
// Keys can be set in the body level
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",
"sound", "after_open", "url", "activity", "custom"}));
protected static final HashSet<String> BODY_KEYS = new HashSet<String>(Arrays.asList("ticker", "title", "text", "builder_id", "icon", "largeIcon", "img", "play_vibrate", "play_lights", "play_sound",
"sound", "after_open", "url", "activity", "custom"));
public enum DisplayType{
NOTIFICATION{public String getValue(){return "notification";}},///通知:消息送达到用户设备后,由友盟SDK接管处理并在通知栏上显示通知内容。
MESSAGE{public String getValue(){return "message";}};///消息:消息送达到用户设备后,消息内容透传给应用自身进行解析处理。
public abstract String getValue();
}
public enum AfterOpenAction{
go_app,//打开应用
go_url,//跳转到URL
go_activity,//打开特定的activity
go_custom//用户自定义内容。
}
// Set key/value in the rootJson, for the keys can be set please see ROOT_KEYS, PAYLOAD_KEYS,
// Set key/value in the rootJson, for the keys can be set please see ROOT_KEYS, PAYLOAD_KEYS,
// BODY_KEYS and POLICY_KEYS.
@Override
public boolean setPredefinedKeyValue(String key, Object value) throws Exception {
......@@ -81,7 +68,7 @@ public abstract class AndroidNotification extends UmengNotification {
}
return true;
}
// Set extra key/value for Android notification
public boolean setExtraField(String key, String value) throws Exception {
JSONObject payloadJson = null;
......@@ -92,7 +79,7 @@ public abstract class AndroidNotification extends UmengNotification {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
if (payloadJson.has("extra")) {
extraJson = payloadJson.getJSONObject("extra");
} else {
......@@ -102,98 +89,140 @@ public abstract class AndroidNotification extends UmengNotification {
extraJson.put(key, value);
return true;
}
//
public void setDisplayType(DisplayType d) throws Exception {
setPredefinedKeyValue("display_type", d.getValue());
}
///通知栏提示文字
public void setTicker(String ticker) throws Exception {
setPredefinedKeyValue("ticker", ticker);
}
///通知标题
public void setTitle(String title) throws Exception {
setPredefinedKeyValue("title", title);
}
///通知文字描述
public void setText(String text) throws Exception {
setPredefinedKeyValue("text", text);
}
///用于标识该通知采用的样式。使用该参数时, 必须在SDK里面实现自定义通知栏样式。
public void setBuilderId(Integer builder_id) throws Exception {
setPredefinedKeyValue("builder_id", builder_id);
}
///状态栏图标ID, R.drawable.[smallIcon],如果没有, 默认使用应用图标。
public void setIcon(String icon) throws Exception {
setPredefinedKeyValue("icon", icon);
}
///通知栏拉开后左侧图标ID
public void setLargeIcon(String largeIcon) throws Exception {
setPredefinedKeyValue("largeIcon", largeIcon);
}
///通知栏大图标的URL链接。该字段的优先级大于largeIcon。该字段要求以http或者https开头。
public void setImg(String img) throws Exception {
setPredefinedKeyValue("img", img);
}
///收到通知是否震动,默认为"true"
public void setPlayVibrate(Boolean play_vibrate) throws Exception {
setPredefinedKeyValue("play_vibrate", play_vibrate.toString());
}
///收到通知是否闪灯,默认为"true"
public void setPlayLights(Boolean play_lights) throws Exception {
setPredefinedKeyValue("play_lights", play_lights.toString());
}
///收到通知是否发出声音,默认为"true"
public void setPlaySound(Boolean play_sound) throws Exception {
setPredefinedKeyValue("play_sound", play_sound.toString());
}
///通知声音,R.raw.[sound]. 如果该字段为空,采用SDK默认的声音
public void setSound(String sound) throws Exception {
setPredefinedKeyValue("sound", sound);
}
///收到通知后播放指定的声音文件
public void setPlaySound(String sound) throws Exception {
setPlaySound(true);
setSound(sound);
}
///点击"通知"的后续行为,默认为打开app。
public void goAppAfterOpen() throws Exception {
setAfterOpenAction(AfterOpenAction.go_app);
}
public void goUrlAfterOpen(String url) throws Exception {
setAfterOpenAction(AfterOpenAction.go_url);
setUrl(url);
}
public void goActivityAfterOpen(String activity) throws Exception {
setAfterOpenAction(AfterOpenAction.go_activity);
setActivity(activity);
}
public void goCustomAfterOpen(String custom) throws Exception {
setAfterOpenAction(AfterOpenAction.go_custom);
setCustomField(custom);
}
public void goCustomAfterOpen(JSONObject custom) throws Exception {
setAfterOpenAction(AfterOpenAction.go_custom);
setCustomField(custom);
}
///点击"通知"的后续行为,默认为打开app。原始接口
public void setAfterOpenAction(AfterOpenAction action) throws Exception {
setPredefinedKeyValue("after_open", action.toString());
}
public void setUrl(String url) throws Exception {
setPredefinedKeyValue("url", url);
}
public void setActivity(String activity) throws Exception {
setPredefinedKeyValue("activity", activity);
}
///can be a string of json
public void setCustomField(String custom) throws Exception {
setPredefinedKeyValue("custom", custom);
}
public void setCustomField(JSONObject custom) throws Exception {
setPredefinedKeyValue("custom", custom);
}
public enum DisplayType {
NOTIFICATION {
public String getValue() {
return "notification";
}
},///通知:消息送达到用户设备后,由友盟SDK接管处理并在通知栏上显示通知内容。
MESSAGE {
public String getValue() {
return "message";
}
};///消息:消息送达到用户设备后,消息内容透传给应用自身进行解析处理。
public abstract String getValue();
}
public enum AfterOpenAction {
go_app,//打开应用
go_url,//跳转到URL
go_activity,//打开特定的activity
go_custom//用户自定义内容。
}
}
......@@ -17,8 +17,8 @@ import org.json.JSONObject;
public class Demo {
private String appkey = null;
private String appMasterSecret = null;
private String timestamp = null;
private PushClient client = new PushClient();
private final String timestamp = null;
private final PushClient client = new PushClient();
public Demo(String key, String secret) {
try {
......@@ -30,6 +30,39 @@ public class Demo {
}
}
public static void main(String[] args) {
// AppKey:5f963f3ea1491772a2aef713
//
// Umeng Message Secret
// 1c37c3d437d76c1235ee19bcb9d2d8c6
// App Master Secret
// ti5gomxtvmkgehmwgtbq9rtsfhy0khsi
// TODO set your appkey and master secret here
// Demo demo = new Demo("your appkey", "your master secret");
Demo demo = new Demo("5f963f3ea1491772a2aef713", "ti5gomxtvmkgehmwgtbq9rtsfhy0khsi");
try {
demo.sendAndroidUnicast();
//demo.sendIOSUnicast();
/* TODO these methods are all available, just fill in some fields and do the test
* demo.sendAndroidCustomizedcastFile();
* demo.sendAndroidBroadcast();
* demo.sendAndroidGroupcast();
* demo.sendAndroidCustomizedcast();
* demo.sendAndroidFilecast();
*
* demo.sendIOSBroadcast();
* demo.sendIOSUnicast();
* demo.sendIOSGroupcast();
* demo.sendIOSCustomizedcast();
* demo.sendIOSFilecast();
*/
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void sendAndroidBroadcast() throws Exception {
AndroidBroadcast broadcast = new AndroidBroadcast(appkey, appMasterSecret);
broadcast.setTicker("Android broadcast ticker");
......@@ -197,7 +230,6 @@ public class Demo {
client.send(unicast);
}
public void sendIOSGroupcast() throws Exception {
IOSGroupcast groupcast = new IOSGroupcast(appkey, appMasterSecret);
/* TODO
......@@ -263,39 +295,6 @@ public class Demo {
client.send(filecast);
}
public static void main(String[] args) {
// AppKey:5f963f3ea1491772a2aef713
//
// Umeng Message Secret
// 1c37c3d437d76c1235ee19bcb9d2d8c6
// App Master Secret
// ti5gomxtvmkgehmwgtbq9rtsfhy0khsi
// TODO set your appkey and master secret here
// Demo demo = new Demo("your appkey", "your master secret");
Demo demo = new Demo("5f963f3ea1491772a2aef713", "ti5gomxtvmkgehmwgtbq9rtsfhy0khsi");
try {
demo.sendAndroidUnicast();
//demo.sendIOSUnicast();
/* TODO these methods are all available, just fill in some fields and do the test
* demo.sendAndroidCustomizedcastFile();
* demo.sendAndroidBroadcast();
* demo.sendAndroidGroupcast();
* demo.sendAndroidCustomizedcast();
* demo.sendAndroidFilecast();
*
* demo.sendIOSBroadcast();
* demo.sendIOSUnicast();
* demo.sendIOSGroupcast();
* demo.sendIOSCustomizedcast();
* demo.sendIOSFilecast();
*/
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
......@@ -7,87 +7,87 @@ import java.util.HashSet;
public abstract class IOSNotification extends UmengNotification {
// Keys can be set in the aps level
protected static final HashSet<String> APS_KEYS = new HashSet<String>(Arrays.asList(new String[]{
"alert", "badge", "sound", "content-available"
}));
@Override
public boolean setPredefinedKeyValue(String key, Object value) throws Exception {
if (ROOT_KEYS.contains(key)) {
// This key should be in the root level
rootJson.put(key, value);
} else if (APS_KEYS.contains(key)) {
// This key should be in the aps level
JSONObject apsJson = null;
JSONObject payloadJson = null;
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
if (payloadJson.has("aps")) {
apsJson = payloadJson.getJSONObject("aps");
} else {
apsJson = new JSONObject();
payloadJson.put("aps", apsJson);
}
apsJson.put(key, value);
} else if (POLICY_KEYS.contains(key)) {
// This key should be in the body level
JSONObject policyJson = null;
if (rootJson.has("policy")) {
policyJson = rootJson.getJSONObject("policy");
} else {
policyJson = new JSONObject();
rootJson.put("policy", policyJson);
}
policyJson.put(key, value);
} else {
if (key == "payload" || key == "aps" || key == "policy") {
throw new Exception("You don't need to set value for " + key + " , just set values for the sub keys in it.");
} else {
throw new Exception("Unknownd key: " + key);
}
}
return true;
}
// Set customized key/value for IOS notification
public boolean setCustomizedField(String key, String value) throws Exception {
//rootJson.put(key, value);
JSONObject payloadJson = null;
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
payloadJson.put(key, value);
return true;
}
// Keys can be set in the aps level
protected static final HashSet<String> APS_KEYS = new HashSet<String>(Arrays.asList("alert", "badge", "sound", "content-available"));
public void setAlert(String token) throws Exception {
setPredefinedKeyValue("alert", token);
@Override
public boolean setPredefinedKeyValue(String key, Object value) throws Exception {
if (ROOT_KEYS.contains(key)) {
// This key should be in the root level
rootJson.put(key, value);
} else if (APS_KEYS.contains(key)) {
// This key should be in the aps level
JSONObject apsJson = null;
JSONObject payloadJson = null;
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
if (payloadJson.has("aps")) {
apsJson = payloadJson.getJSONObject("aps");
} else {
apsJson = new JSONObject();
payloadJson.put("aps", apsJson);
}
apsJson.put(key, value);
} else if (POLICY_KEYS.contains(key)) {
// This key should be in the body level
JSONObject policyJson = null;
if (rootJson.has("policy")) {
policyJson = rootJson.getJSONObject("policy");
} else {
policyJson = new JSONObject();
rootJson.put("policy", policyJson);
}
policyJson.put(key, value);
} else {
if (key == "payload" || key == "aps" || key == "policy") {
throw new Exception("You don't need to set value for " + key + " , just set values for the sub keys in it.");
} else {
throw new Exception("Unknownd key: " + key);
}
}
return true;
}
public void setAlert(String title ,String subtitle , String body) throws Exception{
JSONObject object = new JSONObject();
object.put("title" , title);
object.put("subtitle" , subtitle);
object.put("body" , body);
setPredefinedKeyValue("alert",object );
}
public void setBadge(Integer badge) throws Exception {
setPredefinedKeyValue("badge", badge);
// Set customized key/value for IOS notification
public boolean setCustomizedField(String key, String value) throws Exception {
//rootJson.put(key, value);
JSONObject payloadJson = null;
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
payloadJson.put(key, value);
return true;
}
public void setSound(String sound) throws Exception {
setPredefinedKeyValue("sound", sound);
public void setAlert(String token) throws Exception {
setPredefinedKeyValue("alert", token);
}
public void setContentAvailable(Integer contentAvailable) throws Exception {
setPredefinedKeyValue("content-available", contentAvailable);
public void setAlert(String title, String subtitle, String body) throws Exception {
JSONObject object = new JSONObject();
object.put("title", title);
object.put("subtitle", subtitle);
object.put("body", body);
setPredefinedKeyValue("alert", object);
}
public void setBadge(Integer badge) throws Exception {
setPredefinedKeyValue("badge", badge);
}
public void setSound(String sound) throws Exception {
setPredefinedKeyValue("sound", sound);
}
public void setContentAvailable(Integer contentAvailable) throws Exception {
setPredefinedKeyValue("content-available", contentAvailable);
}
}
......@@ -10,37 +10,34 @@ import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
public class PushClient {
// The user agent
protected final String USER_AGENT = "Mozilla/5.0";
// This object is used for sending the post request to Umeng
protected HttpClient client = new DefaultHttpClient();
// The host
protected static final String host = "http://msg.umeng.com";
// The upload path
protected static final String uploadPath = "/upload";
// The post path
protected static final String postPath = "/api/send";
// The user agent
protected final String USER_AGENT = "Mozilla/5.0";
// This object is used for sending the post request to Umeng
protected HttpClient client = new DefaultHttpClient();
public boolean send(UmengNotification msg) throws Exception {
String timestamp = Integer.toString((int)(System.currentTimeMillis() / 1000));
String timestamp = Integer.toString((int) (System.currentTimeMillis() / 1000));
msg.setPredefinedKeyValue("timestamp", timestamp);
String url = host + postPath;
String postBody = msg.getPostBody();
String sign = DigestUtils.md5Hex(("POST" + url + postBody + msg.getAppMasterSecret()).getBytes("utf8"));
url = url + "?sign=" + sign;
HttpPost post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT);
StringEntity se = new StringEntity(postBody, "UTF-8");
post.setEntity(se);
// Send the post request and get the response
HttpResponse response = client.execute(post);
String url = host + postPath;
String postBody = msg.getPostBody();
String sign = DigestUtils.md5Hex(("POST" + url + postBody + msg.getAppMasterSecret()).getBytes(StandardCharsets.UTF_8));
url = url + "?sign=" + sign;
HttpPost post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT);
StringEntity se = new StringEntity(postBody, "UTF-8");
post.setEntity(se);
// Send the post request and get the response
HttpResponse response = client.execute(post);
int status = response.getStatusLine().getStatusCode();
System.out.println("Response Code : " + status);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
......@@ -48,28 +45,28 @@ public class PushClient {
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.out.println(result.toString());
if (status == 200) {
System.out.println("Notification sent successfully.");
} else {
System.out.println("Failed to send the notification!");
}
return true;
}
}
System.out.println(result.toString());
if (status == 200) {
System.out.println("Notification sent successfully.");
} else {
System.out.println("Failed to send the notification!");
}
return true;
}
// Upload file with device_tokens to Umeng
public String uploadContents(String appkey,String appMasterSecret,String contents) throws Exception {
public String uploadContents(String appkey, String appMasterSecret, String contents) throws Exception {
// Construct the json string
JSONObject uploadJson = new JSONObject();
uploadJson.put("appkey", appkey);
String timestamp = Integer.toString((int)(System.currentTimeMillis() / 1000));
String timestamp = Integer.toString((int) (System.currentTimeMillis() / 1000));
uploadJson.put("timestamp", timestamp);
uploadJson.put("content", contents);
// Construct the request
String url = host + uploadPath;
String postBody = uploadJson.toString();
String sign = DigestUtils.md5Hex(("POST" + url + postBody + appMasterSecret).getBytes("utf8"));
String sign = DigestUtils.md5Hex(("POST" + url + postBody + appMasterSecret).getBytes(StandardCharsets.UTF_8));
url = url + "?sign=" + sign;
HttpPost post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT);
......@@ -94,7 +91,7 @@ public class PushClient {
JSONObject data = respJson.getJSONObject("data");
String fileId = data.getString("file_id");
// Set file_id into rootJson using setPredefinedKeyValue
return fileId;
}
......
......@@ -6,80 +6,76 @@ import java.util.Arrays;
import java.util.HashSet;
public abstract class UmengNotification {
// Keys can be set in the root level
protected static final HashSet<String> ROOT_KEYS = new HashSet<String>(Arrays.asList("appkey", "timestamp", "type", "device_tokens", "alias", "alias_type", "file_id",
"filter", "production_mode", "feedback", "description", "thirdparty_id", "mipush", "mi_activity", "channel_properties"));
// Keys can be set in the policy level
protected static final HashSet<String> POLICY_KEYS = new HashSet<String>(Arrays.asList("start_time", "expire_time", "max_send_num"));
// This JSONObject is used for constructing the whole request string.
protected final JSONObject rootJson = new JSONObject();
// The app master secret
protected String appMasterSecret;
// Keys can be set in the root level
protected static final HashSet<String> ROOT_KEYS = new HashSet<String>(Arrays.asList(new String[]{
"appkey", "timestamp", "type", "device_tokens", "alias", "alias_type", "file_id",
"filter", "production_mode", "feedback", "description", "thirdparty_id" , "mipush" , "mi_activity" , "channel_properties"}));
// Keys can be set in the policy level
protected static final HashSet<String> POLICY_KEYS = new HashSet<String>(Arrays.asList(new String[]{
"start_time", "expire_time", "max_send_num"
}));
// Set predefined keys in the rootJson, for extra keys(Android) or customized keys(IOS) please
// Set predefined keys in the rootJson, for extra keys(Android) or customized keys(IOS) please
// refer to corresponding methods in the subclass.
public abstract boolean setPredefinedKeyValue(String key, Object value) throws Exception;
public void setAppMasterSecret(String secret) {
appMasterSecret = secret;
}
public String getPostBody(){
public String getPostBody() {
return rootJson.toString();
}
protected final String getAppMasterSecret(){
protected final String getAppMasterSecret() {
return appMasterSecret;
}
public void setAppMasterSecret(String secret) {
appMasterSecret = secret;
}
protected void setProductionMode(Boolean prod) throws Exception {
setPredefinedKeyValue("production_mode", prod.toString());
}
setPredefinedKeyValue("production_mode", prod.toString());
}
///正式模式
public void setProductionMode() throws Exception {
setProductionMode(true);
}
public void setProductionMode() throws Exception {
setProductionMode(true);
}
///测试模式
public void setTestMode() throws Exception {
setProductionMode(false);
///测试模式
public void setTestMode() throws Exception {
setProductionMode(false);
}
///发送消息描述,建议填写。
public void setDescription(String description) throws Exception {
setPredefinedKeyValue("description", description);
setPredefinedKeyValue("description", description);
}
///定时发送时间,若不填写表示立即发送。格式: "YYYY-MM-DD hh:mm:ss"。
public void setStartTime(String startTime) throws Exception {
setPredefinedKeyValue("start_time", startTime);
setPredefinedKeyValue("start_time", startTime);
}
///消息过期时间,格式: "YYYY-MM-DD hh:mm:ss"。
public void setExpireTime(String expireTime) throws Exception {
setPredefinedKeyValue("expire_time", expireTime);
}
///发送限速,每秒发送的最大条数。
public void setMaxSendNum(Integer num) throws Exception {
setPredefinedKeyValue("max_send_num", num);
setPredefinedKeyValue("expire_time", expireTime);
}
//厂商弹窗activity
public void setChannelActivity(String activity) throws Exception{
setPredefinedKeyValue("mipush", "true");
setPredefinedKeyValue("mi_activity",activity );
///发送限速,每秒发送的最大条数。
public void setMaxSendNum(Integer num) throws Exception {
setPredefinedKeyValue("max_send_num", num);
}
//厂商弹窗activity
public void setChannelActivity(String activity) throws Exception {
setPredefinedKeyValue("mipush", "true");
setPredefinedKeyValue("mi_activity", activity);
}
//厂商属性配置
public void setChannelProperties(String xiaoMiChannelId) throws Exception{
public void setChannelProperties(String xiaoMiChannelId) throws Exception {
JSONObject object = new JSONObject();
object.put("xiaomi_channel_id" , xiaoMiChannelId);
object.put("xiaomi_channel_id", xiaoMiChannelId);
setPredefinedKeyValue("channel_properties", object);
}
......
......@@ -3,9 +3,9 @@ package com.jumeirah.common.push.android;
import com.jumeirah.common.push.AndroidNotification;
public class AndroidBroadcast extends AndroidNotification {
public AndroidBroadcast(String appkey,String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "broadcast");
public AndroidBroadcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "broadcast");
}
}
......@@ -3,20 +3,20 @@ package com.jumeirah.common.push.android;
import com.jumeirah.common.push.AndroidNotification;
public class AndroidCustomizedcast extends AndroidNotification {
public AndroidCustomizedcast(String appkey,String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "customizedcast");
public AndroidCustomizedcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "customizedcast");
}
public void setAlias(String alias, String aliasType) throws Exception {
setPredefinedKeyValue("alias", alias);
setPredefinedKeyValue("alias_type", aliasType);
}
public void setFileId(String fileId, String aliasType) throws Exception {
setPredefinedKeyValue("file_id", fileId);
setPredefinedKeyValue("alias_type", aliasType);
}
public void setAlias(String alias,String aliasType) throws Exception {
setPredefinedKeyValue("alias", alias);
setPredefinedKeyValue("alias_type", aliasType);
}
public void setFileId(String fileId,String aliasType) throws Exception {
setPredefinedKeyValue("file_id", fileId);
setPredefinedKeyValue("alias_type", aliasType);
}
}
......@@ -3,13 +3,13 @@ package com.jumeirah.common.push.android;
import com.jumeirah.common.push.AndroidNotification;
public class AndroidFilecast extends AndroidNotification {
public AndroidFilecast(String appkey,String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "filecast");
}
public void setFileId(String fileId) throws Exception {
setPredefinedKeyValue("file_id", fileId);
public AndroidFilecast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "filecast");
}
public void setFileId(String fileId) throws Exception {
setPredefinedKeyValue("file_id", fileId);
}
}
\ No newline at end of file
package com.jumeirah.common.push.android;
import org.json.JSONObject;
import com.jumeirah.common.push.AndroidNotification;
import org.json.JSONObject;
public class AndroidGroupcast extends AndroidNotification {
public AndroidGroupcast(String appkey,String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "groupcast");
}
public void setFilter(JSONObject filter) throws Exception {
setPredefinedKeyValue("filter", filter);
public AndroidGroupcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "groupcast");
}
public void setFilter(JSONObject filter) throws Exception {
setPredefinedKeyValue("filter", filter);
}
}
......@@ -3,14 +3,14 @@ package com.jumeirah.common.push.android;
import com.jumeirah.common.push.AndroidNotification;
public class AndroidUnicast extends AndroidNotification {
public AndroidUnicast(String appkey,String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "unicast");
}
public void setDeviceToken(String token) throws Exception {
setPredefinedKeyValue("device_tokens", token);
public AndroidUnicast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "unicast");
}
public void setDeviceToken(String token) throws Exception {
setPredefinedKeyValue("device_tokens", token);
}
}
\ No newline at end of file
......@@ -3,10 +3,10 @@ package com.jumeirah.common.push.ios;
import com.jumeirah.common.push.IOSNotification;
public class IOSBroadcast extends IOSNotification {
public IOSBroadcast(String appkey,String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "broadcast");
public IOSBroadcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "broadcast");
}
}
......@@ -3,17 +3,17 @@ package com.jumeirah.common.push.ios;
import com.jumeirah.common.push.IOSNotification;
public class IOSCustomizedcast extends IOSNotification {
public IOSCustomizedcast(String appkey,String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "customizedcast");
public IOSCustomizedcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "customizedcast");
}
public void setAlias(String alias,String aliasType) throws Exception {
setPredefinedKeyValue("alias", alias);
setPredefinedKeyValue("alias_type", aliasType);
}
public void setAlias(String alias, String aliasType) throws Exception {
setPredefinedKeyValue("alias", alias);
setPredefinedKeyValue("alias_type", aliasType);
}
public void setFileId(String fileId, String aliasType) throws Exception {
setPredefinedKeyValue("file_id", fileId);
setPredefinedKeyValue("alias_type", aliasType);
......
......@@ -3,13 +3,13 @@ package com.jumeirah.common.push.ios;
import com.jumeirah.common.push.IOSNotification;
public class IOSFilecast extends IOSNotification {
public IOSFilecast(String appkey,String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "filecast");
public IOSFilecast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "filecast");
}
public void setFileId(String fileId) throws Exception {
setPredefinedKeyValue("file_id", fileId);
}
setPredefinedKeyValue("file_id", fileId);
}
}
package com.jumeirah.common.push.ios;
import org.json.JSONObject;
import com.jumeirah.common.push.IOSNotification;
import org.json.JSONObject;
public class IOSGroupcast extends IOSNotification {
public IOSGroupcast(String appkey,String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "groupcast");
}
public void setFilter(JSONObject filter) throws Exception {
setPredefinedKeyValue("filter", filter);
public IOSGroupcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "groupcast");
}
public void setFilter(JSONObject filter) throws Exception {
setPredefinedKeyValue("filter", filter);
}
}
......@@ -3,13 +3,13 @@ package com.jumeirah.common.push.ios;
import com.jumeirah.common.push.IOSNotification;
public class IOSUnicast extends IOSNotification {
public IOSUnicast(String appkey,String appMasterSecret) throws Exception{
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "unicast");
public IOSUnicast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "unicast");
}
public void setDeviceToken(String token) throws Exception {
setPredefinedKeyValue("device_tokens", token);
}
setPredefinedKeyValue("device_tokens", token);
}
}
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