Skip to content

Commit 23364ba

Browse files
committed
fix(ios): unrecognized selector sent to instance when using props
A critical issue was introduced by #505 that breaks usage of any of the following props on iOS platform: - `permissions` - `defaultAudience` - `nonceIOS` - `loginTrackingIOS` - `tooltipBehaviorIOS` This commit exposes the underlying `FBSDKLoginButton` property on the custom `RCTFBSDKLoginButtonView` wrapper, and re-exports these props as custom properties with the correct viewClass for correct static type checking.
1 parent 7bda1f8 commit 23364ba

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

ios/RCTFBSDK/login/RCTFBSDKLoginButtonManager.m

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,32 @@ - (UIView *)view
4141

4242
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
4343

44-
RCT_EXPORT_VIEW_PROPERTY(permissions, NSStringArray)
44+
RCT_CUSTOM_VIEW_PROPERTY(permissions, NSStringArray, RCTFBSDKLoginButtonView)
45+
{
46+
[view.loginButton setPermissions:json ? json : nil];
47+
}
4548

46-
RCT_EXPORT_VIEW_PROPERTY(defaultAudience, FBSDKDefaultAudience)
49+
RCT_CUSTOM_VIEW_PROPERTY(defaultAudience, FBSDKDefaultAudience, RCTFBSDKLoginButtonView)
50+
{
51+
if (json)
52+
{
53+
[view.loginButton setDefaultAudience:[RCTConvert FBSDKDefaultAudience:json]];
54+
}
55+
}
4756

48-
RCT_CUSTOM_VIEW_PROPERTY(nonceIOS, NSString, FBSDKLoginButton)
57+
RCT_CUSTOM_VIEW_PROPERTY(nonceIOS, NSString, RCTFBSDKLoginButtonView)
4958
{
50-
[view setNonce:json ? json : nil];
59+
[view.loginButton setNonce:json ? json : nil];
5160
}
5261

53-
RCT_CUSTOM_VIEW_PROPERTY(loginTrackingIOS, NSString, FBSDKLoginButton)
62+
RCT_CUSTOM_VIEW_PROPERTY(loginTrackingIOS, NSString, RCTFBSDKLoginButtonView)
5463
{
55-
[view setLoginTracking:([json isEqualToString:@"limited"]) ? FBSDKLoginTrackingLimited : FBSDKLoginTrackingEnabled];
64+
[view.loginButton setLoginTracking:([json isEqualToString:@"limited"]) ? FBSDKLoginTrackingLimited : FBSDKLoginTrackingEnabled];
5665
}
5766

58-
RCT_CUSTOM_VIEW_PROPERTY(tooltipBehaviorIOS, FBSDKLoginButtonTooltipBehavior, FBSDKLoginButton)
67+
RCT_CUSTOM_VIEW_PROPERTY(tooltipBehaviorIOS, FBSDKLoginButtonTooltipBehavior, RCTFBSDKLoginButtonView)
5968
{
60-
[view setTooltipBehavior:json ? [RCTConvert FBSDKLoginButtonTooltipBehavior:json] : FBSDKLoginButtonTooltipBehaviorAutomatic];
69+
[view.loginButton setTooltipBehavior:json ? [RCTConvert FBSDKLoginButtonTooltipBehavior:json] : FBSDKLoginButtonTooltipBehaviorAutomatic];
6170
}
6271

6372

ios/RCTFBSDK/login/RCTFBSDKLoginButtonView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
@interface RCTFBSDKLoginButtonView: UIView<FBSDKLoginButtonDelegate>
77

8+
@property (nonatomic, strong) FBSDKLoginButton *loginButton;
9+
810
@property (nonatomic, copy) RCTBubblingEventBlock onChange;
911

1012
@end

ios/RCTFBSDK/login/RCTFBSDKLoginButtonView.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
@interface RCTFBSDKLoginButtonView ()
1010

11-
@property (nonatomic, strong) FBSDKLoginButton *loginButton;
12-
1311
@end
1412

1513
@implementation RCTFBSDKLoginButtonView

0 commit comments

Comments
 (0)