Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push ActivationStateMachine tests #662

Merged
merged 47 commits into from
Feb 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
fbbdbfd
Initial Push types
ricardopereira Feb 7, 2017
16af681
Update project
ricardopereira Feb 8, 2017
c75173f
ARTPushNotifications interface
ricardopereira Feb 8, 2017
015abba
Realtime: integrate Push type
ricardopereira Feb 8, 2017
d337aa9
Rest: integrate Push type
ricardopereira Feb 8, 2017
ecd193d
Push.activate
ricardopereira Feb 8, 2017
0ebc76b
fixup! Push.activate
ricardopereira Feb 9, 2017
bb829d8
Push.publish
ricardopereira Feb 13, 2017
c956ba9
fixup! Push.publish
ricardopereira Feb 13, 2017
581e76f
PushChannel subscribe and unsubscribe
ricardopereira Feb 13, 2017
08f9d01
Fix registerCallback
ricardopereira Feb 14, 2017
4d3b772
Remove warnings
ricardopereira Feb 14, 2017
64e6dab
Fix FormFactor
ricardopereira Feb 14, 2017
d67ba78
Fix: use device token as Hex string
ricardopereira Feb 14, 2017
bd73596
Fix: should respect the default encoder
ricardopereira Feb 14, 2017
58f7eab
Remove ARTPushRecipient protocol and types
ricardopereira Feb 14, 2017
e584d67
Add ULID pod
ricardopereira Feb 15, 2017
2a015d9
Use ULID as DeviceId
ricardopereira Feb 15, 2017
9dd8472
Push.deactivate
ricardopereira Feb 15, 2017
ccf0e2b
Load local device
ricardopereira Feb 15, 2017
8622a30
Push: update device
ricardopereira Feb 15, 2017
2c68fa9
PushChannel.subscriptions
ricardopereira Feb 15, 2017
4d2d686
Update ULID pod
ricardopereira Feb 20, 2017
f460881
PushAdmin
ricardopereira Feb 20, 2017
1e51f3e
Update ULID pod
ricardopereira Feb 20, 2017
6a5b42f
Remove warnings
ricardopereira Feb 22, 2017
4ab1d74
JSON encoder: normalize deviceToken hex string
ricardopereira Feb 22, 2017
25a0510
Fix: Push.publish request body
ricardopereira Feb 22, 2017
002c882
Update device forms
ricardopereira Feb 22, 2017
0733ca8
Activation State Machine: init
ricardopereira Feb 22, 2017
7663749
Activation State Machine: registration
ricardopereira Feb 28, 2017
e42b798
Removed ablyPushAuthKey, ablyPushAuthToken and ablyPushClientId from …
ricardopereira Mar 1, 2017
772b53d
Add Rest argument on Push delegate
ricardopereira Mar 2, 2017
1283bec
tmp
tcard Apr 18, 2017
fc53ff7
Fix things for push, and adapt to latest API.
tcard Apr 24, 2017
0aebf3a
Initial State Machine tests
ricardopereira Apr 18, 2017
595d036
ARTLocalDeviceStorage
ricardopereira Apr 18, 2017
82f9906
Fix: ARTPushActivationState
ricardopereira Apr 18, 2017
70ab358
Storage should synchronize UserDefaults
ricardopereira Apr 19, 2017
332748f
Storage Keys accessible on tests
ricardopereira Apr 19, 2017
81fd669
State Machine tests
ricardopereira Apr 19, 2017
c65d63e
ActivationStateMachine: custom delegate and other fixes
ricardopereira Apr 26, 2017
3c984eb
PushActivationStateMachine
ricardopereira Apr 26, 2017
622a79d
Merge branch 'push' into push-spec-activationstatemachine
ricardopereira Jan 25, 2018
c6c0d46
Implement Device storage
ricardopereira Jan 31, 2018
f24ab95
Fix headers
ricardopereira Jan 31, 2018
4c3bc4d
Fix tests
ricardopereira Jan 31, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Ably.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
D71D30041C5F7B2F002115B0 /* RealtimeClientChannels.swift in Sources */ = {isa = PBXBuildFile; fileRef = D71D30031C5F7B2F002115B0 /* RealtimeClientChannels.swift */; };
D72304701BB72CED00F1ABDA /* RealtimeClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = D723046F1BB72CED00F1ABDA /* RealtimeClient.swift */; };
D72768211C9C19040022F8B2 /* RestClientPresence.swift in Sources */ = {isa = PBXBuildFile; fileRef = D72768201C9C19040022F8B2 /* RestClientPresence.swift */; };
D72C67DF201AB74000978EBB /* ARTPushActivationStateMachine+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D72C67DE201AB74000978EBB /* ARTPushActivationStateMachine+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
D73691FF1DB788C40062C150 /* ARTAuthDetails.h in Headers */ = {isa = PBXBuildFile; fileRef = D73691FD1DB788C40062C150 /* ARTAuthDetails.h */; settings = {ATTRIBUTES = (Public, ); }; };
D73692001DB788C40062C150 /* ARTAuthDetails.m in Sources */ = {isa = PBXBuildFile; fileRef = D73691FE1DB788C40062C150 /* ARTAuthDetails.m */; };
D736A0C91F916553005ABE81 /* KSCrash.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D736A0C61F916553005ABE81 /* KSCrash.framework */; };
Expand Down Expand Up @@ -161,6 +162,9 @@
D7DC8AF11C6AA0C8005AF165 /* ARTDefault+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D7DC8AF01C6A9FFC005AF165 /* ARTDefault+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
D7DEAFD11E65926D00D23F24 /* ARTLocalDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = D7DEAFCF1E65926D00D23F24 /* ARTLocalDevice.h */; settings = {ATTRIBUTES = (Public, ); }; };
D7DEAFD21E65926D00D23F24 /* ARTLocalDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = D7DEAFD01E65926D00D23F24 /* ARTLocalDevice.m */; };
D7DF73851EA600240013CD36 /* PushActivationStateMachine.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7DF73831EA5FE620013CD36 /* PushActivationStateMachine.swift */; };
D7DF738A1EA645300013CD36 /* ARTLocalDeviceStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = D7DF73881EA645300013CD36 /* ARTLocalDeviceStorage.h */; settings = {ATTRIBUTES = (Public, ); }; };
D7DF738B1EA645300013CD36 /* ARTLocalDeviceStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = D7DF73891EA645300013CD36 /* ARTLocalDeviceStorage.m */; };
D7EBE5A31BE8391E0086E675 /* RealtimeClientConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7EBE5A21BE8391E0086E675 /* RealtimeClientConnection.swift */; };
D7EBE5A41BE9F6900086E675 /* ARTConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = D7D29B401BE3DD0600374295 /* ARTConnection.h */; settings = {ATTRIBUTES = (Public, ); }; };
D7F1D3731BF4DE07001A4B5E /* ARTRestPresence.h in Headers */ = {isa = PBXBuildFile; fileRef = D7F1D3711BF4DE07001A4B5E /* ARTRestPresence.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -340,6 +344,7 @@
D71D30031C5F7B2F002115B0 /* RealtimeClientChannels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealtimeClientChannels.swift; sourceTree = "<group>"; };
D723046F1BB72CED00F1ABDA /* RealtimeClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealtimeClient.swift; sourceTree = "<group>"; };
D72768201C9C19040022F8B2 /* RestClientPresence.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RestClientPresence.swift; sourceTree = "<group>"; };
D72C67DE201AB74000978EBB /* ARTPushActivationStateMachine+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ARTPushActivationStateMachine+Private.h"; sourceTree = "<group>"; };
D73691FD1DB788C40062C150 /* ARTAuthDetails.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTAuthDetails.h; sourceTree = "<group>"; };
D73691FE1DB788C40062C150 /* ARTAuthDetails.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTAuthDetails.m; sourceTree = "<group>"; };
D736A0C61F916553005ABE81 /* KSCrash.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = KSCrash.framework; path = Carthage/Build/iOS/KSCrash.framework; sourceTree = "<group>"; };
Expand Down Expand Up @@ -421,6 +426,9 @@
D7DC8AF01C6A9FFC005AF165 /* ARTDefault+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ARTDefault+Private.h"; sourceTree = "<group>"; };
D7DEAFCF1E65926D00D23F24 /* ARTLocalDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTLocalDevice.h; sourceTree = "<group>"; };
D7DEAFD01E65926D00D23F24 /* ARTLocalDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTLocalDevice.m; sourceTree = "<group>"; };
D7DF73831EA5FE620013CD36 /* PushActivationStateMachine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PushActivationStateMachine.swift; sourceTree = "<group>"; };
D7DF73881EA645300013CD36 /* ARTLocalDeviceStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTLocalDeviceStorage.h; sourceTree = "<group>"; };
D7DF73891EA645300013CD36 /* ARTLocalDeviceStorage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTLocalDeviceStorage.m; sourceTree = "<group>"; };
D7EBE5A21BE8391E0086E675 /* RealtimeClientConnection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealtimeClientConnection.swift; sourceTree = "<group>"; };
D7EE14F51F07964500C178D5 /* Version.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
D7F1D3711BF4DE07001A4B5E /* ARTRestPresence.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTRestPresence.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -564,6 +572,7 @@
EB1AE0CD1C5C3A4900D62250 /* Utilities.swift */,
EB7913A71C6E54C3000ABF9B /* Crypto.swift */,
D74A17B61FA0D81A006D27B5 /* PushAdmin.swift */,
D7DF73831EA5FE620013CD36 /* PushActivationStateMachine.swift */,
);
path = Spec;
sourceTree = "<group>";
Expand Down Expand Up @@ -660,6 +669,7 @@
isa = PBXGroup;
children = (
D71966E21E5DF360000974DD /* ARTPushActivationStateMachine.h */,
D72C67DE201AB74000978EBB /* ARTPushActivationStateMachine+Private.h */,
D71966E31E5DF360000974DD /* ARTPushActivationStateMachine.m */,
D71966E81E5E006E000974DD /* ARTPushActivationState.h */,
D71966E91E5E006E000974DD /* ARTPushActivationState.m */,
Expand Down Expand Up @@ -857,9 +867,11 @@
D7B621931E4A6FE600684474 /* ARTDeviceDetails.m */,
D768C6AA1E4B5B0200436011 /* ARTDevicePushDetails.h */,
D768C6AB1E4B5B0200436011 /* ARTDevicePushDetails.m */,
EBFFAC181E97919C003E7326 /* ARTLocalDevice+Private.h */,
D7DEAFCF1E65926D00D23F24 /* ARTLocalDevice.h */,
EBFFAC181E97919C003E7326 /* ARTLocalDevice+Private.h */,
D7DEAFD01E65926D00D23F24 /* ARTLocalDevice.m */,
D7DF73881EA645300013CD36 /* ARTLocalDeviceStorage.h */,
D7DF73891EA645300013CD36 /* ARTLocalDeviceStorage.m */,
D71966E71E5DFFC6000974DD /* Activation State Machine */,
D71966E61E5DFFB2000974DD /* Admin */,
);
Expand Down Expand Up @@ -892,6 +904,7 @@
EB91213E1CA0AD6600BA0A40 /* ARTMsgPackEncoder.h in Headers */,
96A507BD1A3791490077CDF8 /* ARTRealtime.h in Headers */,
EB5E058D1C77027600A48B39 /* ARTCrypto+Private.h in Headers */,
D72C67DF201AB74000978EBB /* ARTPushActivationStateMachine+Private.h in Headers */,
D7DC8AF11C6AA0C8005AF165 /* ARTDefault+Private.h in Headers */,
961343D81A42E0B7006DC822 /* ARTClientOptions.h in Headers */,
D7534C321D79E5C20054C182 /* Ably.h in Headers */,
Expand Down Expand Up @@ -986,6 +999,7 @@
D7D8F8251BC2C691009718F2 /* ARTTokenDetails.h in Headers */,
D7D8F82B1BC2C706009718F2 /* ARTTokenRequest.h in Headers */,
EB1AE0CC1C5C1EB200D62250 /* ARTEventEmitter+Private.h in Headers */,
D7DF738A1EA645300013CD36 /* ARTLocalDeviceStorage.h in Headers */,
960D07931A45F1D800ED8C8C /* ARTCrypto.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -1181,6 +1195,7 @@
856AAC991B6E312F00B07119 /* RestClient.swift in Sources */,
D746AE2C1BBB625E003ECEF8 /* RestClientChannel.swift in Sources */,
D71D30041C5F7B2F002115B0 /* RealtimeClientChannels.swift in Sources */,
D7DF73851EA600240013CD36 /* PushActivationStateMachine.swift in Sources */,
D714A63E1C74D4B2002F2CA0 /* NSObject+TestSuite.swift in Sources */,
856AAC971B6E30C800B07119 /* TestUtilities.swift in Sources */,
D72768211C9C19040022F8B2 /* RestClientPresence.swift in Sources */,
Expand Down Expand Up @@ -1250,6 +1265,7 @@
EB9121401CA0AD8200BA0A40 /* ARTMsgPackEncoder.m in Sources */,
96BF61651A35CDE1004CF2B3 /* ARTBaseMessage.m in Sources */,
D7F1D3781BF4DE72001A4B5E /* ARTRealtimePresence.m in Sources */,
D7DF738B1EA645300013CD36 /* ARTLocalDeviceStorage.m in Sources */,
D7B621911E4A6E0200684474 /* ARTPush.m in Sources */,
D7AE18D31E5B410F00478D82 /* ARTPushChannelSubscriptions.m in Sources */,
1CD8DCA01B1C7315007EAF36 /* ARTDefault.m in Sources */,
Expand Down
3 changes: 2 additions & 1 deletion Source/ARTAuth+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ NS_ASSUME_NONNULL_BEGIN
// Private TimeOffset setter for testing only
- (void)setTimeOffset:(NSTimeInterval)offset;

- (NSString *_Nullable)getClientId;
- (NSString *_Nullable)clientId;

- (NSString *_Nullable)appId;

Expand All @@ -89,6 +89,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface ARTEvent (AuthorizationState)
- (instancetype)initWithAuthorizationState:(ARTAuthorizationState)value;
+ (instancetype)newWithAuthorizationState:(ARTAuthorizationState)value;

@end

NS_ASSUME_NONNULL_END
4 changes: 2 additions & 2 deletions Source/ARTAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ NS_ASSUME_NONNULL_BEGIN

@interface ARTAuth : NSObject

- (instancetype)init NS_UNAVAILABLE;
@property (nullable, readonly) NSString *clientId;

@property (nullable, readonly, getter=getClientId) NSString *clientId;
- (instancetype)init NS_UNAVAILABLE;

/**
# (RSA8) Auth#requestToken
Expand Down
2 changes: 1 addition & 1 deletion Source/ARTAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ - (void)setProtocolClientId:(NSString *)clientId {
} ART_TRY_OR_REPORT_CRASH_END
}

- (NSString *)getClientId {
- (NSString *)clientId {
__block NSString *clientId;
dispatch_sync(_queue, ^{
ART_TRY_OR_REPORT_CRASH_START(_rest) {
Expand Down
2 changes: 1 addition & 1 deletion Source/ARTDeviceDetails.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import <Foundation/Foundation.h>
#import "ARTPush.h"
#import <Ably/ARTPush.h>

@class ARTDevicePushDetails;

Expand Down
5 changes: 0 additions & 5 deletions Source/ARTLocalDevice+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
// Copyright © 2017 Ably. All rights reserved.
//

#ifndef ARTLocalDevice_Private_h
#define ARTLocalDevice_Private_h

#import <Ably/ARTRest.h>

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -29,5 +26,3 @@ extern NSString *const ARTDeviceTokenKey;
@end

NS_ASSUME_NONNULL_END

#endif /* ARTLocalDevice_Private_h */
2 changes: 1 addition & 1 deletion Source/ARTLocalDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import <Foundation/Foundation.h>
#import "ARTDeviceDetails.h"
#import <Ably/ARTDeviceDetails.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
21 changes: 9 additions & 12 deletions Source/ARTLocalDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "ARTRest+Private.h"
#import "ARTAuth+Private.h"
#import "ARTEncoder.h"
#import "ARTLocalDeviceStorage.h"
#import <ULID/ULID.h>

NSString *const ARTDevicePlatform = @"ios";
Expand Down Expand Up @@ -59,26 +60,24 @@ + (ARTLocalDevice *)load:(ARTRest *_Nonnull)rest {
}
device.push.recipient[@"transportType"] = ARTDevicePushTransportType;

NSString *deviceId = [[NSUserDefaults standardUserDefaults] stringForKey:ARTDeviceIdKey];
NSString *deviceId = [rest.storage objectForKey:ARTDeviceIdKey];
if (!deviceId) {
deviceId = [[ULID new] ulidString];
[[NSUserDefaults standardUserDefaults] setObject:deviceId forKey:ARTDeviceIdKey];
[[NSUserDefaults standardUserDefaults] synchronize];
[rest.storage setObject:deviceId forKey:ARTDeviceIdKey];
}
device.id = deviceId;
device.updateToken = [[NSUserDefaults standardUserDefaults] stringForKey:ARTDeviceUpdateTokenKey];
device.updateToken = [rest.storage objectForKey:ARTDeviceUpdateTokenKey];

[device setDeviceToken:[[NSUserDefaults standardUserDefaults] stringForKey:ARTDeviceTokenKey]];
[device setDeviceToken:[rest.storage objectForKey:ARTDeviceTokenKey]];

return device;
}

- (void)resetId {
[[NSUserDefaults standardUserDefaults] setObject:nil forKey:ARTDeviceIdKey];
[self.rest.storage setObject:nil forKey:ARTDeviceIdKey];
[self setAndPersistUpdateToken:nil];
NSString *deviceId = [[ULID new] ulidString];
[[NSUserDefaults standardUserDefaults] setObject:deviceId forKey:ARTDeviceIdKey];
[[NSUserDefaults standardUserDefaults] synchronize];
[self.rest.storage setObject:deviceId forKey:ARTDeviceIdKey];
self.id = deviceId;
}

Expand Down Expand Up @@ -118,14 +117,12 @@ - (void)setDeviceToken:(NSString *_Nonnull)token {
}

- (void)setAndPersistDeviceToken:(NSString *)token {
[[NSUserDefaults standardUserDefaults] setObject:token forKey:ARTDeviceTokenKey];
[[NSUserDefaults standardUserDefaults] synchronize];
[self.rest.storage setObject:token forKey:ARTDeviceTokenKey];
[self setDeviceToken:token];
}

- (void)setAndPersistUpdateToken:(NSString *)token {
[[NSUserDefaults standardUserDefaults] setObject:token forKey:ARTDeviceUpdateTokenKey];
[[NSUserDefaults standardUserDefaults] synchronize];
[self.rest.storage setObject:token forKey:ARTDeviceUpdateTokenKey];
self.updateToken = token;
}

Expand Down
22 changes: 22 additions & 0 deletions Source/ARTLocalDeviceStorage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// ARTLocalDeviceStorage.h
// Ably
//
// Created by Ricardo Pereira on 18/04/2017.
// Copyright © 2017 Ably. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@protocol ARTDeviceStorage <NSObject>
- (nullable id)objectForKey:(NSString *)key;
- (void)setObject:(nullable id)value forKey:(NSString *)key;
@end

@interface ARTLocalDeviceStorage : NSObject<ARTDeviceStorage>

@end

NS_ASSUME_NONNULL_END
22 changes: 22 additions & 0 deletions Source/ARTLocalDeviceStorage.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// ARTLocalDeviceStorage.m
// Ably
//
// Created by Ricardo Pereira on 18/04/2017.
// Copyright © 2017 Ably. All rights reserved.
//

#import "ARTLocalDeviceStorage.h"

@implementation ARTLocalDeviceStorage

- (nullable id)objectForKey:(NSString *)key {
return [[NSUserDefaults standardUserDefaults] objectForKey:key];
}

- (void)setObject:(nullable id)value forKey:(NSString *)key {
[[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
[[NSUserDefaults standardUserDefaults] synchronize];
}

@end
5 changes: 0 additions & 5 deletions Source/ARTPush+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
// Copyright © 2017 Ably. All rights reserved.
//

#ifndef ARTPush_Private_h
#define ARTPush_Private_h

#import <Ably/ARTPush.h>

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -20,5 +17,3 @@ NS_ASSUME_NONNULL_BEGIN
@end

NS_ASSUME_NONNULL_END

#endif /* ARTPush_Private_h */
4 changes: 2 additions & 2 deletions Source/ARTPush.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//

#import <Foundation/Foundation.h>
#import "ARTTypes.h"
#import "ARTPushAdmin.h"
#import <Ably/ARTTypes.h>
#import <Ably/ARTPushAdmin.h>

@class ARTRest;
@class ARTRealtime;
Expand Down
3 changes: 2 additions & 1 deletion Source/ARTPush.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#import "ARTClientOptions+Private.h"
#import "ARTPushAdmin+Private.h"
#import "ARTLocalDevice+Private.h"
#import "ARTLocalDeviceStorage.h"
#import "ARTRealtime+Private.h"

NSString *const ARTDeviceIdKey = @"ARTDeviceId";
Expand Down Expand Up @@ -59,7 +60,7 @@ + (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceTokenDa
NSString *deviceToken = [[[deviceTokenData description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]] stringByReplacingOccurrencesOfString:@" " withString:@""];

NSLog(@"ARTPush: device token received %@", deviceToken);
NSString *currentDeviceToken = [[NSUserDefaults standardUserDefaults] stringForKey:ARTDeviceTokenKey];
NSString *currentDeviceToken = [rest.storage objectForKey:ARTDeviceTokenKey];
if ([currentDeviceToken isEqualToString:deviceToken]) {
// Already stored.
return;
Expand Down
4 changes: 4 additions & 0 deletions Source/ARTPushActivationEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
#import <Foundation/Foundation.h>

@class ARTErrorInfo;
@class ARTPushActivationState;

NS_ASSUME_NONNULL_BEGIN

@interface ARTPushActivationEvent : NSObject <NSCoding>

- (NSData *)archive;
+ (nullable ARTPushActivationState *)unarchive:(NSData *)data;

@end

/// Event with Error info
Expand Down
10 changes: 10 additions & 0 deletions Source/ARTPushActivationEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ - (void)encodeWithCoder:(NSCoder *)aCoder {
// Just to persist the class info, no properties
}

#pragma mark - Archive/Unarchive

- (NSData *)archive {
return [NSKeyedArchiver archivedDataWithRootObject:self];
}

+ (ARTPushActivationEvent *)unarchive:(NSData *)data {
return [NSKeyedUnarchiver unarchiveObjectWithData:data];
}

@end

#pragma mark - Event with Error info
Expand Down
4 changes: 4 additions & 0 deletions Source/ARTPushActivationState.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithMachine:(ARTPushActivationStateMachine *)machine;
+ (instancetype)new NS_UNAVAILABLE;
+ (instancetype)newWithMachine:(ARTPushActivationStateMachine *)machine;

@property (atomic, strong, nullable) ARTPushActivationStateMachine *machine;

- (nullable ARTPushActivationState *)transition:(ARTPushActivationEvent *)event;

- (NSData *)archive;
+ (nullable ARTPushActivationState *)unarchive:(NSData *)data;

@end

/// Persistent State
Expand Down
Loading