Subversion Repositories SmartDukaan

Rev

Rev 34042 | Rev 34044 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34042 Rev 34043
Line 2609... Line 2609...
2609
                data.put("url", result_url);
2609
                data.put("url", result_url);
2610
                data.put("time_to_live", campaign.getExpireTimestamp());
2610
                data.put("time_to_live", campaign.getExpireTimestamp());
2611
                data.put("image", campaign.getImageUrl());
2611
                data.put("image", campaign.getImageUrl());
2612
                data.put("largeIcon", "large_icon");
2612
                data.put("largeIcon", "large_icon");
2613
                data.put("smallIcon", "small_icon");
2613
                data.put("smallIcon", "small_icon");
2614
                data.put("vibrate", 1);
2614
                data.put("vibrate", "1");
2615
                data.put("pid", pushNotification.getId());
2615
                data.put("pid", pushNotification.getId());
2616
                data.put("sound", 1);
2616
                data.put("sound", "1");
2617
                data.put("priority", "high");
2617
                data.put("priority", "high");
2618
                message.put("data", data);
2618
                message.put("data", data);
2619
 
2619
 
2620
                JSONObject payload = new JSONObject();
2620
                JSONObject payload = new JSONObject();
2621
                payload.put("message", message);
2621
                payload.put("message", message);
Line 2629... Line 2629...
2629
 
2629
 
2630
                    StringEntity entity = new StringEntity(payload.toString());
2630
                    StringEntity entity = new StringEntity(payload.toString());
2631
                    httpPost.setEntity(entity);
2631
                    httpPost.setEntity(entity);
2632
                    CloseableHttpResponse response = client.execute(httpPost);
2632
                    CloseableHttpResponse response = client.execute(httpPost);
2633
                    LOGGER.info("google FCM status code: {}",response.getStatusLine().getStatusCode());
2633
                    LOGGER.info("google FCM status code: {}",response.getStatusLine().getStatusCode());
-
 
2634
                    String responseBody = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))
-
 
2635
                            .lines().collect(Collectors.joining("\n"));
2634
                    if (response.getStatusLine().getStatusCode() == 200) {
2636
                    if (response.getStatusLine().getStatusCode() == 200) {
2635
                        pushNotification.setSentTimestamp(LocalDateTime.now());
2637
                        pushNotification.setSentTimestamp(LocalDateTime.now());
2636
                    } else {
2638
                    } else {
2637
                        pushNotification.setSentTimestamp(LocalDateTime.of(1970, 1, 1, 00, 00));
2639
                        pushNotification.setSentTimestamp(LocalDateTime.of(1970, 1, 1, 00, 00));
2638
                        LOGGER.info("message" + "not sent");
2640
                        LOGGER.info("FCM Response message" + responseBody);
2639
                        response.toString();
2641
                        response.toString();
2640
                    }
2642
                    }
2641
 
2643
 
2642
                } catch (Exception e) {
2644
                } catch (Exception e) {
2643
                    e.printStackTrace();
2645
                    e.printStackTrace();