本文整理汇总了Java中javapns.devices.exceptions.InvalidDeviceTokenFormatException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidDeviceTokenFormatException类的具体用法?Java InvalidDeviceTokenFormatException怎么用?Java InvalidDeviceTokenFormatException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidDeviceTokenFormatException类属于javapns.devices.exceptions包,在下文中一共展示了InvalidDeviceTokenFormatException类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generatePayloadPerDevice
import javapns.devices.exceptions.InvalidDeviceTokenFormatException; //导入依赖的package包/类
private PayloadPerDevice generatePayloadPerDevice(IOSNotification notification) throws JSONException, InvalidDeviceTokenFormatException {
Payload payload = null;
switch (notification.getType()) {
case COMBINED:
payload = PushNotificationPayload.combined(notification.getMessage(), notification.getBadge(), notification.getSound());
break;
case BADGE:
payload = PushNotificationPayload.badge(notification.getBadge());
break;
case ALERT:
payload = PushNotificationPayload.alert(notification.getMessage());
break;
}
Map<String, Object> body = notification.getBody();
if (body != null) {
for (Entry<String, Object> entry : body.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof String) {
payload.addCustomDictionary(key, (String) value);
} else if (value instanceof Integer) {
payload.addCustomDictionary(key, value);
} else if (value instanceof List<?>) {
payload.addCustomDictionary(key, (List<?>) value);
} else {
payload.addCustomDictionary(key, value);
}
}
}
return new PayloadPerDevice(payload, notification.getRecipientId());
}