Firebase云消息传递缺少注册

时间:2017-05-12 06:09:02

标签: android firebase android-volley firebase-cloud-messaging

嘿,我刚刚将FCM添加到我的新网站。现在我想从我的Android应用程序发送通知。当我和邮递员一起做这件事时一切正常。这是我的参数:

                @Override
                protected Map<String,String> getParams(){
                    Map<String,String> params = new HashMap<String, String>();
                    Foo foo = new Foo();
                    Notification notification = new Notification();
                    foo.to="[key]";
                    notification.title="foo";
                    notification.body="abc";
                    foo.notification=notification;
                    Gson gson = new Gson();
                    String gg = gson.toJson(foo);
                    params.put("foo",gg);
                    Log.d("PAARAMS",gg);
                    return params;
                }

所以我的参数看起来像这样:

  

{&#34;通知&#34; {&#34;主体&#34;:&#34; ABC&#34;&#34;标题&#34;:&#34;富&#34;} &#34;至&#34;:&#34;键&#34;}

我还添加了这样的自定义标题:

               @Override
                public Map<String, String> getHeaders() throws AuthFailureError {
                    Map<String,String> params = new HashMap<String, String>();
                    params.put("Authorization", "key=[key]");
                    return params;
                }

但我得到的所有响应都是 MissingRegistration

当我添加

  

params.put(&#34; Content-Type&#34;,&#34; application / json&#34;);

我得到 BasicNetwork.performRequest:https://fcm.googleapis.com/fcm/send的意外回复代码400

这是我的请求响应,我收到错误:

StringRequest postRequest = new StringRequest(Request.Method.POST, "https://fcm.googleapis.com/fcm/send",
                    new Response.Listener<String>()
                    {
                        @Override
                        public void onResponse(String response) {
                            // response
                            Log.d("Response", response);
                        }
                    },

整个项目位于github

0 个答案:

没有答案