I'm using SignalR
. I can receive Messages and show Notification when the app is open or is in the background. but when closed application I can't receive messages. Does anyone have a solution to this?
I have the following code in MainActivity OnCreate
:
ActivityChat.connection.received(json -> runOnUiThread(new Runnable() {
@RequiresApi(api = Build.VERSION_CODES.O)
public void run() {
JsonObject jsonObject = json.getAsJsonObject();
if (jsonObject != null && jsonObject.has("A")) {
jsonArray = jsonObject.getAsJsonArray("A");
String method = jsonObject.get("M").getAsString();
//PushNotifications(method,jsonArray);
if (method.equals("addNewMessage")) {
if (jsonArray != null && jsonArray.size() != 0) {
if (jsonArray.get(2).getAsString().equals(driverID)) {
if (TransportClass.showCaseView != null && !TransportClass.showCaseView.isShowing()) {
Notificate();
}
}
}
}
}
}
}));
from java signalr don't receive message when app is closed
No comments:
Post a Comment