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:

  1. 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.

  2. 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 declare imports graphics on your text view to enable this support.

  3. 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.

  4. 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.

  5. 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