Skip to content

Commit

Permalink
fix(android): handle setDataProcessingOptions params correctly to avo…
Browse files Browse the repository at this point in the history
…id crash (thebergamo#256)
  • Loading branch information
oscb authored May 18, 2022
1 parent 847feea commit 1426cf8
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
import com.facebook.FacebookSdk;
import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.module.annotations.ReactModule;
import java.util.ArrayList;
import java.util.List;

/**
* This is a {@link NativeModule} that allows JS to use SDK settings in Facebook Android SDK.
Expand All @@ -30,24 +33,17 @@ public String getName() {
return NAME;
}

/**
* Sets data processing options
* @param options list of the options
*/
@ReactMethod
public void setDataProcessingOptions(@Nullable String[] options) {
FacebookSdk.setDataProcessingOptions(options, 0, 0);
}

/**
* Sets data processing options with country and state
* @param options list of the options
* @param country code of the country
* @param state code of the state
*/
@ReactMethod
public static void setDataProcessingOptionsExtra(@Nullable String[] options, int country, int state) {
FacebookSdk.setDataProcessingOptions(options, country, state);
public void setDataProcessingOptions(ReadableArray options, int country, int state) {
List<String> opts = Utility.reactArrayToStringList(options);
String[] optsArray = opts.toArray(new String[0]);
FacebookSdk.setDataProcessingOptions(optsArray, country, state);
}

/**
Expand Down

0 comments on commit 1426cf8

Please sign in to comment.