本文整理汇总了Java中javapns.notification.PushNotificationPayload.addAlert方法的典型用法代码示例。如果您正苦于以下问题:Java PushNotificationPayload.addAlert方法的具体用法?Java PushNotificationPayload.addAlert怎么用?Java PushNotificationPayload.addAlert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javapns.notification.PushNotificationPayload
的用法示例。
在下文中一共展示了PushNotificationPayload.addAlert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPayload
import javapns.notification.PushNotificationPayload; //导入方法依赖的package包/类
/**
* Create a payload to be sent to client device.
*
* @param alertMessage Message that is visible to end user
* @param hiddenMessage Message that is invisible to end user
* @return a push notification payload to send to client device
*/
public PushNotificationPayload createPayload(String alertMessage,
String hiddenMessage) {
if (StringUtility.isNullOrEmpty(alertMessage) || StringUtility.isNullOrEmpty(hiddenMessage)) {
throw new IllegalArgumentException("Input arguments cannot be a null or an empty String");
}
PushNotificationPayload payload = new PushNotificationPayload();
try {
payload.addAlert(alertMessage);
payload.addCustomDictionary("hiddenMessage", hiddenMessage);
} catch (JSONException e) {
log.warning(e.getClass().toString() + " " + e.getMessage());
}
return payload;
}
示例2: sendIosInvitationNotification
import javapns.notification.PushNotificationPayload; //导入方法依赖的package包/类
/**
* Sends an invitation notification to iOS devices.
*
* @param iOsDevices the list of Android devices to send the notification to.
* @param invitee the Player who has been invited.
* @param invitationId the invitation id.
* @param gameId the game id.
* @param messageText invitationText to be sent.
* @throws CommunicationException if an error occurred while sending iOS push notifications.
*/
private void sendIosInvitationNotification(List<DeviceEntity> iOsDevices, PlayerEntity invitee,
long invitationId, long gameId, String messageText) throws CommunicationException {
PushNotificationPayload payload = PushNotificationPayload.complex();
try {
payload.addAlert(messageText);
payload.addCustomDictionary("invitationId", String.valueOf(invitationId));
payload.addCustomDictionary("gameId", String.valueOf(gameId));
payload.addCustomDictionary("playerId", String.valueOf(invitee.getId()));
payload.addCustomDictionary("nickName", invitee.getNickname());
IosNotificationService notificationService = new IosNotificationService();
notificationService.sendPushNotification(iOsDevices, payload, invitee.getKey());
} catch (JSONException e) {
logger.log(Level.WARNING, "Invalid format of a push notification payload", e);
}
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-griddler-sample-backend-java,代码行数:28,代码来源:InvitationService.java