For group chat, the dictionary looks like this:
{
"AL_KEY" = "**msgtype**";
"AL_VALUE" = "{\"id\":\"**appIDhere**\",\"type\":\"**msgtype**\",\"message\":\"**AL_GROUP:groupid:userid**\",\"notifyUser\":true,\"totalUnreadCount\":0,\"sendAlert\":false,\"messageMetaData\":{}}";
aps = {
alert = "**groupname\nuserid: messagecontent**";
badge = 127;
"content-available" = 1;
sound = default;
};
}
For One - to - One chat,
{
"AL_KEY" = "**msgtype**";
"AL_VALUE" = "{\"id\":\"**appIDhere**\",\"type\":\"**msgtype**\",\"message\":\"**userid**\",\"notifyUser\":true,\"totalUnreadCount\":128,\"sendAlert\":true,\"messageMetaData\":{}}";
aps = {
alert = "**userid**: **messagecontent**";
badge = 128;
"content-available" = 1;
sound = default;
};
}
星号中的名称将被其适当的值替换。希望这对你有用。
编辑:
在这里,您可以使用APPLOZIC_01检查接收到的消息的AL_KEY,然后在AL_VALUE 中您可以获得消息。
消息作为两种类型的一对一或群聊消息是
1)对于群聊,您可以检查第一部分字符串是否可以使用以下方法拆分:如果它有AL_GROUP 那么它的组消息,第二部分是 groupId,第三部分是在该组中发送消息的 userId
2)一对一,消息中只有一个部分是userId,是一对一聊天中发送消息的