- ADD OAuth2 Manager

This commit is contained in:
giuseppenuc committed 2016-02-05 00:56:20 +01:00
1 parent 515d75c316
commit 31a1afdc98
65 files changed
+4110 -2732

No files matched your search

+2 -2
View File
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="whP-gf-Uak">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="whP-gf-Uak">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
</dependencies>
<scenes>
<!--Object View Controller-->
+110 -97
View File
@@ -1,130 +1,143 @@
//
// PNObjectAppDelegate.m
// PNObject
//
// Created by Giuseppe Nucifora on 12/28/2015.
// Copyright (c) 2015 Giuseppe Nucifora. All rights reserved.
//
//
// PNObjectAppDelegate.m
// PNObject
//
// Created by Giuseppe Nucifora on 12/28/2015.
// Copyright (c) 2015 Giuseppe Nucifora. All rights reserved.
//
#import "PNObjectAppDelegate.h"
#import "PNObject.h"
#import "PNUser.h"
#import "PNAddress.h"
#import "PNObject+PNObjectConnection.h"
@implementation PNObjectAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[PNObjectConfig initSharedInstanceForEnvironments:@{ EnvironmentDevelopment : @"https://development.it/api/v1",
EnvironmentStage : @"https://stage.it/api/v1",
EnvironmentProduction : @"https://pnobject.giuseppenucifora.com/"
}];
[[PNObjectConfig sharedInstance] setEnvironment:Production];
//[[[PNObjectConfig sharedInstance] manager] setSecurityPolicy:[AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate]];
//[[PNObjectConfig sharedInstance] manager].securityPolicy.allowInvalidCertificates = YES;
//[PNObject get];*/
/*
PNUser *user = [PNUser currentUser];
//NSLog(@"user : %@",[user getJSONObject]);
//[user autoRemoveLocally];
[user setFirstName:@"Giuseppe2"];
[user setLastName:@"Nucifora2"];
[user setEmail:@"giuseppe.nucifora@giuseppenucifora.com"];
[user setSex:@"M"];
[user setHasAcceptedNewsletter:NO];
[user setHasAcceptedPrivacy:YES];
[user setUsername:@"giuseppe.nucifora"];
[user setPassword:@"giuseppe.nucifora.password"];
[user setPhone:@"+393485904995"];
[user setUserId:@"blablabla"];
[user saveLocally];
[user setFirstName:@"Angela"];
[user setLastName:@"Sapienza"];
[user getJSONObject];*/
PNAccessToken *accessToken = [PNAccessToken currentAccessToken];
NSLog(@"%@",[accessToken JSONObject]);
[[[PNObjectConfig sharedInstance] manager] GET:[[[PNObjectConfig sharedInstance] PNObjEndpoint] stringByAppendingString:[PNAccessToken PNObjClassName]] parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
PNAccessToken *accessToken = [[PNAccessToken alloc] initWithJSON:responseObject];
NSLog(@"%@",[accessToken JSONObject]);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[accessToken saveLocally];
});
//[accessToken saveLocally];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"%@",error);
}];
//NSLog(@"%@",userDictionary);
/*
PNAddress *address1 = [[PNAddress alloc] init];
[address1 setZip:@"95014"];
[address1 setCountry:@"Italy"];
[address1 setCity:@"Giarre"];
[address1 setProvince:@"Catania"];
NSLog(@"%@",[address1 saveLocally]);
PNAddress *address2 = [[PNAddress alloc] init];
[address2 setZip:@"95014"];
[address2 setCountry:@"Italy"];
[address2 setCity:@"Giarre"];
[address2 setProvince:@"Catania"];
NSLog(@"%@",[address2 saveLocally]);*/
return YES;
// Override point for customization after application launch.
[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://packman.local/app_dev.php/api/v1/",
EnvironmentStage : @"http://packman.ppreview.it/app_stage.php/api/v1/",
EnvironmentProduction : @"http://packman.ppreview.it/app_stage.php/api/v1/"
} withOauth:YES];
[[PNObjectConfig sharedInstance] setHTTPHeaderValue:@"application/x-www-form-urlencoded" forKey:@"Content-Type"];
[[PNObjectConfig sharedInstance] setClientID:@"1_pqjo2w5k7j4g8skco408oc048w8so0ws840gcg8k8gwsgk0g4" clientSecret:@"10w0vg2v6eggooc4wks4w4s0wkwok0wkck0w888so0o80g88w8" forEnv:Stage];
#ifdef DEBUG
[[PNObjectConfig sharedInstance] setEnvironment:Stage];
#endif
/*[PNObjectConfig initSharedInstanceForEnvironments:@{ EnvironmentDevelopment : @"https://development.it/api/v1",
EnvironmentStage : @"https://stage.it/api/v1",
EnvironmentProduction : @"https://pnobject.giuseppenucifora.com/"
}];
[[PNObjectConfig sharedInstance] setEnvironment:Production];
//[[[PNObjectConfig sharedInstance] manager] setSecurityPolicy:[AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate]];
//[[PNObjectConfig sharedInstance] manager].securityPolicy.allowInvalidCertificates = YES;
//[PNObject get];
PNUser *user = [PNUser currentUser];
//NSLog(@"user : %@",[user getJSONObject]);
//[user autoRemoveLocally];
[user setFirstName:@"Giuseppe2"];
[user setLastName:@"Nucifora2"];
[user setEmail:@"giuseppe.nucifora@giuseppenucifora.com"];
[user setSex:@"M"];
[user setHasAcceptedNewsletter:NO];
[user setHasAcceptedPrivacy:YES];
[user setUsername:@"giuseppe.nucifora"];
[user setPassword:@"giuseppe.nucifora.password"];
[user setPhone:@"+393485904995"];
[user setUserId:@"blablabla"];
[user saveLocally];
[user setFirstName:@"Angela"];
[user setLastName:@"Sapienza"];
[user getJSONObject];*/
/*[[[PNObjectConfig sharedInstance] manager] GET:[[[PNObjectConfig sharedInstance] baseUrl] stringByAppendingString:[PNAccessToken PNObjEndPoint]] parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
PNAccessToken *accessToken = [[PNAccessToken alloc] initWithJSON:responseObject];
NSLog(@"%@",[accessToken JSONObject]);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[accessToken saveLocally];
});
//[accessToken saveLocally];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"%@",error);
}];*/
//NSLog(@"%@",userDictionary);
/*
PNAddress *address1 = [[PNAddress alloc] init];
[address1 setZip:@"95014"];
[address1 setCountry:@"Italy"];
[address1 setCity:@"Giarre"];
[address1 setProvince:@"Catania"];
NSLog(@"%@",[address1 saveLocally]);
PNAddress *address2 = [[PNAddress alloc] init];
[address2 setZip:@"95014"];
[address2 setCountry:@"Italy"];
[address2 setCity:@"Giarre"];
[address2 setProvince:@"Catania"];
NSLog(@"%@",[address2 saveLocally]);*/
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
+3 -3
View File
@@ -11,7 +11,7 @@
int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([PNObjectAppDelegate class]));
}
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([PNObjectAppDelegate class]));
}
}