对于通过XMMP支持上游和下游消息的服务器端实现,我使用org.jivesoftware.smack.tcp.XMPPTCPConnection。我从GCM迁移到FCM,现在我的应用服务器不再接收任何上游消息。我是否必须更改主机,端口或其他内容才能使用FCM?
从Android客户端发送消息,如:
String senderId = ctxt.getResources().getString(com.app.teamchannel.R.string.sender_id);
Map<String,String> data = new HashMap<String,String>();
data.put(GcmConstants.ACTION, GcmConstants.ACTION_CHAT);
data.put(Constants.CHAT_FLAG, Constants.FLAG_NEW_CHAT);
ObjectMapper mapper = new ObjectMapper();
String chatJsonInString = mapper.writeValueAsString(Helper.chatToJson(chat));
data.put(Constants.CHAT_JSON, chatJsonInString);
String receiverJsonInString = mapper.writeValueAsString(Helper.userToJson(receiver));
data.put(Constants.RECEIVER_JSON, receiverJsonInString);
String id = Integer.toString(getNextMsgId(ctxt));
FirebaseMessaging fm = FirebaseMessaging.getInstance();
fm.send(new RemoteMessage.Builder(senderId + "@gcm.googleapis.com").setMessageId(id).setData(data).build());
Log.v(Constants.TAG, "verification message successfully sent: " + GcmConstants.ACTION_CHAT + " -> " + Constants.FLAG_NEW_CHAT);
答案 0 :(得分:0)
解决了这个问题。我将google-services.json放在错误的文件夹中。现在,谷歌云服务器和我的应用服务器端点之间的通信正常工作。