diff options
-rw-r--r-- | Juick.xcodeproj/project.pbxproj | 9 | ||||
-rw-r--r-- | Juick/AppDelegate.m | 20 | ||||
-rw-r--r-- | Juick/Model/Message.m | 1 | ||||
-rw-r--r-- | Juick/Model/TokensList.h | 14 | ||||
-rw-r--r-- | Juick/Model/TokensList.m | 13 | ||||
-rw-r--r-- | Juick/Supporting Files/Juick-Info.plist | 2 | ||||
-rw-r--r-- | Juick/Supporting Files/Juick-Prefix.pch | 8 |
7 files changed, 59 insertions, 8 deletions
diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj index 8eb5a31..7dd079e 100644 --- a/Juick.xcodeproj/project.pbxproj +++ b/Juick.xcodeproj/project.pbxproj @@ -7,8 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - 063DFC3866D41B2A873F21C2 /* Pods_Juick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B72EF56E0806976BAF9D91E7 /* Pods_Juick.framework */; }; - 48C9BE90B2C1E29BEA14C12C /* Pods_JuickTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F312BD1E5D93EF49132A25B6 /* Pods_JuickTests.framework */; }; + 770A42911E8881CB000B206A /* TokensList.m in Sources */ = {isa = PBXBuildFile; fileRef = 770A42901E8881CB000B206A /* TokensList.m */; }; 77317BAC181BBE8500D60005 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77317BAB181BBE8500D60005 /* Foundation.framework */; }; 77317BAE181BBE8500D60005 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77317BAD181BBE8500D60005 /* CoreGraphics.framework */; }; 77317BB0181BBE8500D60005 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77317BAF181BBE8500D60005 /* UIKit.framework */; }; @@ -60,7 +59,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 4A0219982372B305EC484794 /* Pods-JuickTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JuickTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-JuickTests/Pods-JuickTests.release.xcconfig"; sourceTree = "<group>"; }; + 770A428F1E8881CB000B206A /* TokensList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TokensList.h; sourceTree = "<group>"; }; + 770A42901E8881CB000B206A /* TokensList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TokensList.m; sourceTree = "<group>"; }; 77317BA8181BBE8500D60005 /* Juick.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Juick.app; sourceTree = BUILT_PRODUCTS_DIR; }; 77317BAB181BBE8500D60005 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 77317BAD181BBE8500D60005 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -261,6 +261,8 @@ 77A09549181F1F25002BDECD /* Message.m */, 77B099A4189D57F000A84F59 /* User.h */, 77B099A5189D57F000A84F59 /* User.m */, + 770A428F1E8881CB000B206A /* TokensList.h */, + 770A42901E8881CB000B206A /* TokensList.m */, ); path = Model; sourceTree = "<group>"; @@ -519,6 +521,7 @@ 77A0954A181F1F25002BDECD /* Message.m in Sources */, 77B09994189D0B9900A84F59 /* UIImage+Utils.m in Sources */, 77317BC2181BBE8500D60005 /* MessagesViewController.m in Sources */, + 770A42911E8881CB000B206A /* TokensList.m in Sources */, 77FFC01E1D5FE7CE003BD81A /* NavCell.m in Sources */, 77C67EE21828288C00427098 /* RevealPanelViewController.m in Sources */, 77B099A6189D57F000A84F59 /* User.m in Sources */, diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m index 8240892..1ba0ccf 100644 --- a/Juick/AppDelegate.m +++ b/Juick/AppDelegate.m @@ -14,6 +14,7 @@ #import "ColorScheme.h" #import "Message.h" +#import "TokensList.h" @implementation AppDelegate @@ -45,6 +46,7 @@ SWRevealViewController *reveal; [User checkIsValid:^(BOOL success) { if (success) { [messages loadFromPath:[Message feedUrl] withParams:nil withTitle:@"My feed"]; + [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert|UIUserNotificationTypeSound|UIUserNotificationTypeBadge) categories:nil]]; } else { [User throwUnableToLogin]; } @@ -69,4 +71,22 @@ SWRevealViewController *reveal; [messages pushViewController:loginView animated:YES]; } +-(void) application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { + [[UIApplication sharedApplication] registerForRemoteNotifications]; +} + +-(void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { + NSString *token = [[deviceToken description] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"<>"]]; + token = [token stringByReplacingOccurrencesOfString:@" " withString:@""]; + TokensList *tokensList = [TokensList new]; + tokensList.type = @"apns"; + tokensList.tokens = [NSArray arrayWithObjects:token, nil]; + AFHTTPSessionManager *manager = [APIClient sharedClient].manager; + [manager PUT:@"/notifications" parameters:[tokensList yy_modelToJSONObject] success:nil failure:nil]; +} + +-(void) application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { + NSLog(@"Error: %@", [error debugDescription]); +} + @end diff --git a/Juick/Model/Message.m b/Juick/Model/Message.m index a7934ac..4a6e96c 100644 --- a/Juick/Model/Message.m +++ b/Juick/Model/Message.m @@ -25,6 +25,7 @@ +(void) pullNextFromPath:(NSString *)path params:(NSDictionary *) params callback:(void(^)(NSArray *))callback { AFHTTPSessionManager *manager = [APIClient sharedClient].manager; if ([[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"] != nil) { + manager.requestSerializer = [AFJSONRequestSerializer serializer]; [manager.requestSerializer setAuthorizationHeaderFieldWithUsername:[[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"] password:[[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.password"]]; } [manager GET:path parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { diff --git a/Juick/Model/TokensList.h b/Juick/Model/TokensList.h new file mode 100644 index 0000000..9ed5ab0 --- /dev/null +++ b/Juick/Model/TokensList.h @@ -0,0 +1,14 @@ +// +// TokensList.h +// Juick +// +// Created by Vitaly Takmazov on 27/03/2017. +// Copyright © 2017 com.juick. All rights reserved. +// + +#import <Foundation/Foundation.h> + +@interface TokensList : NSObject +@property NSString *type; +@property NSArray<NSString *> *tokens; +@end diff --git a/Juick/Model/TokensList.m b/Juick/Model/TokensList.m new file mode 100644 index 0000000..5cfe6a6 --- /dev/null +++ b/Juick/Model/TokensList.m @@ -0,0 +1,13 @@ +// +// TokensList.m +// Juick +// +// Created by Vitaly Takmazov on 27/03/2017. +// Copyright © 2017 com.juick. All rights reserved. +// + +#import "TokensList.h" + +@implementation TokensList + +@end diff --git a/Juick/Supporting Files/Juick-Info.plist b/Juick/Supporting Files/Juick-Info.plist index 0c481a1..ed5a794 100644 --- a/Juick/Supporting Files/Juick-Info.plist +++ b/Juick/Supporting Files/Juick-Info.plist @@ -21,7 +21,7 @@ <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> - <string>1.0.14</string> + <string>1.0.16</string> <key>ITSAppUsesNonExemptEncryption</key> <false/> <key>LSApplicationCategoryType</key> diff --git a/Juick/Supporting Files/Juick-Prefix.pch b/Juick/Supporting Files/Juick-Prefix.pch index d88823b..ee9f226 100644 --- a/Juick/Supporting Files/Juick-Prefix.pch +++ b/Juick/Supporting Files/Juick-Prefix.pch @@ -18,8 +18,8 @@ #import "YYWebImage.h" #import "NSString+HTML.h" #import "UIImage+Utils.h" - #import "NSDate+TimeAgo.h" - #import "TTTAttributedLabel.h" - #import "SWRevealViewController.h" - #import <AFNetworking/AFNetworking.h> + #import "NSString+FontAwesome.h" + @import TTTAttributedLabel; + @import AFNetworking; + @import YYModel; #endif |