WhatsApp sticker whitelist returns false for both true and false when received result in React Native

108 Views Asked by At

I am using a code snippet from whatsapp to if sticker is whitelisted or not. It always returns false while in logs it shows proper result.

                if (cursor != null && cursor.moveToFirst()) {
                    final int whiteListResult = cursor.getInt(cursor.getColumnIndexOrThrow(QUERY_RESULT_COLUMN_NAME));
                    Log.d("ReactNative","whiteListResult for "+identifier+" is "+whiteListResult);
                    return whiteListResult == 1;
                }

// getting the value and sending to React Native caller
...
boolean flag = isWhiteListed(...);
// here also logging flag shows correct result
promise.resolve(flag) 
...
```js
...
isAdded.then(result => log(result)) 
// result is always false . tried whitelisted and non whitelisted stickers.
1

There are 1 best solutions below

0
CrackerKSR On

Ok the problem is passing the boolean values to React Native. Do not know how it true becomes false but solution is convert the boolean into string and then pass it to promise.resolve().

boolean flag = ...
promise.resolve(String.valueOf(flag))

Or you can use WritableArray or WrittableHash. These objects has methods for pushing boolean values like pushBoolean()/ putBoolean()