本文整理汇总了Java中javapns.notification.PushedNotifications类的典型用法代码示例。如果您正苦于以下问题:Java PushedNotifications类的具体用法?Java PushedNotifications怎么用?Java PushedNotifications使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PushedNotifications类属于javapns.notification包,在下文中一共展示了PushedNotifications类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: send
import javapns.notification.PushedNotifications; //导入依赖的package包/类
public IosResponse send(Payload payload, File certificado, String keyFile,
Boolean productionMode, List<String> devices) throws BusinessException {
try {
LOGGER.info("Enviando notificacion IOS");
PushedNotifications result;
String threads = parametroDao.getByName("IOS_THREADS").getValor();
if (threads != null && devices.size() >= Integer.parseInt(threads)) {
result = Push.payload(payload, certificado,
keyFile, productionMode, Integer.parseInt(threads), devices);
} else {
result = Push.payload(payload, certificado,
keyFile, productionMode, devices);
}
LOGGER.info("Procesando response: " + result.toString());
return procesarResponse(result);
} catch (CommunicationException e) {
LOGGER.error("CommunicationException" + e.getMessage());
throw new BusinessException(GlobalCodes.errors.IOS_COMM, e);
} catch (KeystoreException e1) {
LOGGER.error("KeystoreException" + e1.getMessage());
throw new BusinessException(GlobalCodes.errors.IOS_KEY_STORE, e1);
} catch (Exception ex) {
LOGGER.error("Exception" + ex.getMessage());
throw new BusinessException(GlobalCodes.errors.IOS_PUSH_PAYLOAD, ex);
}
}
开发者ID:jokoframework,项目名称:notification-server,代码行数:27,代码来源:ApnsFacade.java
示例2: procesarResponse
import javapns.notification.PushedNotifications; //导入依赖的package包/类
private static IosResponse procesarResponse(PushedNotifications result) {
IosResponse ios = new IosResponse();
ios.setFailure(result.getFailedNotifications().size());
ios.setSuccess(result.getSuccessfulNotifications().size());
ios.setResults(new ArrayList<Result>());
for (PushedNotification notification : result) {
LOGGER.info("[iOs] Divice: " + notification.getDevice().getToken());
Result r = procesarPushed(notification);
r.setIosResponse(ios);
ios.getResults().add(r);
}
return ios;
}
开发者ID:jokoframework,项目名称:notification-server,代码行数:14,代码来源:ApnsFacade.java
示例3: processPushedNotifications
import javapns.notification.PushedNotifications; //导入依赖的package包/类
private void processPushedNotifications(Map<String, PushedNotifications> pushedNotifications) {
notificationSender.processedPendingNotificationResponses();
for (String taskName : pushedNotifications.keySet()) {
processPushedNotifications(taskName, pushedNotifications.get(taskName));
}
}
开发者ID:googlesamples,项目名称:io2014-codelabs,代码行数:8,代码来源:Worker.java
示例4: sendAlert
import javapns.notification.PushedNotifications; //导入依赖的package包/类
/**
* Sends an alert notification to a list of devices.
*
* @param alertMessage alert to be sent as a push notification
* @param deviceTokens the list of tokens for devices to which the notifications should be sent
* @return a list of pushed notifications that contain details on transmission results.
* @throws javapns.communication.exceptions.CommunicationException thrown if an error occurred while communicating with the target
* server even after a few retries.
* @throws javapns.communication.exceptions.KeystoreException thrown if an error occurs with using the certificate.
*/
public PushedNotifications sendAlert(String alertMessage, String[] deviceTokens)
throws CommunicationException, KeystoreException {
log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
+ " devices started at " + dateFormat.format(new Date()) + ".");
PushedNotifications notifications =
sendPayload(PushNotificationPayload.alert(alertMessage), deviceTokens);
log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
+ " devices completed at " + dateFormat.format(new Date()) + ".");
return notifications;
}
开发者ID:googlesamples,项目名称:io2014-codelabs,代码行数:24,代码来源:Sender.java
示例5: sendPushAlert
import javapns.notification.PushedNotifications; //导入依赖的package包/类
@Override
public void sendPushAlert(PushMessage pushMessage) {
validate(pushMessage);
try {
PushedNotifications pushedNotifications = Push.alert(pushMessage.getMessage(), apnsCertFile,
apnsCertPassword, apnsProduction, pushMessage.getDeviceToken());
for (PushedNotification notification : pushedNotifications) {
if (notification.isSuccessful()) {
/* Apple accepted the notification and should deliver it */
log.debug("Push notification sent successfully to: " + notification.getDevice().getToken());
messageLogger.info(pushMessage.getDeviceToken() + " - " + pushMessage.getMessage());
/* TODO Query the Feedback Service regularly */
} else {
String invalidToken = notification.getDevice().getToken();
log.warn("Push notification failed. Invalid token: " + invalidToken, notification.getException());
/*
* If the problem was an error-response packet returned by
* Apple, get it
*/
ResponsePacket theErrorResponse = notification.getResponse();
if (theErrorResponse != null) {
log.warn("Apple error", theErrorResponse.getMessage());
}
throw new RuntimeException("Could not send notification with token " + pushMessage.getDeviceToken());
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:MinHalsoplan,项目名称:netcare-healthplan,代码行数:40,代码来源:PushServiceImpl.java
示例6: sendAlert
import javapns.notification.PushedNotifications; //导入依赖的package包/类
/**
* Sends an alert notification to a list of devices.
*
* @param alertMessage alert to be sent as a push notification
* @param deviceTokens the list of tokens for devices to which the notifications should be sent
* @return a list of pushed notifications that contain details on transmission results.
* @throws CommunicationException thrown if an error occurred while communicating with the target
* server even after a few retries.
* @throws KeystoreException thrown if an error occurs with using the certificate.
*/
public PushedNotifications sendAlert(String alertMessage, String[] deviceTokens)
throws CommunicationException, KeystoreException {
log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
+ " devices started at " + dateFormat.format(new Date()) + ".");
PushedNotifications notifications =
sendPayload(PushNotificationPayload.alert(alertMessage), deviceTokens);
log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
+ " devices completed at " + dateFormat.format(new Date()) + ".");
return notifications;
}
开发者ID:googlearchive,项目名称:solutions-mobile-backend-starter-java,代码行数:24,代码来源:Sender.java
示例7: sendAlert
import javapns.notification.PushedNotifications; //导入依赖的package包/类
/**
* Sends an alert notification to a list of devices.
*
* @param alertMessage alert to be sent as a push notification
* @param deviceTokens the list of tokens for devices to which the notifications should be sent
* @return a list of pushed notifications that contain details on transmission results.
* @throws CommunicationException thrown if an error occurred while communicating with the target
* server even after a few retries.
* @throws KeystoreException thrown if an error occurs with using the certificate.
*/
public PushedNotifications sendAlert(String alertMessage, String[] deviceTokens)
throws CommunicationException, KeystoreException {
log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
+ " devices started at " + dateFormat.format(new Date()) + ".");
PushedNotifications notifications =
sendPayload(PushNotificationPayload.alert(alertMessage), deviceTokens);
log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
+ " devices completed at " + dateFormat.format(new Date()) + ".");
return notifications;
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-ios-push-notification-sample-backend-java,代码行数:24,代码来源:PushNotificationSender.java
示例8: sendToUsers
import javapns.notification.PushedNotifications; //导入依赖的package包/类
@PostMapping(value = "/toUsers")
public Callable<BaseModel<?>> sendToUsers(@RequestBody IosPushReq message) {
return new Callable<BaseModel<?>>() {
@Override
public BaseModel<?> call() throws Exception {
String certKeyPath = pushServerInfo.getIos().getCertKeyPath();
String keyPassword = pushServerInfo.getIos().getCertPassword();
try {
List<String> tokens = new ArrayList<String>();
for (UserToken user: message.getUserTokenList()) {
String token;
if (user.getUserToken() != null) {
token = user.getUserToken();
} else {
token = userTokenService.getToken(user.getUserId());
}
if (token != null && token.startsWith("ios:")) {
tokens.add(token.substring(4));
}
}
if (!tokens.isEmpty()) {
PushNotificationPayload payload =
PushNotificationPayload.alert(message.getContent());
payload.addSound("default");
payload.addCustomDictionary("time", CommonUtils.currentTimeSeconds());
payload.addCustomDictionary("msg_type", message.getMsgType());
payload.addCustomDictionary("from_id", message.getFromId());
// 群组时
if (CommonUtils.isGroup(message.getMsgType())) {
payload.addCustomDictionary("group_id", message.getGroupId());
}
PushedNotifications apnResults;
if (pushServerInfo.isTestMode()) {
apnResults =
Push.payload(payload, certKeyPath, keyPassword, false, 30, tokens);
} else {
apnResults =
Push.payload(payload, certKeyPath, keyPassword, true, 30, tokens);
}
if (apnResults != null) {
for (PushedNotification apnResult : apnResults) {
// ResponsePacket responsePacket = apnResult.getResponse();
if (apnResult.isSuccessful()) {
logger.debug("推送结果:成功");
// logger.debug("推送结果:",
// responsePacket.getStatus(),responsePacket.getMessage());
} else {
logger.debug("推送结果:失败");
}
}
}
}
return new BaseModel<Integer>();
} catch (Exception e) {
logger.error("Iphone 推送失败!", e);
throw new Exception("推送失败!");
}
}
};
}
开发者ID:ccfish86,项目名称:sctalk,代码行数:72,代码来源:IphonePushServiceController.java
注:本文中的javapns.notification.PushedNotifications类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论