How to dynamically add stickers in the whatsapp-sticker pack [Android][Unity-Android plugin]?

2k Views Asked by At

I have used the repo to make an android plugin for my unity game, wherein I reward the player with some stickers at each level. So basically Im successful in calling the add sticker function from the android plugin and can add the sticker pack according to the desired identifier and name. (Here the contents.json, is already in the aar.)

But since i now need to edit the contents.json (we cant modify .aar files) so i copy the assets file content checkout the content provider code https://pastebin.com/urhXTs7z And now the contents.json is in my Android/data/packagename/files/

From Unity I deserialize and serialize that json and just add items to the sticker pack list. And then overwrite the contents.json if (Application.platform == RuntimePlatform.Android) { System.IO.File.WriteAllText(Application.persistentDataPath + "/contents.json", contents); }

It works for the original contents.json but after updating the stickerpack, the new items are not read by the ReadContentFile function But this doesnt work, the plugin just reads the original contents.json. (Because copy assets is called in OnCreate, I tried using sharepreferences of android to call the copyassets function only once. But then my app crashes.)

I found people with similar questions here : https://github.com/WhatsApp/stickers/issues/340 But im not able to figure out what to do.

I dont know even it is possible to handle stickers addition dynamically when the code is inside a plugin.

Please refer to the code in the pastebin link

Would love any suggestions to alternative methods to do this.

0

There are 0 best solutions below