如何让我的Imessage贴纸可用于whatsapp

时间:2017-04-14 19:13:54

标签: ios whatsapp imessage

我想知道是否可以在whatsapp中分享Imessage贴纸。如果有可能我怎么能为此编写应用程序代码?

2 个答案:

答案 0 :(得分:1)

为此,您需要使用贴纸构建单独的键盘扩展,以便在WhatsApp中它们将作为图像或GIF发送。

答案 1 :(得分:1)

从GitHub下载示例项目和所需文件: https://github.com/WhatsApp/stickers/tree/master/iOS

然后使用以下代码创建贴纸包:

let stickerPack = StickerPack(identifier: "identifier",
name: "sticker pack name", 
publisher: "sticker pack publisher", 
trayImageFileName: "tray image file name", 
publisherWebsite: "publisher website URL", 
privacyPolicyWebsite: "privacy policy website URL", 
licenseAgreementWebsite: "license agreement website URL")

将贴纸添加到贴纸包:

stickerPack.addSticker(contentsOfFile: "file name of sticker image", 
emojis: ["array of emojis"])

调用以下方法将贴纸包导入Whatsapp:

stickerPack.sendToWhatsApp { completed in
// Called when the sticker pack has been wrapped in a form that WhatsApp 
// can read and WhatsApp is about to open.
}

您必须在LSApplicationQueriesSchemes文件中添加Info.plist

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>whatsapp</string>
</array>

此外,您必须使用一些限制和预定义的语法, 阅读有关创建whatsapp贴纸的更多信息:

https://faq.whatsapp.com/general/26000226