-
Notifications
You must be signed in to change notification settings - Fork 0
/
FacebookLoginManager.m
29 lines (22 loc) · 953 Bytes
/
FacebookLoginManager.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
#import "FacebookLoginManager.h"
#import "FBSDKCoreKit/FBSDKCoreKit.h"
#import "FBSDKLoginKit/FBSDKLoginKit.h"
@implementation FacebookLoginManager
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(newSession:(RCTResponseSenderBlock)callback) {
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"public_profile", @"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
callback(@[@"Error", [NSNull null]]);
} else if (result.isCancelled) {
callback(@[@"Canceled", [NSNull null]]);
} else {
FBSDKAccessToken *token = result.token;
NSString *tokenString = token.tokenString;
NSString *userId = token.userID;
NSDictionary *credentials = @{ @"token" : tokenString, @"userId" : userId };
callback(@[[NSNull null], credentials]);
}
}];
};
@end