Makvin
Makvin

Reputation: 3629

Firebase event not display on firebase console

I generated firebase notification without dashboard using below url:




  try {
            RequestQueue requestQueue = Volley.newRequestQueue(con);
            String url = "https://fcm.googleapis.com/fcm/send";
            JSONObject jsonBody = new JSONObject();//
            jsonBody.put("Title", "Android Volley Demo");
            jsonBody.put("Author", "BNK");
            final String requestBody ;
            requestBody="{ \"data\": {\n" +
                    "    \"image\": \"\",\n" +
                    "    \"message\": \"appname\"\n" +
                    "    \"AnotherActivity\": \"True\"\n" +
                    "  },\n" +
                    "  \"to\" :"+"\""+token+"\""+"\n" +
                    "}";
            StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Log.i("VOLLEY", response);
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.e("VOLLEY", error.toString());
                }
            }) {
                @Override
                public String getBodyContentType() {
                    return "application/json; charset=utf-8";
                }

                public Map<String, String> getHeaders() throws AuthFailureError
                {
                    Map<String, String> headers = new HashMap<String, String>();
                    headers.put("Content-Type", "application/json");
                    headers.put("Authorization","key=server_key_here");

                    return headers;
                }

                @Override
                public byte[] getBody() throws AuthFailureError {
                    try {
                        return requestBody == null ? null : requestBody.getBytes("utf-8");
                    } catch (UnsupportedEncodingException uee) {
                        VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s", requestBody, "utf-8");
                        return null;
                    }
                }

                @Override
                protected Response<String> parseNetworkResponse(NetworkResponse response) {
                    String responseString = "";
                    if (response != null) {
                        responseString = String.valueOf(response.statusCode);
                        // can get more details such as response.headers
                    }
                    return Response.success(responseString, HttpHeaderParser.parseCacheHeaders(response));
                }
            };

            requestQueue.add(stringRequest);
        } catch (JSONException e) {
            e.printStackTrace();
        }

i got the notification successfully but cant display notification_open,notification_receive,notification_dismiss,etc events on firebase console in Events menu feature only display app_remove firstopen,etc There is no events about notification like notification_open notification_foreground Is there any code to put on our java file? Please help me

Upvotes: 1

Views: 777

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598797

Only message sent through the Notifications panel in the Firebase console automatically log analytics events. For (either data or notification) messages that you send through the Firebase Cloud Messaging API, no analytics events are automatically logged.

Upvotes: 2

Related Questions