本文整理汇总了Java中javapns.notification.PushedNotification.getResponse方法的典型用法代码示例。如果您正苦于以下问题:Java PushedNotification.getResponse方法的具体用法?Java PushedNotification.getResponse怎么用?Java PushedNotification.getResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javapns.notification.PushedNotification
的用法示例。
在下文中一共展示了PushedNotification.getResponse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: procesarPushed
import javapns.notification.PushedNotification; //导入方法依赖的package包/类
public static Result procesarPushed(PushedNotification notification) {
Result r = new Result();
String diviceToken = notification.getDevice().getToken();
if (notification.isSuccessful()) {
r.setMessageId("OK");
} else {
Exception theProblem = notification.getException();
if (theProblem != null) {
r.setError(theProblem.getMessage());
LOGGER.error("[iOS] Excepcion retornada al notificar "
+ diviceToken + " " + theProblem.getMessage());
}
/*
* If the problem was an error-response packet returned by
* Apple, get it
*/
ResponsePacket theErrorResponse = notification.getResponse();
if (theErrorResponse != null) {
if (GlobalCodes.iosTokenError.contains(String.valueOf(theErrorResponse.getStatus()))) {
r.setOriginalRegistrationId(diviceToken);
}
r.setMessageId(String.valueOf(theErrorResponse.getIdentifier()));
r.setStatus(theErrorResponse.getStatus());
r.setError(theErrorResponse.getMessage());
}
}
return r;
}
示例2: processPushedNotifications
import javapns.notification.PushedNotification; //导入方法依赖的package包/类
private void processPushedNotifications(String taskName, PushedNotifications notifications) {
List<String> invalidTokens = new ArrayList<String>();
for (PushedNotification notification : notifications) {
if (!notification.isSuccessful()) {
log.log(Level.WARNING,
"Notification to device " + notification.getDevice().getToken() +
" from task " + taskName + " wasn't successful.",
notification.getException());
// Check if APNS returned an error-response packet.
ResponsePacket errorResponse = notification.getResponse();
if (errorResponse != null) {
if (errorResponse.getStatus() == 8) {
String invalidToken = notification.getDevice().getToken();
invalidTokens.add(invalidToken);
}
log.warning("Error response packet: " + errorResponse.getMessage());
}
}
if (invalidTokens.size() > 0) {
Utility.enqueueRemovingDeviceTokens(invalidTokens);
}
}
}
示例3: sendPushAlert
import javapns.notification.PushedNotification; //导入方法依赖的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);
}
}
示例4: processPushedNotifications
import javapns.notification.PushedNotification; //导入方法依赖的package包/类
private void processPushedNotifications(String taskName, PushedNotifications notifications) {
List<String> invalidTokens = new ArrayList<String>();
for (PushedNotification notification : notifications) {
if (!notification.isSuccessful()) {
log.log(Level.WARNING,
"Notification to device " + notification.getDevice().getToken() +
" from task " + taskName + " wasn't successful.",
notification.getException());
// Check if APNS returned an error-response packet.
ResponsePacket errorResponse = notification.getResponse();
if (errorResponse != null) {
if (errorResponse.getStatus() == 8) {
String invalidToken = notification.getDevice().getToken();
invalidTokens.add(invalidToken);
}
log.warning("Error response packet: " + errorResponse.getMessage());
}
}
if (invalidTokens.size() > 0) {
PushNotificationUtility.enqueueRemovingDeviceTokens(invalidTokens);
}
}
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-ios-push-notification-sample-backend-java,代码行数:28,代码来源:PushNotificationWorker.java