-
Notifications
You must be signed in to change notification settings - Fork 7
/
RNDigits.m
40 lines (32 loc) · 1.55 KB
/
RNDigits.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#import <DigitsKit/DigitsKit.h>
#import "RNDigits.h"
@implementation RNDigits
RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(logout)
{
[[Digits sharedInstance] logOut];
}
RCT_EXPORT_METHOD(view:(NSDictionary*)config callback:(RCTResponseSenderBlock)callback)
{
Digits *digits = [Digits sharedInstance];
DGTAuthenticationConfiguration *configuration = [[DGTAuthenticationConfiguration alloc] initWithAccountFields:DGTAccountFieldsDefaultOptionMask];
configuration.appearance = [[DGTAppearance alloc] init];
configuration.appearance.accentColor = [UIColor colorWithString:[config valueForKey:@"accentColor"]];
configuration.appearance.backgroundColor = [UIColor colorWithString:[config valueForKey:@"backgroundColor"]];
[digits authenticateWithViewController:nil configuration:configuration completion:^(DGTSession *session, NSError *error) {
if (error) {
callback(@[error.localizedDescription, [NSNull null]]);
} else {
NSDictionary *auth = @{
@"consumerKey": [[digits authConfig] consumerKey],
@"consumerSecret": [[digits authConfig] consumerSecret],
@"authToken": session.authToken,
@"authTokenSecret": session.authTokenSecret,
@"userId": session.userID,
@"phoneNumber": session.phoneNumber
};
callback(@[[NSNull null], auth]);
}
}];
}
@end