1 /*******************************************************************************
2 * Copyright © Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
4 * This file is part of the work and learning management system Pentila Nero.
6 * Pentila Nero is free software. You can redistribute it and/or modify since
7 * you respect the terms of either (at least one of the both license) :
8 * - under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
11 * - the CeCILL-C as published by CeCILL-C; either version 1 of the
12 * License, or any later version
13 * - the GNU Lesser General Public License as published by the
14 * Free Software Foundation, either version 3 of the license,
15 * or (at your option) any later version.
17 * There are special exceptions to the terms and conditions of the
18 * licenses as they are applied to this software. View the full text of
19 * the exception in file LICENSE-PROJECT.txt in the directory of this software
22 * Pentila Nero is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * Licenses for more details.
27 * You should have received a copy of the GNU Affero General Public License
28 * and the CeCILL-C and the GNU Lesser General Public License along with
29 * Pentila Nero. If not, see :
30 * <http://www.gnu.org/licenses/> and
31 * <http://www.cecill.info/licences.fr.html>.
32 ******************************************************************************/
33 package com.pentila.entSavoie.mobileNotification.androidUtils;
35 import java.io.IOException;
36 import java.util.Iterator;
38 import java.util.concurrent.ConcurrentHashMap;
40 import javax.servlet.RequestDispatcher;
41 import javax.servlet.Servlet;
42 import javax.servlet.ServletContext;
43 import javax.servlet.ServletException;
44 import javax.servlet.http.HttpServlet;
45 import javax.servlet.http.HttpServletRequest;
46 import javax.servlet.http.HttpServletResponse;
49 public class AndroidPushService{
55 public void sendNotification(String alertText, String deviceToken) {
58 AndroidPushManager androidManager = new AndroidPushManagerImpl();
59 AndroidMessage androidMessage = new AndroidMessage(deviceToken,alertText);
60 androidManager.sendNotifictaion(androidMessage);
62 } catch (Exception e) {
70 String deviceToken1 = "APA91bGyLlmlltHV9tNrK5MSvgJlgHaAcpoqbAJUuYw49KAP2exp3OAwMwnega3zwXOhPzm1wBCaCGMG5GD9r1OwQW3J-Jov-TT1F51kQxjzQAyjenb6-jS10QGLZY0Yv6XQbngkbr8T42-3Ss9Y6CXAUM6PlyEYIQ";
71 String deviceToken2 ="APA91bFmcwSCCOAGrrkkO42yTMGuEjMQWTkcID_2aZNMUsL1egb5dUxWPmeDxVtwY_NKq7rKJrQEJLqLu-CXeeqLyngOflhSt26wU5b_dF1mrbOumdkoM9XZjsG8kWlOXrHo86RGp3eBTYxZt24VoPtlOATrtj7yJA";
72 String alertText = "Testing push notification and phonegap";
74 sendNotification(alertText, deviceToken1);
75 sendNotification(alertText, deviceToken2);