I'm trying to make a very simple stickers iMessage application with user being proposed to in-app purchase when they click on some of the stickers.
I have a custom view controller that implements UIViewController
, UICollectionViewDelegate
, UICollectionViewDataSource
(source: https://github.com/jelenakrmar/customStickerApp).
I am now trying to override the default behaviour when the user taps or peels the sticker.
My first attempt was at the level of the collectionView
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// open the in-app purchase window
}
but it doesn't work
Maybe I would need to extend MSStickerView
and do something in 'didTap
' and 'didLongPress
'.
Does anyone have some experience with overriding the behaviour of iMessage when selecting a sticker?
It seems like, if your
UICollectionViewCell
has aMSStickerView
(or possibly importsMessages
framework), thedidSelectItemAt
delegate doesn't get called.For example, if I wanted to have a Sticker Extension with free and locked stickers, I would create two different cells in my
UICollectionView
. One has aMSStickerView
and the second one only has anUIImageView
. If a free sticker is tapped, iOS handles everything with theUICollectionView
delegate not being fired. However, if a user taps a locked sticker, the delegate will fire, and can be handled by thedidSelectItemAt
delegate.I haven't found any documentation that points to this yet.