Skip to content

Commit

Permalink
fix: addSslPinningErrorListener compatibility with RN Android <v0.65
Browse files Browse the repository at this point in the history
  • Loading branch information
frw committed Jul 28, 2023
1 parent 141cdba commit b1723fe
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ public class SslPublicKeyPinningModule extends ReactContextBaseJavaModule implem
private static CertificatePinner certificatePinner = null;
private static boolean isCustomClientBuilderInitialized = false;

private static int listenerCount = 0;

public SslPublicKeyPinningModule(ReactApplicationContext reactContext) {
super(reactContext);
}
Expand Down Expand Up @@ -120,10 +118,7 @@ private void initializeCustomClientBuilder() {
previousCustomClientBuilder.apply(builder);
}
if (certificatePinner != null) {
builder.certificatePinner(certificatePinner);
if (listenerCount > 0) {
builder.addInterceptor(this);
}
builder.certificatePinner(certificatePinner).addInterceptor(this);
}
});
}
Expand Down Expand Up @@ -174,11 +169,9 @@ public Response intercept(@NonNull Chain chain) throws IOException {

@ReactMethod
public void addListener(String eventName) {
listenerCount += 1;
}

@ReactMethod
public void removeListeners(Integer count) {
listenerCount -= count;
}
}

0 comments on commit b1723fe

Please sign in to comment.