Jobeso / react-native-whatsapp-stickers

Integrate sticker packs for WhatsApp with your react-native app
Other
81 stars 30 forks source link

Feature Requests #11

Open ReactNativeFan opened 5 years ago

ReactNativeFan commented 5 years ago

Discussion

All the things in life you ever wanted to discuss.

  1. Can you please expose the following swift function in your react-native so one can send sticker as data rather than a filename in the bundle. This is very useful.!

func addSticker(imageData: Data, type: ImageDataExtension, emojis: [String]?)

  1. does your current implementation set the following store links: ios_app_store_link & android_play_store_link.
Jobeso commented 5 years ago
  1. Can you please expose the following swift function in your react-native so one can send sticker as data rather than a filename in the bundle. This is very useful.!

Yeah, exposing the inner functions is possible but not neccessary for most cases. There also has to be a conversion step from js param to native param depending on what kind of data you want to insert. So it would be useful to get a bit more infos about your use case to discuss a solution how to move further. I'm open in expanding the functionality.

  1. does your current implementation set the following store links: ios_app_store_link & android_play_store_link.

The current implementation doesn't set this on iOS. This is a native implementation of WhatsApp. As far as I could see it's not supported by them for iOS right now. Please let me know if you have other knowledge about that.

ReactNativeFan commented 5 years ago
  1. Can you please expose the following swift function in your react-native so one can send sticker as data rather than a filename in the bundle. This is very useful.!

Yeah, exposing the inner functions is possible but not neccessary for most cases. There also has to be a conversion step from js param to native param depending on what kind of data you want to insert. So it would be useful to get a bit more infos about your use case to discuss a solution how to move further. I'm open in expanding the functionality.

Thank you for your willing to proceed further. Creating a pack from a static json limits the lib capability this is why the native swift files added overloaded addSticker that accepts image data rather than filename, which means a sticker pack can be created on the fly. This mean, your sticker could be read from phone gallery "temp url" or internet (remote url), or from base64. Therefore, a conversion is needed to convert what i mentioned to native ImageData.

  1. does your current implementation set the following store links: ios_app_store_link & android_play_store_link.

The current implementation doesn't set this on iOS. This is a native implementation of WhatsApp. As far as I could see it's not supported by them for iOS right now. Please let me know if you have other knowledge about that.

When i was using the template, if you click on a received sticker, a dropdown menu shows "View Sticker Set", if you have the sticker pack installed, the app opens the tab containing them. Otherwise, it takes you to the store to download the app given that the app ios link is provided. This feature is now broken i.e., "View Sticker Set" is not shown. Maybe because your stickerConfig.js does not ask for the ios_link. I think if i hard coded the link in the native files, it should work although with the first update of your lib, i will lose the change.

Jobeso commented 5 years ago
  1. I agree, support for local images and base64 etc. is a good thing for the roadmap.

  2. I need to dig deeper into it. I think that this is something only supported on Android and this should work with the current implementation. For iOS there are strings but I think there are no setters yet which let to my assumption that this is not supported by iOS. Like I said, I'll take another look at it.

If you want to add features to the library you are also always welcome to submit a pr for that.

ReactNativeFan commented 5 years ago
  1. I agree, support for local images and base64 etc. is a good thing for the roadmap.

I really appreciate if you can add this cool feature soon.

  1. I need to dig deeper into it. I think that this is something only supported on Android and this should work with the current implementation. For iOS there are strings but I think there are no setters yet which let to my assumption that this is not supported by iOS. Like I said, I'll take another look at it.

In the original template:

StickerPackManager.swift
    func fetchStickerPacks
        the store links are set here:
            let iosAppStoreLink: String? = dict["ios_app_store_link"] as? String
            let androidAppStoreLink: String? = dict["android_play_store_link"] as? String

the function fetchStickerPacks is called inside AllStickerPacksViewController.swift try StickerPackManager.fetchStickerPacks

Unfortunately, fetchStickerPacks() is not called by your library since it does not perform sanity check on the validity of the pack as in AllStickerPacksViewController.swift Therefore, ios_app_store_link is not set

To solve the problem, i think you need to pass the iosAppStoreLink in both constructors of the StickerPack.swift then copy it inside sendToWhatsApp() json["ios_app_store_link"] = self.iosAppStoreLink

I did not look how it is handled in Android but i think there should be a similar fix to set "android_play_store_link"

If you want to add features to the library you are also always welcome to submit a pr for that.