iMessage Apps - Programatically create animated sticker from .apng
Asked Answered
N

1

8

Hi has anyone tried yet to programatically create a custom sticker programmatically with an animated apng file?

I've had no success but can state the following:

  1. .apng file of correct dimensions and file size (300px * 300px) and < 500kb.

  2. Can add this as a .png and it shows the first frame (not animated)

  3. Changing file name to .apng causes an error to be raised upon inserting sticker to MS Message.

  4. Have taken the approach of loading the apng into the project folder (not in Assets.xcassets) as the initialize sticker requires an NSURL which is not made availabe if apng is created as an iOS sticker.

  5. Managed to user the same sequence in .GIF. this inserted correctly as a sticker.

Code below:

MSConversation *currentConversation = [self activeConversation];

NSURL *urlForSticker2 = [[NSBundle mainBundle] URLForResource:@"elephant_apng" withExtension:@"apng"];
MSSticker *challengeSticker2 = [[MSSticker alloc] initWithContentsOfFileURL:urlForSticker2 localizedDescription:@"My Sticker Localised" error:&myError];

[currentConversation insertSticker:challengeSticker2 completionHandler:^(NSError * error) 
{

//HERE we get: error    NSError *   domain: @"com.apple.messages.stickers-error" - code: 8  0x0000600000058240


 }];

So yes - keen to be able to overcome the error shown above.

Nealneala answered 22/6, 2016 at 1:38 Comment(1)
I'm having the same problem you could solve? Do you know how create a .apng from png files (in code)?Goulden
S
0

Maybe you forget click here when you add the resource?

add resource

and your apng file's extension should be just "png" when you insert a MSSticker object.

Sweatband answered 13/9, 2016 at 7:44 Comment(1)
it maybe a iOS bug.Sweatband

© 2022 - 2024 — McMap. All rights reserved.