- Fix PNInstallation

This commit is contained in:
giuseppenuc committed 2016-04-05 15:46:06 +02:00
1 parent 1df32f64a7
commit 7752bf3e18
51 files changed
+14486 -12301

No files matched your search

+12 -1
View File
@@ -21,7 +21,14 @@
*/
+ (instancetype _Nonnull)currentInstallation;
- (void)setDeviceTokenFromData:(nullable NSData *)deviceTokenData;
/**
* <#Description#>
*
* @param deviceTokenData <#deviceTokenData description#>
*
* @return RETURN YES if token is not set o token changes, NO if token is the same of old token.
*/
- (BOOL) setDeviceTokenFromData:(nullable NSData *)deviceTokenData;
///--------------------------------------
#pragma mark - PNInstallation Properties
@@ -51,6 +58,10 @@
* <#Description#>
*/
@property (nonatomic, strong, readonly, nullable) NSString *deviceToken;
/**
* <#Description#>
*/
@property (nonatomic, strong, readonly, nullable) NSString *oldDeviceToken;
/**
* <#Description#>
*/
+25 -7
View File
@@ -7,6 +7,7 @@
//
#import "PNInstallation.h"
#import "DJLocalization.h"
@interface PNInstallation() <PNObjectSubclassing>
@@ -33,6 +34,7 @@ static bool isFirstAccess = YES;
@"deviceName":@"deviceName",
@"osVersion":@"osVersion",
@"deviceToken":@"deviceToken",
@"oldDeviceToken":@"oldDeviceToken",
@"badge":@"badge",
@"localeIdentifier":@"localeIdentifier",
};
@@ -40,11 +42,11 @@ static bool isFirstAccess = YES;
}
+ (NSString *)objectClassName {
return @"Installation";
return @"PNInstallation";
}
+ (NSString *)objectEndPoint {
return @"Installation";
return @"PNInstallation";
}
+ (BOOL) singleInstance {
@@ -61,13 +63,15 @@ static bool isFirstAccess = YES;
dispatch_once(&onceToken, ^{
isFirstAccess = NO;
INSTALLATION = [[super allocWithZone:NULL] init];
INSTALLATION = [[super allocWithZone:NULL] initForCurrentInstallation];
});
return INSTALLATION;
}
- (void)setDeviceTokenFromData:(NSData *)deviceTokenData {
- (BOOL) setDeviceTokenFromData:(NSData *)deviceTokenData {
BOOL response = NO;
_deviceTokenData = deviceTokenData;
@@ -76,14 +80,22 @@ static bool isFirstAccess = YES;
stringByReplacingOccurrencesOfString:@">" withString:@""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
if (!_deviceToken || (_deviceToken && ![ptoken isEqualToString:_deviceToken])) {
response = YES;
}
_oldDeviceToken = _deviceToken;
_deviceToken = ptoken;
return response;
}
#pragma mark -
#pragma mark Private Methods
- (id) init
- (id) initForCurrentInstallation
{
if(INSTALLATION){
return INSTALLATION;
@@ -95,7 +107,10 @@ static bool isFirstAccess = YES;
NSDictionary *savedInstallation = [[PNObjectModel sharedInstance] fetchObjectsWithClass:[self class]];
if (savedInstallation) {
self = [super initWithLocalJSON:savedInstallation];
Class objectClass = NSClassFromString([[self class] PNObjClassName]);
self = [[objectClass alloc] initWithLocalJSON:savedInstallation];
}
else {
self = [super init];
@@ -107,9 +122,12 @@ static bool isFirstAccess = YES;
_deviceModel = [[UIDevice currentDevice] model];
_osVersion = [[UIDevice currentDevice] systemVersion];
_deviceName = [[UIDevice currentDevice] name];
_localeIdentifier = [[DJLocalizationSystem shared] language];
INSTALLATION = self;
}
return self;
return INSTALLATION;
}
#pragma mark -
+1 -1
View File
@@ -82,7 +82,7 @@ static bool isFirstAccess = YES;
if (USER) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
[self autoLogin];
});
}