忍耐能化怯懦为力量,焦急却化力量为懦弱。——科尔顿
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| JPushClient jpushClient = new JPushClient(jPushMasterSecret, jPushAppKey, null, ClientConfig.getInstance());
var payload = PushPayload.newBuilder() .setPlatform(Platform.ios()) .setAudience(Audience.all()) .setNotification(Notification.newBuilder() .addPlatformNotification(IosNotification.newBuilder() .setAlert(dto.getMsg()) .setBadge(0) .setSound("default") .build()) .build()) .setMessage(Message.content(dto.getContent())) .setOptions(Options.newBuilder() .setApnsProduction(true) .build()) .build();
try { PushResult result = jpushClient.sendPush(payload); sink.success(result); LOG.info("Got result - " + result);
} catch (APIConnectionException e) { LOG.error("Connection error, should retry later", e); sink.error(e); } catch (APIRequestException e) { LOG.error("Should review the error, and fix the request", e); LOG.info("HTTP Status: " + e.getStatus()); LOG.info("Error Code: " + e.getErrorCode()); LOG.info("Error Message: " + e.getErrorMessage()); sink.error(e); }
|
代码仓库:
https://github.com/jpush/jpush-api-java-client
文档如下:
创建推送 API - 极光文档