aboutsummaryrefslogtreecommitdiff
path: root/juick-notifications/src/main/java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-24 19:32:10 +0300
committerGravatar Vitaly Takmazov2018-10-24 19:32:10 +0300
commitfe021e7185c5f55a6fe69004cfd5c0374548ec85 (patch)
tree4279de25f19081788fbce3155bce716029c9a1cd /juick-notifications/src/main/java
parent5179d2a856172290a1af2a65c2968e3a3122ff8c (diff)
notifications: development notifications for me
Diffstat (limited to 'juick-notifications/src/main/java')
-rw-r--r--juick-notifications/src/main/java/com/juick/components/APNSManager.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/juick-notifications/src/main/java/com/juick/components/APNSManager.java b/juick-notifications/src/main/java/com/juick/components/APNSManager.java
index c38d1c6f..314a0bd1 100644
--- a/juick-notifications/src/main/java/com/juick/components/APNSManager.java
+++ b/juick-notifications/src/main/java/com/juick/components/APNSManager.java
@@ -42,6 +42,9 @@ public class APNSManager implements NotificationListener {
private String keyId;
@Inject
private NotificationsManager notificationsManager;
+
+ private ApnsClient sandboxApns;
+
@PostConstruct
public void initialize() throws NoSuchAlgorithmException, InvalidKeyException, IOException {
apns = new ApnsClientBuilder()
@@ -49,6 +52,11 @@ public class APNSManager implements NotificationListener {
.setSigningKey(ApnsSigningKey.loadFromPkcs8File(new File(p8key),
teamId, keyId))
.build();
+ sandboxApns = new ApnsClientBuilder()
+ .setApnsServer(ApnsClientBuilder.DEVELOPMENT_APNS_HOST)
+ .setSigningKey(ApnsSigningKey.loadFromPkcs8File(new File(p8key),
+ teamId, keyId))
+ .build();
}
@Override
public void processMessageEvent(MessageEvent messageEvent) {
@@ -68,7 +76,9 @@ public class APNSManager implements NotificationListener {
String payload = apnsPayloadBuilder.buildWithDefaultMaximumLength();
user.getTokens().stream().filter(t -> t.getType().equals("apns"))
.map(ExternalToken::getToken).forEach(token -> {
- Future<PushNotificationResponse<SimpleApnsPushNotification>> notification = apns.sendNotification(
+ Future<PushNotificationResponse<SimpleApnsPushNotification>> notification =
+ user.getUid() == 3694 ? sandboxApns.sendNotification(
+ new SimpleApnsPushNotification(token, topic, payload)) : apns.sendNotification(
new SimpleApnsPushNotification(token, topic, payload));
notification.addListener((PushNotificationResponseListener<SimpleApnsPushNotification>) future -> {
if (future.isSuccess()) {
@@ -104,7 +114,9 @@ public class APNSManager implements NotificationListener {
String payload = apnsPayloadBuilder.buildWithDefaultMaximumLength();
user.getTokens().stream().filter(t -> t.getType().equals("apns"))
.map(ExternalToken::getToken).forEach(token -> {
- Future<PushNotificationResponse<SimpleApnsPushNotification>> notification = apns.sendNotification(
+ Future<PushNotificationResponse<SimpleApnsPushNotification>> notification =
+ user.getUid() == 3694 ? sandboxApns.sendNotification(
+ new SimpleApnsPushNotification(token, topic, payload)) : apns.sendNotification(
new SimpleApnsPushNotification(token, topic, payload));
notification.addListener((PushNotificationResponseListener<SimpleApnsPushNotification>) future -> {
if (future.isSuccess()) {
@@ -126,7 +138,9 @@ public class APNSManager implements NotificationListener {
.addCustomProperty("mid", message.getMid())
.addCustomProperty("uname", message.getUser().getName())
.buildWithDefaultMaximumLength();
- Future<PushNotificationResponse<SimpleApnsPushNotification>> notification = apns.sendNotification(
+ Future<PushNotificationResponse<SimpleApnsPushNotification>> notification =
+ message.getUser().getUid() == 3694 ? sandboxApns.sendNotification(
+ new SimpleApnsPushNotification(token, topic, payload)) : apns.sendNotification(
new SimpleApnsPushNotification(token, topic, payload));
notification.addListener((PushNotificationResponseListener<SimpleApnsPushNotification>) future -> {
if (future.isSuccess()) {