how can I incorporate Genmoji into my app?
Asked on 07/30/2024
1 search
To incorporate Genmoji into your app, you can follow these steps:
-
Ensure Rich Text Support: If your app already supports rich text, you are in a good position to start. Genmoji support is enabled by default in rich text views. This is because all system serialization frameworks, such as secure coding and pasteboard, have been updated to natively support
NSAdaptiveImageGlyph
. -
Enable Adaptive Image Glyphs: On iOS, if your
UITextView
already has a paste configuration or a target action for paste that supports images, Genmoji and adaptive image glyphs are supported by default. On macOS, you can declareimports graphics
on your text view to enable this support. -
Serialize and Store Content: 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.
-
Use NSAdaptiveImageGlyph: This API supports using Genmoji and other personalized images. It allows you to format, copy, paste, and send Genmoji as stickers. You can use Genmoji anywhere that supports rich text.
-
Notification Support: If your app uses communication notifications, you can include Genmoji in your notifications using the
UNNotificationAttributedMessageContext
API for push notifications. The payload should contain a rich text representation that may include image glyphs.
For a detailed walkthrough, you can refer to the session Bring expression to your app with Genmoji starting at the "Adopting in your app" chapter.
Relevant Sessions

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.