当前位置: 首页>>代码示例>>Java>>正文


Java PushedNotification.getResponse方法代码示例

本文整理汇总了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;
}
 
开发者ID:jokoframework,项目名称:notification-server,代码行数:29,代码来源:ApnsFacade.java

示例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);
    }
  }
}
 
开发者ID:googlesamples,项目名称:io2014-codelabs,代码行数:28,代码来源:Worker.java

示例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);
	}

}
 
开发者ID:MinHalsoplan,项目名称:netcare-healthplan,代码行数:40,代码来源:PushServiceImpl.java

示例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


注:本文中的javapns.notification.PushedNotification.getResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。