Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions ActiveStack.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ Pod::Spec.new do |s|
s.name = "ActiveStack"
s.version = "0.2.3"
s.summary = "Active Mobile Service Layer for ActiveStack iOS Clients."
s.homepage = "https://github.com/ActiveStack/active-client-sdk-objc"
s.homepage = "https://github.com/v2Nitesh/active-client-sdk-objc.git"
s.license = 'MIT'
s.author = { "Brad Anderson Smith" => "brad@theappguy.guru" }
s.source = { :git => "https://github.com/ActiveStack/active-client-sdk-objc.git", :tag => s.version.to_s }
s.author = { "Nitesh Meshram" => "nitesh.meshram@v2solutions.com" }
s.source = { :git => "https://github.com/v2Nitesh/active-client-sdk-objc.git", :tag => s.version.to_s }
s.platform = :ios, '7.0'
s.requires_arc = true
s.prefix_header_file = 'client-library/ActiveStack-Prefix.pch'
s.source_files = 'client-library/**/*'

s.dependency 'gtm-oauth2'

s.dependency 'Reachability'
s.dependency 'socket.IO', '0.2.2'

s.dependency 'gtm-oauth2'

s.description = <<-DESC
DESC
TODO: ActiveStack Private pod version 0.2.3.
DESC
end
4 changes: 4 additions & 0 deletions client-library/PFAuthManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@

+ (PFAuthManager *)sharedInstance;

- (void) registerWithAuthenticationProvider:(NSString *)authProvider
credential:(NSString *)credential
delegate:(id<PFAuthManagerDelegate>)delegate;

@end
7 changes: 7 additions & 0 deletions client-library/PFAuthManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ - (void) loginWithAuthenticationProvider:(NSString *)authProvider
[PFClient loginWithAuthenticationProvider:authProvider credential:credential callbackTarget:self method:@selector(providerBasedAuthenticationDidCompleteWithSuccess:)];

}
- (void) registerWithAuthenticationProvider:(NSString *)authProvider
credential:(NSString *)credential
delegate:(id<PFAuthManagerDelegate>)delegate {
self.isAuthenticating = true;
self.delegate = delegate;
[PFClient registerWithAuthenticationProvider:authProvider credential:credential callbackTarget:self method:@selector(providerBasedAuthenticationDidCompleteWithSuccess:)];
}


+ (NSArray *)oauthProviderKeys{
Expand Down
4 changes: 4 additions & 0 deletions client-library/sync/PFClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "PFModelObject.h"
#import "IUserAnchor.h"
#import "Reachability.h"
#import "AuthenticationRequest.h"

@class PFSocketManager;
@class PushCWUpdateRequest;
Expand Down Expand Up @@ -70,4 +71,7 @@
+ (void) logout;
+ (void) save;

+ (bool) registerWithAuthenticationProvider:(NSString *)authProvider credential:(NSString *)credential callbackTarget:(id<AuthenticationDelegate>)target method:(SEL)selector;
+ (AuthenticationRequest *)newRegisterRequestWithAuthenticationProvider:(NSString *)authProvider Credential:(NSString *)credential;

@end
69 changes: 69 additions & 0 deletions client-library/sync/PFClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -563,4 +563,73 @@ - (void)setReachableBlock:(NetworkReachable)reachableBlock{
- (void)setUnReachableBlock:(NetworkUnreachable)unReachableBlock{
self.reach.unreachableBlock = unReachableBlock;
}
#pragma mark - Registration Methods



/** Nitesh
* Service method to allow the client application to user Registration request using a
* custom authentication provider
*/



+(bool) registerWithAuthenticationProvider:(NSString *)authProvider credential:(NSString *)credential callbackTarget:(id<AuthenticationDelegate>)target method:(SEL)selector {
[PFClient sharedInstance].authDelegate = target;
[[PFClient sharedInstance] startLoginTimeoutTimer];
AuthenticationRequest *req;
req = [self newRegisterRequestWithAuthenticationProvider:authProvider Credential:credential];

PFInvocation* callback = [[PFInvocation alloc] initWithTarget:[PFClient sharedInstance] method:@selector(receivedRegisterUsernamePasswordResponse:)];
[[PFSocketManager sharedInstance] sendEvent:@"register" data:req callback:callback];
return true;
}
/**
* Service method to make it easier for the client application to issue a registration request
*/



+(AuthenticationRequest *)newRegisterRequestWithAuthenticationProvider:(NSString *)authProvider Credential:(NSString *)credential {

AuthenticationRequest* req = [[AuthenticationRequest alloc] init];
req.authProvider = authProvider;
req.deviceId = [[NSUUID UUID] UUIDString];
req.credential = credential;
return req;
}

/**
* Callback method for when the registration response is recieved
*/



- (void) receivedRegisterUsernamePasswordResponse:(id) result{
NSLog(@"PFClient Got auth response");
if ([result isMemberOfClass:[AuthenticationResponse class]]) {
AuthenticationResponse* response = (AuthenticationResponse*) result;
UserToken* userToken = response.result;
clientId = response.clientId;
self.userId = userToken.user.ID;
self.token = userToken.token;
if (self.token.length > 0 && self.userId.length > 0 && [[(AuthenticationResponse *)result statusCode] integerValue] == 200) {
[PFClient save];
return;
}
else {
NSString *errorMessage = [(AuthenticationResponse *)result message];
[loginTimeOutTimer invalidate];
NSError *error = [NSError errorWithDomain:@"com.activestack.error" code:0 userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: %@",errorMessage]}];
[self.authDelegate authenticationDidFailWithError:error];
return;
}
}
[loginTimeOutTimer invalidate];
NSError *error = [NSError errorWithDomain:@"com.activestack.error" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Server did not return a token."}];
[self.authDelegate authenticationDidFailWithError:error];


}

@end