1

由于未知原因,我无法在开发环境中运行推送通知。它没有显示,因此我无法在我的 iOS 设备上运行我的应用程序来检查某些字段。在生产中,推送通知工作正常。

我现在遇到的问题是我想使用通知有效负载中的“userId”导航到某个页面。我不知道该有效载荷的结构。任何人都可以指出 Applozic 服务器发送的有效载荷的结构吗?

let dictionary = launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] as? [String: Any] 

这本词典是用什么做的?

非常感谢您的帮助。

4

1 回答 1

3
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,是一对一聊天中发送消息的

于 2019-02-07T13:07:09.437 回答