firebase事件不会显示在firebase控制台上

时间:2017-12-01 06:31:35

标签: android firebase push-notification firebase-cloud-messaging firebase-analytics

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();
        }

我成功收到通知但无法在事件菜单功能中显示firebase控制台上的notification_open,notification_receive,notification_dismiss等事件 app_remove firstopen等 没有关于通知的事件 notification_open notification_foreground  是否有任何代码可以放在我们的java文件中?  请帮帮我

1 个答案:

答案 0 :(得分:1)

只有通过Firebase控制台中的“通知”面板发送的消息才会自动记录分析事件。对于您通过Firebase Cloud Messaging API发送的(数据或通知)消息,不会自动记录任何分析事件。