Skip to content

Commit

Permalink
Trying to get hybrid iOS/Android notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Litarvan committed Dec 2, 2018
1 parent cbeb7b1 commit d3bf395
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/main/java/fr/litarvan/sakado/server/SakadoServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import java.io.IOException;
import java.net.InetSocketAddress;

// TODO: Menu de la cantine + sauvegarde connexion

public class SakadoServer implements App
{
public static final String VERSION = "1.4.1-BETA";
Expand Down
25 changes: 20 additions & 5 deletions src/main/java/fr/litarvan/sakado/server/push/PushService.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void send(User user, String type, String title, String message, String co
conn.setRequestMethod("POST");
conn.setDoOutput(true);

JsonObject data = new JsonObject();
/*JsonObject data = new JsonObject();
data.addProperty("title", "Sakado - " + title);
data.addProperty("message", message);
data.addProperty("priority", "high");
Expand All @@ -103,15 +103,30 @@ public void send(User user, String type, String title, String message, String co
if (type != null)
{
data.addProperty("type", type);
}
}*/

JsonObject notification = new JsonObject();
notification.addProperty("body", title);
notification.addProperty("title", message);
notification.addProperty("title", "Sakado - " + title);
notification.addProperty("body", message);

if (color != null)
{
notification.addProperty("color", color);
}

if (icon != null)
{
notification.addProperty("icon", icon);
}

if (type != null)
{
notification.addProperty("type", type);
}

JsonObject request = new JsonObject();
request.addProperty("to", user.getDeviceToken());
request.add("data", data);
//request.add("data", data);
request.add("notification", notification);

String requestContent = gson.toJson(request);
Expand Down

0 comments on commit d3bf395

Please sign in to comment.