|
|
@@ -21,7 +21,7 @@ public class PushUtils {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void sendAndroidBroadcast(String ticker, String title, String text) throws Exception {
|
|
|
+ public void sendAndroidBroadcast(String ticker, String title, String text, boolean production) throws Exception {
|
|
|
AndroidBroadcast broadcast = new AndroidBroadcast(appkey, appMasterSecret);
|
|
|
broadcast.setTicker(ticker);
|
|
|
broadcast.setTitle(title);
|
|
|
@@ -30,7 +30,11 @@ public class PushUtils {
|
|
|
broadcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
|
|
|
// TODO Set 'production_mode' to 'false' if it's a test device.
|
|
|
// For how to register a test device, please see the developer doc.
|
|
|
- broadcast.setProductionMode();
|
|
|
+ if (production) {
|
|
|
+ broadcast.setProductionMode();
|
|
|
+ } else {
|
|
|
+ broadcast.setTestMode();
|
|
|
+ }
|
|
|
// Set customized fields
|
|
|
// broadcast.setExtraField("test", "helloworld");
|
|
|
//厂商通道相关参数
|
|
|
@@ -156,7 +160,7 @@ public class PushUtils {
|
|
|
client.send(filecast);
|
|
|
}
|
|
|
|
|
|
- public void sendIOSBroadcast(String title, String text) throws Exception {
|
|
|
+ public void sendIOSBroadcast(String title, String text, boolean production) throws Exception {
|
|
|
IOSBroadcast broadcast = new IOSBroadcast(appkey, appMasterSecret);
|
|
|
//alert值设置为字符串
|
|
|
//broadcast.setAlert("IOS 广播测试");
|
|
|
@@ -165,7 +169,11 @@ public class PushUtils {
|
|
|
broadcast.setBadge(0);
|
|
|
broadcast.setSound("default");
|
|
|
// TODO set 'production_mode' to 'true' if your app is under production mode
|
|
|
- broadcast.setTestMode();
|
|
|
+ if (production) {
|
|
|
+ broadcast.setProductionMode();
|
|
|
+ } else {
|
|
|
+ broadcast.setTestMode();
|
|
|
+ }
|
|
|
// Set customized fields
|
|
|
broadcast.setCustomizedField("test", "helloworld");
|
|
|
client.send(broadcast);
|
|
|
@@ -257,7 +265,7 @@ public class PushUtils {
|
|
|
public static void main(String[] args) {
|
|
|
try {
|
|
|
new PushUtils("62b5753a05844627b5c56bc8", "lynwia75tojrokcmqu9nyiukhjdrefof")
|
|
|
- .sendIOSBroadcast("test", "123");
|
|
|
+ .sendIOSBroadcast("test", "123", false);
|
|
|
} catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
}
|