Created
August 13, 2015 16:16
-
-
Save dhrrgn/f7489fe718a5e4d54bc3 to your computer and use it in GitHub Desktop.
Digits React Native module.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RNDigits.m | |
// | |
// Created by Dan Horrigan on 8/13/15. | |
// Copyright (c) 2015 Tackk, Inc. All rights reserved. | |
// | |
#import <DigitsKit/DigitsKit.h> | |
#import "RCTBridgeModule.h" | |
#import "RCTEventDispatcher.h" | |
@interface RNDigits : NSObject <RCTBridgeModule> | |
@end | |
// --------------- | |
@implementation RNDigits | |
@synthesize bridge = _bridge; | |
RCT_EXPORT_MODULE() | |
RCT_EXPORT_METHOD(authenticate) | |
{ | |
[[Digits sharedInstance] authenticateWithCompletion:^(DGTSession *session, NSError *error) { | |
if (session) { | |
NSDictionary *details = @{ | |
@"authToken": session.authToken, | |
@"authTokenSecret": session.authTokenSecret, | |
@"userID": session.userID, | |
@"phoneNumber": session.phoneNumber, | |
}; | |
[self.bridge.eventDispatcher sendAppEventWithName:@"digitsDidAuthenticate" body:details]; | |
} else { | |
[self.bridge.eventDispatcher sendAppEventWithName:@"digitsDidNotAuthenticate" body:@{ | |
@"domain": error.domain, | |
@"description": error.localizedDescription, | |
}]; | |
} | |
}]; | |
} | |
RCT_EXPORT_METHOD(logout) | |
{ | |
[[Digits sharedInstance] logOut]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment