1. Practical path (what you need to do)
1.1. Prepare the assets and the sticker_packs.wasticker file
This part is identical to the official iOS sample:
- Follow the official image rules (512×512, <100 KB, 3–30 stickers, 96×96 tray icon).
- Create the sticker_packs.wasticker file (a JSON-based metadata file) containing:
- identifier (the pack ID),
- name,
- publisher,
- tray_image_file,
- list of image_file items.
You can even use Android-side JSON/pack generators as long as you adjust the fields to match the iOS structure.
1.2. Integrate the WhatsApp sample project into the Xcode project generated by B4i
Typical workflow:
- In B4i, generate a Release build and download the app’s Xcode project.
- Open the generated Xcode project.
- Inside Xcode, add the folders/classes from the WAStickersThirdParty iOS sample (or at least the core files such as Sticker.swift, StickerPack.swift, StickerPackManager, etc.).
- Copy the following into your app bundle:
- all sticker images,
- the sticker_packs.wasticker file.
- In your Info.plist, add:
'<key>LSApplicationQueriesSchemes</key>
'<array>
'<string>whatsapp</string>
'</array>
#QueriesSchemes: whatsapp
This allows the app to open the whatsapp:// URL scheme on iOS.
1.3. Create an Objective-C wrapper usable from B4i
In B4i, you can embed
inline Objective-C code using #If OBJC.
Your goal is to expose a simple method that invokes the same logic used by the “Add to WhatsApp” button in the official iOS sample.
Example:
B4i side:
Sub AddStickerPackToWhatsApp (Identifier As String, Name As String)
Dim no As NativeObject = Me
no.RunMethod("addStickerPackToWhatsApp::", Array(Identifier, Name))
End Sub
Sub btnAdd_Click
Dim packId As String = "my_pack_01"
Dim packName As String = "Cuppy Stickers"
AddStickerPackToWhatsApp(packId, packName)
End Sub
Objective-C wrapper inside the same B4i module:
#If OBJC
#import "StickerPackManager.h" // or the equivalent header from WAStickersThirdParty
- (void)addStickerPackToWhatsApp:(NSString *)identifier :(NSString *)name {
// You will copy/adapt this code from the official iOS sample.
// Example logic:
//
// StickerPack *pack = [StickerPackManager stickerPackWithIdentifier:identifier];
// if (pack) {
// [StickerPackManager addStickerPackToWhatsApp:pack
// completionHandler:^(BOOL success, NSError *error) {
// // Optional: handle callback
// }];
// }
}
#End If
The main implementation inside addStickerPackToWhatsApp must be copied from the original Sample Project, since that’s the code that builds and validates the sticker pack and triggers WhatsApp import.