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:
-
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.
-
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.
-
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.
-
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.
Bring expression to your app with Genmoji
Discover how to bring Genmoji to life in your app. We’ll go over how to render, store, and communicate text that includes Genmoji. If your app features a custom text engine, we’ll also cover techniques for adding support for Genmoji.
What’s new in AppKit
Discover the latest advances in Mac app development. Get an overview of the new features in macOS Sequoia, and how to adopt them in your app. Explore new ways to integrate your existing code with SwiftUI. Learn about the improvements made to numerous AppKit controls, like toolbars, menus, text input, and more.
Platforms State of the Union
Discover the newest advancements on Apple platforms.