是否可以为iMessage应用程序扩展创建自定义MSMessageLayout?如果是这样,有人可以给我一个例子

时间:2021-04-09 02:21:35

Among the examples I have seen so far for iMessage-App extensions, I learned that the only way to send GIF is through creating a MSSticker and attaching a gif to it for sending. But, after observing some apps. I saw that GIPHY sends GIF through MSMessageTemplateLayout or MSMessageLayout. I know this because of how MSSticker and MSMessageLayout looks on the screen. You can see that in the images below:

在我到目前为止看到的iMessage-App扩展示例中,我了解到发送GIF的唯一方法是创建一个MSSticker并将gif附加到它以进行发送。但是,在观察了一些应用程序之后。我看到GIPHY通过MSMessageTemplateLayout或MSMessageLayout发送GIF。我知道这是因为MSSticker和MSMessageLayout在屏幕上看起来如何。您可以在下面的图片中看到:

是否可以为iMessage应用程序扩展创建自定义MSMessageLayout?如果是这样,有人可以给我一个例子

This above image is gif inserted through MSSticker.

上面的图片是通过MSSticker插入的gif。

是否可以为iMessage应用程序扩展创建自定义MSMessageLayout?如果是这样,有人可以给我一个例子

This above image is gif inserted through MSMessageLayout.

上面的图片是通过MSMessageLayout插入的gif。

The problem here is MSMessageLayout doesn't have any method to override. There is no way that I know by which we can insert gif into MSMessageTemplateLayout and make it play. I tried it. The only way I know is to create a custom MSMessageLayout which I don't find any examples for.

这里的问题是MSMessageLayout没有任何方法可以覆盖。我无法通过哪种方式将gif插入MSMessageTemplateLayout并使其播放。我尝试过这个。我知道的唯一方法是创建一个我没有找到任何示例的自定义MSMessageLayout。

The major reason for me trying this method is:

我尝试这种方法的主要原因是:

  • There is 500 kb limit for size of GIF we can send through MSSticker
  • 我们可以通过MSSticker发送的GIF大小限制为500 kb
  • Through GIPHY, we can send a GIF with size greater than 500 kb. I checked it myself
  • 通过GIPHY,我们可以发送一个大小超过500 kb的GIF。我亲自检查过

So, two humble requests to the community:

所以,对社区的两个不起眼的要求:

  • If anyone already tried sending GIF through MSMessageLayout, please answer how you did it
  • 如果有人已经尝试通过MSMessageLayout发送GIF,请回答你是如何做到的
  • If anyone succeded in sending GIF of size > 500 kb through MSSticker, please answer how you did it
  • 如果有人通过MSSticker成功发送大小> 500 kb的GIF,请回答你是怎么做的

1 个解决方案

#1


2  

Usually when you send a MSMessage inside a MSMessageTemplateLayout, the app icon is shown on the top-left corner (in your screenshot, it doesn't appear) so this makes me think that they probably use insertAttachment(_:). In this way the media is handled automatically by iMessage as it has been sent via sharing from any other apps.

通常当您在MSMessageTemplateLayout中发送MSMessage时,应用程序图标显示在左上角(在屏幕截图中,它不会出现)所以这让我觉得他们可能使用insertAttachment(_ :)。通过这种方式,媒体由iMessage自动处理,因为它是通过任何其他应用程序的共享发送的。

#1


2  

Usually when you send a MSMessage inside a MSMessageTemplateLayout, the app icon is shown on the top-left corner (in your screenshot, it doesn't appear) so this makes me think that they probably use insertAttachment(_:). In this way the media is handled automatically by iMessage as it has been sent via sharing from any other apps.

通常当您在MSMessageTemplateLayout中发送MSMessage时,应用程序图标显示在左上角(在屏幕截图中,它不会出现)所以这让我觉得他们可能使用insertAttachment(_ :)。通过这种方式,媒体由iMessage自动处理,因为它是通过任何其他应用程序的共享发送的。