Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

Commit

Permalink
Method to configure native integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
hzalaz committed Nov 6, 2015
1 parent 8eaf582 commit da89fc4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion auth0-lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Auth0Lock {
show(options, callback) {
LockModule.init(this.lockOptions);
if (this.nativeIntegrations) {
LockModule.registerNativeAuthentication(this.nativeIntegrations);
LockModule.nativeIntegrations(this.nativeIntegrations);
}
LockModule.show(options, callback);
}
Expand Down
27 changes: 13 additions & 14 deletions objc/A0LockReactModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,39 +51,38 @@ @implementation A0LockReactModule
}
}

RCT_EXPORT_METHOD(registerNativeAuthentication:(NSArray *)authentications) {
RCT_EXPORT_METHOD(nativeIntegrations:(NSDictionary *)integrations) {
A0Lock *lock = [[A0LockReact sharedInstance] lock];
if (!lock) {
return;
}
NSMutableArray *authenticators = [@[] mutableCopy];
for (NSDictionary *authentication in authentications) {
NSString *name = authentication[@"name"];
__block NSMutableArray *authenticators = [@[] mutableCopy];
[integrations enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSDictionary * _Nonnull values, BOOL * _Nonnull stop) {
#ifdef FACEBOOK_ENABLED
if ([@"facebook" isEqualToString:name]) {
NSArray *permissions = authentication[@"permissions"];
if ([@"facebook" isEqualToString:key]) {
NSArray *permissions = values[@"permissions"];
if (permissions.count == 0) {
permissions = nil;
}
[authenticators addObject:[A0FacebookAuthenticator newAuthenticatorWithPermissions:permissions]];
}
#endif
#ifdef TWITTER_ENABLED
if ([@"twitter" isEqualToString:name]) {
NSString *apiKey = authentication[@"api_key"];
NSString *apiSecret = authentication[@"api_secret"];
if ([@"twitter" isEqualToString:key]) {
NSString *apiKey = values[@"api_key"];
NSString *apiSecret = values[@"api_secret"];
[authenticators addObject:[A0TwitterAuthenticator newAuthenticatorWithKey:apiKey andSecret:apiSecret]];
}
#endif
#ifdef GOOGLE_PLUS_ENABLED
if ([@"google" isEqualToString:name]) {
NSString *clientId = authentication[@"client_id"];
NSArray *scopes = authentication[@"scopes"];
if ([@"google" isEqualToString:key]) {
NSString *clientId = values[@"client_id"];
NSArray *scopes = values[@"scopes"];
[authenticators addObject:[A0GooglePlusAuthenticator newAuthenticatorWithClientId:clientId andScopes:scopes]];
}
#endif
[lock registerAuthenticators:authenticators];
}
}];
[lock registerAuthenticators:authenticators];
}

RCT_EXPORT_METHOD(show:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback) {
Expand Down
1 change: 0 additions & 1 deletion sample-app/js/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ var {
Image,
TouchableHighlight,
} = React;

var HeaderView = require('./header');
var TokenView = require('./token');
var Auth0Lock = require('react-native-lock-ios');
Expand Down

0 comments on commit da89fc4

Please sign in to comment.