I'm trying to export an UIImage as a sticker for Messages app, but I can't find any documentation about this.
I have my project with the Sticker Pack extension enabled and see that Xcode created a new Stickers.xcassets, every image that I add there manually appears on Messages app to use as a sticker, but how can I save an image programatically there, so the user can create stickers from any image ?
All I can find is information related to creating stickers without doing any code, just shipping an app with predefined images.
let sticker = try MSSticker(contentsOfFileURL: url, localizedDescription: "Test")
I know how create a MSSticker from the image file, but after this I don't know how to proceed and make this newly created sticker appear on Messages app.
Stickers are loaded from stickers assets catalog
.xcstickers
. This catalog is a resource file/folder, that means this is placed inside your bundle. All files inside your bundle are not writable and they have only read permissions. IMO what you need to do is:You have to store your users custom images in any one of the sandboxed folders (Documents, Library and temp).
Read image from this folder and create
MSSticker
from it same way as you did. -let sticker = try MSSticker(contentsOfFileURL: url, localizedDescription: "Test")
and add. this sticker to array.MSStickerBrowserViewController
you will load stickers from array created in previous step.Like this