Skip to content

Commit

Permalink
save select cer path from file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakey committed Feb 25, 2017
1 parent 03f50c6 commit eebcbac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 2 additions & 3 deletions SmartPush/PushViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
{

NSString *_token;

NSString *_cerPath;

otSocket socket;
OSStatus _connectResult;
OSStatus _closeResult;
Expand All @@ -23,9 +24,7 @@
SecKeychainRef _keychain;
SecCertificateRef _certificate;
SecIdentityRef _identity;

NSUserDefaults *_defaults;

NSMutableArray *_certificates;

}
Expand Down
15 changes: 11 additions & 4 deletions SmartPush/PushViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#define Push_Production "gateway.push.apple.com"


#define KEY_CER @"KEY_CER"
#define KEY_TOKEN @"KEY_TOKEN"
#define KEY_Payload @"KEY_Payload"
#define KEY_CER @"KEY_CER"
#define KEY_TOKEN @"KEY_TOKEN"
#define KEY_Payload @"KEY_Payload"

#import "PushViewController.h"
#import "SecManager.h"
Expand All @@ -25,9 +25,10 @@ - (void)viewDidLoad {

_connectResult = -50;
_closeResult = -50;
[self loadUserData];
[self modeSwitch:self.devSelect];
[self loadKeychain];
[self loadUserData];

}

- (IBAction)devPopButtonSelect:(DragPopUpButton*)sender {
Expand All @@ -46,6 +47,7 @@ - (IBAction)devPopButtonSelect:(DragPopUpButton*)sender {
- (void)applyWithCerPath:(NSString*)cerPath{
SecCertificateRef secRef = [SecManager certificatesWithPath:cerPath];
if ([SecManager isPushCertificate:secRef]) {
_cerPath = cerPath;
if (secRef) {
_certificate = secRef;
[self resetConnect];
Expand Down Expand Up @@ -99,9 +101,14 @@ - (void)loadUserData{

if ([[_defaults valueForKey:KEY_Payload] description].length>0)
[self.payload setStringValue:[_defaults valueForKey:KEY_Payload]];

if ([[_defaults valueForKey:KEY_CER] description].length>0)
[self applyWithCerPath:[_defaults valueForKey:KEY_CER]];


}
- (void)saveUserData{
[_defaults setValue:_cerPath forKey:KEY_CER];
[_defaults setValue:self.tokenTextField.stringValue forKey:KEY_TOKEN];
[_defaults setValue:self.payload.stringValue forKey:KEY_Payload];
[_defaults synchronize];
Expand Down

0 comments on commit eebcbac

Please sign in to comment.