|
1 | 1 | package cn.jpush.api.examples; |
2 | 2 |
|
3 | 3 | import cn.jpush.api.common.ClientConfig; |
| 4 | +import cn.jpush.api.push.model.*; |
4 | 5 | import cn.jpush.api.push.model.notification.IosAlert; |
5 | 6 | import org.slf4j.Logger; |
6 | 7 | import org.slf4j.LoggerFactory; |
|
9 | 10 | import cn.jpush.api.common.resp.APIConnectionException; |
10 | 11 | import cn.jpush.api.common.resp.APIRequestException; |
11 | 12 | import cn.jpush.api.push.PushResult; |
12 | | -import cn.jpush.api.push.model.Message; |
13 | | -import cn.jpush.api.push.model.Options; |
14 | | -import cn.jpush.api.push.model.Platform; |
15 | | -import cn.jpush.api.push.model.PushPayload; |
16 | 13 | import cn.jpush.api.push.model.audience.Audience; |
17 | 14 | import cn.jpush.api.push.model.audience.AudienceTarget; |
18 | 15 | import cn.jpush.api.push.model.notification.AndroidNotification; |
@@ -178,5 +175,21 @@ public static void testSendIosAlert() { |
178 | 175 | } |
179 | 176 | } |
180 | 177 |
|
| 178 | + public static void testSendWithSMS() { |
| 179 | + JPushClient jpushClient = new JPushClient(masterSecret, appKey); |
| 180 | + try { |
| 181 | + SMS sms = SMS.content("Test SMS", 10); |
| 182 | + PushResult result = jpushClient.sendAndroidMessageWithAlias("Test SMS", "test sms", sms, "alias1"); |
| 183 | + LOG.info("Got result - " + result); |
| 184 | + } catch (APIConnectionException e) { |
| 185 | + LOG.error("Connection error. Should retry later. ", e); |
| 186 | + } catch (APIRequestException e) { |
| 187 | + LOG.error("Error response from JPush server. Should review and fix it. ", e); |
| 188 | + LOG.info("HTTP Status: " + e.getStatus()); |
| 189 | + LOG.info("Error Code: " + e.getErrorCode()); |
| 190 | + LOG.info("Error Message: " + e.getErrorMessage()); |
| 191 | + } |
| 192 | + } |
| 193 | + |
181 | 194 | } |
182 | 195 |
|
0 commit comments