How do genmoji work

Generated on 8/2/2024

1 search

Genmoji are a new way to create personalized emoji-like images that can be used across various Apple platforms. Unlike traditional emoji, which are standardized Unicode characters, Genmoji are unique rasterized bitmaps that can't be described by a Unicode text character. Here’s how they work:

  1. Creation and Usage:

    • Genmoji can be created using the new emoji keyboard, which combines standard emoji with personalized content like stickers, Memoji, Animoji, and Genmoji.
    • They are handled using NSAdaptiveImageGlyph, a new API that supports using Genmoji and other personalized images. This API allows Genmoji to be formatted, copied, pasted, and sent as stickers, and they can be used anywhere that supports rich text.
  2. Technical Implementation:

    • Genmoji are represented as attributed strings, a data type used for rich text with graphics.
    • If your app already supports rich text views, enabling Genmoji can be as simple as setting a property to support adaptive image glyphs.
    • On iOS, if your text view supports images, Genmoji support is enabled by default. On macOS, you can enable it by declaring imports graphics on your text view.
  3. Serialization and Storage:

    • Genmoji support is integrated into system serialization frameworks like secure coding and pasteboard.
    • To store Genmoji, serialize the content of the text view into an RTFD data object and store it in your database. When displaying the content again, reverse the process to create an attributed string from the stored data.
  4. Compatibility:

    • Genmoji are not Unicode characters, so they may not be suitable for text-only items like email addresses and phone numbers.
    • They can be included in notifications using the new UNNotificationAttributedMessageContext API for push notifications.

For more detailed information, you can watch the session Bring expression to your app with Genmoji starting at 00:01:10.