Jobeso / react-native-whatsapp-stickers

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

react-native-whatsapp-stickers getting success but not exported to whatsapp or not working properly #81

Open anirban-baisya opened 2 years ago

anirban-baisya commented 2 years ago

1st go to :- node_modules > react-native-whatsapp-stickers > android > src> main > java > com > jobeso > RNWhatsAppStickers >RNWhatsAppStickersModule.java

2nd :- comment out below lines from @ReactMethod public void send(String identifier, String stickerPackName, Promise promise) { ... } section

try {
  Activity activity = getCurrentActivity();
  // ResolveInfo should = activity.getPackageManager().resolveActivity(intent, 0);
  // if (should != null) {
    activity.startActivityForResult(wintent, ADD_PACK);
    promise.resolve("OK");
  // } else {
  //   promise.resolve("OK, but not opened");
  // }
} catch (ActivityNotFoundException e) {
  promise.reject(ERROR_ADDING_STICKER_PACK, e);
} catch  (Exception e){
  promise.reject(ERROR_ADDING_STICKER_PACK, e);
}
ReactNativeFan commented 1 year ago

@anirban-baisya I am having the same problem with react-native 0.69. I am not getting any information in debug mode. did you find a solution or at least what was the problem? Thanks.

ReactNativeFan commented 1 year ago

After debugging RNWhatsAppStickersModule.java, i found that the following activity was failing:

ResolveInfo should = activity.getPackageManager().resolveActivity(intent, 0);

The problem happens if you are targeting android 11 (API 30 or higher) which is the default settings for ReactNative 0.69.

Android 11 introduces new changes related to package visibility, which will require adding some intent in "android/app/src/main/AndroidManifest.xml"

I solved the problem by adding the following intent before the "<application" markup

 <queries>
    <intent>
        <action android:name="android.intent.action.MAIN" />
    </intent>
</queries>

Rememebr "" is new markup and requires a recent version of gradle or you will get "Failed Linking" error.

I am using the following gradle recent versions:

gradle plugin: 7.2.1 add to "android/build.gradle" classpath("com.android.tools.build:gradle:7.2.1")

gradle: 7.3.3 add to "android/gradle/wrapper/gradle-wrapper.properties" distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip

@Jobeso, you may want to update the install section for Android to have the new intent i mentioned earlier.