我之前见过这个话题,
但我认为情况并非如此.
我正在尝试通过FCM(Firebase云消息传递)向所有其他设备发送来自一台设备(将成为管理设备)的推送通知,而我正准备通过他们的文档.
我试图订阅主题或保持简单仍然得到相同的错误,“MissingRegistration”.
String JsonData = "{\"to\":\"/topics/news\",\"notification\":{\"Title\":\"Title\",\"body\":\"text\" }}"; byte[] postData = JsonData.getBytes(Charset.forname("UTF-8")); int postDataLength = postData.length; URL url = new URL("https://fcm.GoogleAPIs.com/fcm/send"); httpURLConnection con = (httpURLConnection) url.openConnection(); con.setDoinput(true); con.setDoOutput(true); con.setInstanceFollowRedirects(true); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type","application/Json"); con.setRequestProperty("Authorization","key=AIzaSyB70J***-z34q2_h*******qjZsM5zBIf8Y"); //I've added stars :-) con.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); con.setRequestProperty("Content-Type","charset=UTF-8"); con.setRequestProperty("Content-Length",Integer.toString(postDataLength)); con.setUseCaches(false); DataOutputStream wr = new DataOutputStream(con.getoutputStream()); wr.write(postData); inputStream inputStream= con.getinputStream(); BufferedReader reader = new BufferedReader(new inputStreamReader(inputStream)); String line = null; String outPut = ""; while (((line = reader.readline()) != null)){ outPut += line; }
解决方法:
我也有同样的错误,但我的是在服务器端(从rails推送到androID),但我的问题是我忘了在标题中指定内容类型(我使用RestClIEnt发布到firebase).希望它可以帮助某人
RestClIEnt.post( "https://fcm.GoogleAPIs.com/fcm/send", {:to => reg_ID,:notification => options }.to_Json,{:content_type => :Json, :accept => :Json,:Authorization => "key=*****"}
总结 以上是内存溢出为你收集整理的Firebase FCM推送,错误注册失败| Android的全部内容,希望文章能够帮你解决Firebase FCM推送,错误注册失败| Android的所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)