Merge branch 'master' into develop-installation
* master: 1.2.0 no message - Release 1.1.5 - Aggiornato readme # Conflicts: # PNObject.podspec
This commit is contained in:
commit
37c04b3399
@ -32,29 +32,16 @@
|
||||
|
||||
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
// Override point for customization after application launch.
|
||||
/*
|
||||
[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://packman.local/app_dev.php/api/v1/",
|
||||
EnvironmentStage : @"https://packman.ppreview.it/app_stage.php/api/v1/",
|
||||
EnvironmentProduction : @"http://packman.ppreview.it/app_stage.php/api/v1/"
|
||||
} userSubclass:[PNUser class] withOauth:YES];
|
||||
[[PNObjectConfig sharedInstance] setHTTPHeaderValue:@"application/x-www-form-urlencoded" forKey:@"Content-Type"];
|
||||
[[PNObjectConfig sharedInstance] setClientID:@"1_pqjo2w5k7j4g8skco408oc048w8so0ws840gcg8k8gwsgk0g4" clientSecret:@"10w0vg2v6eggooc4wks4w4s0wkwok0wkck0w888so0o80g88w8" forEnv:EnvironmentProduction];
|
||||
#ifdef DEBUG
|
||||
|
||||
[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://pnobject.local/api/v1/",
|
||||
EnvironmentStage : @"http://pnobject.stage.it/api/v1/",
|
||||
EnvironmentProduction : @"http://pnobject.prod.it/api/v1/"
|
||||
} userSubclass:[PNUser class] withOauthMode:OAuthModeClientCredential];
|
||||
|
||||
[[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentStage];
|
||||
[[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentProduction];
|
||||
|
||||
[[PNObjectConfig sharedInstance] setEnvironment:EnvironmentStage];
|
||||
#endif*/
|
||||
|
||||
[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://bmwcallingweb.local/app_dev.php/api/v1/",
|
||||
EnvironmentStage : @"http://bmwcallingweb.ppreview.it/app_dev.php/api/v1/",
|
||||
EnvironmentProduction : @"http://bmwcallingweb.ppreview.it/app_dev.php/api/v1/"
|
||||
} userSubclass:[PNUser class] withOauthMode:OAuthModePassword];
|
||||
|
||||
[[PNObjectConfig sharedInstance] setClientID:@"1_pqjo2w5k7j4g8skco408oc048w8so0ws840gcg8k8gwsgk0g4" clientSecret:@"10w0vg2v6eggooc4wks4w4s0wkwok0wkck0w888so0o80g88w8" forEnv:EnvironmentStage];
|
||||
|
||||
|
||||
[[PNObjectConfig sharedInstance] setOauthUserName:@"admin" oauthPassword:@"admin" forEnv:EnvironmentStage];
|
||||
|
||||
[[PNObjectConfig sharedInstance] setEnvironment:EnvironmentStage];
|
||||
|
||||
//[[PNObjectConfig sharedInstance] setHTTPHeaderValue:@"XMLHttpRequest" forKey:@"X-Request-With"];
|
||||
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
|
||||
_refreshToken = [UIButton newAutoLayoutView];
|
||||
[_refreshToken addTarget:self action:@selector(refreshTokenAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
@ -102,72 +102,22 @@
|
||||
|
||||
- (void) apiCallAction {
|
||||
|
||||
/*PNObjcPassword *password = [PNObjcPassword new];
|
||||
[password setPassword:@"asdasdasd"];
|
||||
[password setConfirmPassword:@"asdasdasd"];
|
||||
|
||||
User *user = [User new];
|
||||
[user setFirstName:@"Giuseppe"];
|
||||
[user setLastName:@"Nuficora"];
|
||||
[user setEmail:@"packman5@giuseppenucifora.com"];
|
||||
[user setPassword:password];
|
||||
[user setHasAcceptedNewsletter:YES];
|
||||
[user setHasAcceptedPrivacy:YES];
|
||||
*/
|
||||
//[user saveLocally];
|
||||
PNObjcPassword *password = [PNObjcPassword new];
|
||||
[password setPassword:@"asdasdasd"];
|
||||
[password setConfirmPassword:@"asdasdasd"];
|
||||
|
||||
PNUser *user = [PNUser new];
|
||||
[user setFirstName:@"Test"];
|
||||
[user setLastName:@"Test"];
|
||||
[user setEmail:@"pnobject@pnobject.com"];
|
||||
[user setPassword:password];
|
||||
[user setHasAcceptedNewsletter:YES];
|
||||
[user setHasAcceptedPrivacy:YES];
|
||||
|
||||
[user saveLocally];
|
||||
|
||||
NSLog(@"%@",[[PNUser currentUser] JSONFormObject]);
|
||||
//NSLog(@"%@",[user JSONObjectMap]);
|
||||
/*[user registerWithBlockSuccess:^(PNUser * _Nullable responseObject) {
|
||||
|
||||
} failure:^(NSError * _Nonnull error) {
|
||||
|
||||
}];*/
|
||||
|
||||
/*[[User currentUser] socialLoginWithBlockSuccessFromViewController:self
|
||||
blockSuccess:^(PNUser * _Nullable responseObject) {
|
||||
|
||||
} failure:^(NSError * _Nonnull error) {
|
||||
|
||||
}];*/
|
||||
|
||||
//User * user = [User currentUser];
|
||||
|
||||
//if ([user isAuthenticated]) {
|
||||
|
||||
/*[User loginCurrentUserWithEmail:@"demo@packman.example" password:@"demo@packman.example" withBlockSuccess:^(PNUser * _Nullable responseObject) {
|
||||
|
||||
NSLog(@"response : %@",responseObject);
|
||||
|
||||
NSLog(@"%@",[User currentUser]);
|
||||
} failure:^(NSError * _Nonnull error) {
|
||||
NSLog(@"response : %@",error);
|
||||
}];*/
|
||||
|
||||
/*[PNUser socialLoginWithBlockSuccess:^(PNUser * _Nullable responseObject) {
|
||||
|
||||
} failure:^(NSError * _Nonnull error) {
|
||||
|
||||
}];*/
|
||||
|
||||
/*[PNUser socialUserFromViewController:self blockSuccess:^(PNUser * _Nullable responseObject) {
|
||||
|
||||
NSLog(@"%@",[[PNUser currentUser] JSONFormObject]);
|
||||
|
||||
|
||||
} failure:^(NSError * _Nonnull error) {
|
||||
|
||||
}];*/
|
||||
|
||||
|
||||
|
||||
/*[User resetPasswordForEmail:@"packman@giuseppenucifora.com" Progress:^(NSProgress * _Nonnull uploadProgress) {
|
||||
|
||||
} Success:^(NSDictionary * _Nullable responseObject) {
|
||||
|
||||
} failure:^(NSError * _Nonnull error) {
|
||||
|
||||
}];*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -8,17 +8,17 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'PNObject'
|
||||
s.version = '1.1.5'
|
||||
s.version = '1.2.0'
|
||||
s.summary = 'PNObject is a simple replica of the more complex ParseObject'
|
||||
|
||||
|
||||
#s.description = <<-DESC TODO: Add long description of the pod here. DESC
|
||||
|
||||
s.homepage = "https://git.giuseppenucifora.com/giuseppenucifora/PNObject"
|
||||
s.homepage = "https://github.com/giuseppenucifora/PNObject"
|
||||
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
s.author = { 'Giuseppe Nucifora' => 'me@giuseppenucifora.com' }
|
||||
s.source = { :git => "https://git.giuseppenucifora.com/giuseppenucifora/PNObject.git", :tag => s.version.to_s }
|
||||
s.source = { :git => "https://github.com/giuseppenucifora/PNObject.git", :tag => s.version.to_s }
|
||||
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
|
||||
|
||||
s.ios.deployment_target = '8.0'
|
||||
|
||||
147
README.md
147
README.md
@ -20,6 +20,153 @@ it, simply add the following line to your Podfile:
|
||||
pod "PNObject"
|
||||
```
|
||||
|
||||
Configure PNObject endpoint client ID, client secret and OAuthModePassword
|
||||
###
|
||||
|
||||
```
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
|
||||
[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://pnobject.local/api/v1/",
|
||||
EnvironmentStage : @"http://pnobject.stage.it/api/v1/",
|
||||
EnvironmentProduction : @"http://pnobject.prod.it/api/v1/"
|
||||
} userSubclass:[PNUser class] withOauthMode:OAuthModePassword];
|
||||
|
||||
[[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentStage];
|
||||
[[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentProduction];
|
||||
|
||||
|
||||
|
||||
[[PNObjectConfig sharedInstance] setOauthUserName:@"admin" oauthPassword:@"admin" forEnv:EnvironmentStage];
|
||||
|
||||
[[PNObjectConfig sharedInstance] setEnvironment:EnvironmentStage];
|
||||
}
|
||||
```
|
||||
###
|
||||
Configure PNObject endpoint client ID, client secret and OAuthModeClientCredential
|
||||
---
|
||||
|
||||
|
||||
```
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
|
||||
[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://pnobject.local/api/v1/",
|
||||
EnvironmentStage : @"http://pnobject.stage.it/api/v1/",
|
||||
EnvironmentProduction : @"http://pnobject.prod.it/api/v1/"
|
||||
} userSubclass:[PNUser class] withOauthMode:OAuthModeClientCredential];
|
||||
|
||||
[[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentStage];
|
||||
[[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentProduction];
|
||||
|
||||
[[PNObjectConfig sharedInstance] setEnvironment:EnvironmentStage];
|
||||
}
|
||||
```
|
||||
###
|
||||
Configure PNObject endpoint and using custom PNUser object
|
||||
---
|
||||
|
||||
```
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
|
||||
[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://pnobject.local/api/v1/",
|
||||
EnvironmentStage : @"http://pnobject.stage.it/api/v1/",
|
||||
EnvironmentProduction : @"http://pnobject.prod.it/api/v1/"
|
||||
} userSubclass:[PNUser class] withOauthMode:OAuthModeClientCredential];
|
||||
|
||||
[[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentStage];
|
||||
[[PNObjectConfig sharedInstance] setClientID:@"xxxxxxxxx" clientSecret:@"xxxxxxxxxxxx" forEnv:EnvironmentProduction];
|
||||
|
||||
[[PNObjectConfig sharedInstance] setEnvironment:EnvironmentStage];
|
||||
}
|
||||
```
|
||||
|
||||
###
|
||||
User.h
|
||||
---
|
||||
|
||||
```
|
||||
|
||||
|
||||
#import <PNObject/PNUser.h>
|
||||
|
||||
@interface User : PNUser
|
||||
|
||||
@end
|
||||
```
|
||||
|
||||
###
|
||||
User.m
|
||||
---
|
||||
```
|
||||
#import "User.h"
|
||||
#import "PNObject+Protected.h"
|
||||
#import "PNObject+PNObjectConnection.h"
|
||||
#import <NSDate_Utils/NSDate+NSDate_Util.h>
|
||||
|
||||
@interface User () <PNObjectSubclassing>
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation User
|
||||
|
||||
+ (NSDictionary *)objcetMapping {
|
||||
|
||||
NSMutableDictionary *userMapping = [[NSMutableDictionary alloc] initWithDictionary:[[PNUser class] objcetMapping]];
|
||||
|
||||
return userMapping;
|
||||
}
|
||||
|
||||
+ (BOOL) singleInstance {
|
||||
return [[self class] singleInstance];
|
||||
}
|
||||
|
||||
+ (NSString * _Nonnull) objectEndPoint {
|
||||
return @"User";
|
||||
}
|
||||
|
||||
|
||||
+ (NSString * _Nonnull ) objectClassName {
|
||||
return @"User";
|
||||
}
|
||||
|
||||
###
|
||||
Custom Reset Password
|
||||
|
||||
+ (void) resetPasswordForEmail:(NSString * _Nonnull) userEmail
|
||||
Progress:(nullable void (^)(NSProgress * _Nonnull uploadProgress)) uploadProgress
|
||||
Success:(nullable void (^)(NSDictionary * _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSError * _Nonnull error))failure {
|
||||
|
||||
[self POSTWithEndpointAction:@"password-reset-request"
|
||||
parameters:[self resetPasswordFormObject:userEmail]
|
||||
progress:uploadProgress
|
||||
success:^(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject) {
|
||||
if (success) {
|
||||
success(responseObject);
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
if (failure) {
|
||||
failure(error);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
+ (NSDictionary * _Nonnull) resetPasswordFormObject:(NSString *) email {
|
||||
|
||||
NSMutableDictionary *resetPasswordDictionary = [[NSMutableDictionary alloc] init];
|
||||
[resetPasswordDictionary setObject:email forKey:@"email"];
|
||||
|
||||
return resetPasswordDictionary;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
Giuseppe Nucifora, me@giuseppenucifora.com
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user