Subversion Repositories SmartDukaan

Rev

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

Rev 27132 Rev 27172
Line 1832... Line 1832...
1832
				jsonObj.put("vibrate", 1);
1832
				jsonObj.put("vibrate", 1);
1833
				jsonObj.put("pid", pushNotification.getId());
1833
				jsonObj.put("pid", pushNotification.getId());
1834
				jsonObj.put("sound", 1);
1834
				jsonObj.put("sound", 1);
1835
				jsonObj.put("priority", "high");
1835
				jsonObj.put("priority", "high");
1836
				json.put("data", jsonObj);
1836
				json.put("data", jsonObj);
1837
				LOGGER.info("request {}", json);
-
 
1838
				try {
1837
				try {
1839
					CloseableHttpClient client = HttpClients.createDefault();
1838
					CloseableHttpClient client = HttpClients.createDefault();
1840
					HttpPost httpPost = new HttpPost(FCM_URL);
1839
					HttpPost httpPost = new HttpPost(FCM_URL);
1841
 
1840
 
1842
					httpPost.setHeader("Content-Type", "application/json; utf-8");
1841
					httpPost.setHeader("Content-Type", "application/json; utf-8");
1843
					httpPost.setHeader("authorization", "key=" + FCM_API_KEY);
1842
					httpPost.setHeader("authorization", "key=" + FCM_API_KEY);
1844
					StringEntity entity = new StringEntity(json.toString());
1843
					StringEntity entity = new StringEntity(json.toString());
1845
					httpPost.setEntity(entity);
1844
					httpPost.setEntity(entity);
1846
					CloseableHttpResponse response = client.execute(httpPost);
1845
					CloseableHttpResponse response = client.execute(httpPost);
1847
					LOGGER.info("response" + response);
-
 
1848
 
1846
 
1849
					if (response.getStatusLine().getStatusCode() == 200) {
1847
					if (response.getStatusLine().getStatusCode() == 200) {
1850
						pushNotification.setSentTimestamp(LocalDateTime.now());
1848
						pushNotification.setSentTimestamp(LocalDateTime.now());
1851
					} else {
1849
					} else {
1852
						pushNotification.setSentTimestamp(LocalDateTime.of(1970, 1, 1, 00, 00));
1850
						pushNotification.setSentTimestamp(LocalDateTime.of(1970, 1, 1, 00, 00));