我想在 Objective C 中创建一个视图并在本机反应中使用,但不知道如何做到这一点这是我的代码:Obj-C:
#import "DGTAuthenticateButtonView.h"
#import "RCTBridge.h"
#import "RCTEventDispatcher.h"
#import "UIView+React.h"
#import <DigitsKit/DigitsKit.h>
@implementation DGTAuthenticateButtonView
RCT_EXPORT_MODULE()
- (UIView *) view {
UIButton *button = [[UIButton alloc] init];
[button setTitle:@"REGISTER" forState:UIControlStateNormal];
return button;
}
RCT_EXPORT_METHOD(authenticate) {
Digits *digits = [Digits sharedInstance];
DGTAuthenticationConfiguration *configuration = [[DGTAuthenticationConfiguration alloc] initWithAccountFields:DGTAccountFieldsDefaultOptionMask];
configuration.phoneNumber = @"+345555555555";
[digits authenticateWithViewController:nil configuration:configuration completion:^(DGTSession *newSession, NSError *error){
}];
}
@end
我想打电话给authenticate
TouchableOpacity 但它不起作用:(
import React, {Component} from 'react';
import {
AppRegistry,TouchableOpacity
} from 'react-native';
var requireNativeComponent = require('requireNativeComponent');
var DGTAuthenticateButtonView = requireNativeComponent('DGTAuthenticateButtonView', DGTAuthenticateButtonView);
class TestProj extends Component {
render() {
return (
<TouchableOpacity style={{flex: 1, backgroundColor: 'green'}}
onPress={() => DGTAuthenticateButtonView.authenticate()}
/>
)
}
}
AppRegistry.registerComponent('TestProj', () => TestProj);
有人知道怎么做吗?提前致谢。