Skip to content

Commit 8b37cfe

Browse files
committed
changing property to isSubscribed instead of subscribed
1 parent c360722 commit 8b37cfe

File tree

8 files changed

+36
-36
lines changed

8 files changed

+36
-36
lines changed

iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ - (void) onOSPermissionChanged:(OSPermissionStateChanges*)stateChanges {
121121
- (void) onOSSubscriptionChanged:(OSSubscriptionStateChanges*)stateChanges {
122122
NSLog(@"onOSSubscriptionChanged: %@", stateChanges);
123123
ViewController* mainController = (ViewController*) self.window.rootViewController;
124-
mainController.subscriptionSegmentedControl.selectedSegmentIndex = (NSInteger) stateChanges.to.subscribed;
124+
mainController.subscriptionSegmentedControl.selectedSegmentIndex = (NSInteger) stateChanges.to.isSubscribed;
125125
}
126126

127127
- (void)onOSEmailSubscriptionChanged:(OSEmailSubscriptionStateChanges *)stateChanges {

iOS_SDK/OneSignalDevApp/OneSignalDevAppClip/AppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ - (void) onOSPermissionChanged:(OSPermissionStateChanges*)stateChanges {
118118
- (void) onOSSubscriptionChanged:(OSSubscriptionStateChanges*)stateChanges {
119119
NSLog(@"onOSSubscriptionChanged: %@", stateChanges);
120120
ViewController* mainController = (ViewController*) self.window.rootViewController;
121-
mainController.subscriptionSegmentedControl.selectedSegmentIndex = (NSInteger) stateChanges.to.subscribed;
121+
mainController.subscriptionSegmentedControl.selectedSegmentIndex = (NSInteger) stateChanges.to.isSubscribed;
122122
}
123123

124124
- (void)onOSEmailSubscriptionChanged:(OSEmailSubscriptionStateChanges *)stateChanges {

iOS_SDK/OneSignalSDK/Source/OSDeviceState.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ - (instancetype)initWithSubscriptionState:(OSPermissionSubscriptionState *)state
4444

4545
_isPushDisabled = ![[state subscriptionStatus] userSubscriptionSetting];
4646

47-
_isSubscribed = [[state subscriptionStatus] subscribed];
47+
_isSubscribed = [[state subscriptionStatus] isSubscribed];
4848

4949
_notificationPermissionStatus = [[state permissionStatus] status];
5050

iOS_SDK/OneSignalSDK/Source/OSEmailSubscription.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ - (instancetype)init {
4848
return self;
4949
}
5050

51-
-(BOOL)subscribed {
51+
-(BOOL)isSubscribed {
5252
return self.emailUserId != nil;
5353
}
5454

iOS_SDK/OneSignalSDK/Source/OSSubscription.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ - (void)setUserSubscriptionSetting:(BOOL)userSubscriptionSetting {
125125

126126

127127
- (void)setAccepted:(BOOL)inAccpeted {
128-
BOOL lastSubscribed = self.subscribed;
128+
BOOL lastSubscribed = self.isSubscribed;
129129

130130
// checks to see if we should delay the observer update
131131
// This is to prevent a problem where the observer gets updated
@@ -137,25 +137,25 @@ - (void)setAccepted:(BOOL)inAccpeted {
137137
}
138138

139139
_accpeted = inAccpeted;
140-
if (lastSubscribed != self.subscribed)
140+
if (lastSubscribed != self.isSubscribed)
141141
[self.observable notifyChange:self];
142142
}
143143

144-
- (BOOL)subscribed {
144+
- (BOOL)isSubscribed {
145145
return _userId && _pushToken && _userSubscriptionSetting && _accpeted;
146146
}
147147

148148
- (NSString*)description {
149149
static NSString* format = @"<OSSubscriptionState: userId: %@, pushToken: %@, userSubscriptionSetting: %d, subscribed: %d>";
150-
return [NSString stringWithFormat:format, self.userId, self.pushToken, self.userSubscriptionSetting, self.subscribed];
150+
return [NSString stringWithFormat:format, self.userId, self.pushToken, self.userSubscriptionSetting, self.isSubscribed];
151151
}
152152

153153
- (NSDictionary*)toDictionary {
154154
return @{
155155
@"userId": _userId ?: [NSNull null],
156156
@"pushToken": _pushToken ?: [NSNull null],
157157
@"userSubscriptionSetting": @(_userSubscriptionSetting),
158-
@"subscribed": @(self.subscribed)
158+
@"subscribed": @(self.isSubscribed)
159159
};
160160
}
161161

iOS_SDK/OneSignalSDK/Source/OneSignal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ typedef NS_ENUM(NSInteger, OSNotificationPermission) {
287287
// Subscription Classes
288288
@interface OSSubscriptionState : NSObject
289289

290-
@property (readonly, nonatomic) BOOL subscribed; // (yes only if userId, pushToken, and setSubscription exists / are true)
290+
@property (readonly, nonatomic) BOOL isSubscribed; // (yes only if userId, pushToken, and setSubscription exists / are true)
291291
@property (readonly, nonatomic) BOOL userSubscriptionSetting; // returns setSubscription state.
292292
@property (readonly, nonatomic, nullable) NSString* userId; // AKA OneSignal PlayerId
293293
@property (readonly, nonatomic, nullable) NSString* pushToken; // AKA Apple Device Token
@@ -298,7 +298,7 @@ typedef NS_ENUM(NSInteger, OSNotificationPermission) {
298298
@interface OSEmailSubscriptionState : NSObject
299299
@property (readonly, nonatomic, nullable) NSString* emailUserId; // The new Email user ID
300300
@property (readonly, nonatomic, nullable) NSString *emailAddress;
301-
@property (readonly, nonatomic) BOOL subscribed;
301+
@property (readonly, nonatomic) BOOL isSubscribed;
302302
- (NSDictionary* _Nonnull)toDictionary;
303303
@end
304304

iOS_SDK/OneSignalSDK/UnitTests/EmailTests.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ - (void)testSubscriptionState {
296296
XCTAssertNil(unsubscribedSubscriptionStatus.emailAuthCode);
297297
XCTAssertNil(unsubscribedSubscriptionStatus.emailAddress);
298298
XCTAssertNil(unsubscribedSubscriptionStatus.emailUserId);
299-
XCTAssertFalse(unsubscribedSubscriptionStatus.subscribed);
299+
XCTAssertFalse(unsubscribedSubscriptionStatus.isSubscribed);
300300

301301
let expectation = [self expectationWithDescription:@"email"];
302302
expectation.expectedFulfillmentCount = 2;
@@ -312,7 +312,7 @@ - (void)testSubscriptionState {
312312
XCTAssertEqual(loggedInSubscriptionStatus.emailUserId, @"1234");
313313
XCTAssertEqual(loggedInSubscriptionStatus.emailAddress, @"[email protected]");
314314
XCTAssertEqual(loggedInSubscriptionStatus.emailAuthCode, @"test-hash-token");
315-
XCTAssertEqual(loggedInSubscriptionStatus.subscribed, true);
315+
XCTAssertEqual(loggedInSubscriptionStatus.isSubscribed, true);
316316

317317
[OneSignal logoutEmailWithSuccess:^{
318318
[expectation fulfill];
@@ -327,7 +327,7 @@ - (void)testSubscriptionState {
327327
XCTAssertNil(loggedOutSubscriptionStatus.emailAuthCode);
328328
XCTAssertNil(loggedOutSubscriptionStatus.emailAddress);
329329
XCTAssertNil(loggedOutSubscriptionStatus.emailUserId);
330-
XCTAssertFalse(loggedOutSubscriptionStatus.subscribed);
330+
XCTAssertFalse(loggedOutSubscriptionStatus.isSubscribed);
331331
}
332332

333333
- (void)testEmailSubscriptionObserver {

iOS_SDK/OneSignalSDK/UnitTests/UnitTests.m

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@ - (void)testBasicInitTest {
183183

184184
NSLog(@"CURRENT USER ID: %@", status.subscriptionStatus);
185185

186-
XCTAssertEqual(status.subscriptionStatus.subscribed, true);
186+
XCTAssertEqual(status.subscriptionStatus.isSubscribed, true);
187187
XCTAssertEqual(status.subscriptionStatus.userSubscriptionSetting, true);
188188
XCTAssertEqual(status.subscriptionStatus.userId, @"1234");
189189
XCTAssertEqualObjects(status.subscriptionStatus.pushToken, @"0000000000000000000000000000000000000000000000000000000000000000");
190190

191191
//email has not been set so the email properties should be nil
192-
XCTAssertFalse(status.emailSubscriptionStatus.subscribed);
192+
XCTAssertFalse(status.emailSubscriptionStatus.isSubscribed);
193193
XCTAssertNil(status.emailSubscriptionStatus.emailUserId);
194194
XCTAssertNil(status.emailSubscriptionStatus.emailAddress);
195195

@@ -428,8 +428,8 @@ - (void)testSubscriptionChangeObserverWhenAlreadyAccepted {
428428
[OneSignal addSubscriptionObserver:observer];
429429
[UnitTestCommonMethods runBackgroundThreads];
430430

431-
XCTAssertEqual(observer->last.from.subscribed, false);
432-
XCTAssertEqual(observer->last.to.subscribed, true);
431+
XCTAssertEqual(observer->last.from.isSubscribed, false);
432+
XCTAssertEqual(observer->last.to.isSubscribed, true);
433433
XCTAssertEqual(observer->fireCount, 1);
434434
}
435435

@@ -449,8 +449,8 @@ - (void)testSubscriptionChangeObserverFireAfterAppRestart {
449449
[OneSignal addSubscriptionObserver:observer];
450450
[UnitTestCommonMethods runBackgroundThreads];
451451

452-
XCTAssertEqual(observer->last.from.subscribed, true);
453-
XCTAssertEqual(observer->last.to.subscribed, false);
452+
XCTAssertEqual(observer->last.from.isSubscribed, true);
453+
XCTAssertEqual(observer->last.to.isSubscribed, false);
454454
}
455455

456456
- (void)testPermissionChangeObserverWithNativeiOS10PromptCall {
@@ -588,14 +588,14 @@ - (void)testSubscriptionChangeObserverBasic {
588588
[UnitTestCommonMethods answerNotificationPrompt:true];
589589
[UnitTestCommonMethods runBackgroundThreads];
590590

591-
XCTAssertEqual(observer->last.from.subscribed, false);
592-
XCTAssertEqual(observer->last.to.subscribed, true);
591+
XCTAssertEqual(observer->last.from.isSubscribed, false);
592+
XCTAssertEqual(observer->last.to.isSubscribed, true);
593593

594594
[OneSignal disablePush:true];
595595
[UnitTestCommonMethods runBackgroundThreads];
596596

597-
XCTAssertEqual(observer->last.from.subscribed, true);
598-
XCTAssertEqual(observer->last.to.subscribed, false);
597+
XCTAssertEqual(observer->last.from.isSubscribed, true);
598+
XCTAssertEqual(observer->last.to.isSubscribed, false);
599599
}
600600

601601
- (void)testSubscriptionChangeObserverWhenPromptNotShown {
@@ -612,7 +612,7 @@ - (void)testSubscriptionChangeObserverWhenPromptNotShown {
612612

613613
XCTAssertNil(observer->last.from.userId);
614614
XCTAssertEqualObjects(observer->last.to.userId, @"1234");
615-
XCTAssertFalse(observer->last.to.subscribed);
615+
XCTAssertFalse(observer->last.to.isSubscribed);
616616

617617
[OneSignal disablePush:true];
618618
[UnitTestCommonMethods runBackgroundThreads];
@@ -622,23 +622,23 @@ - (void)testSubscriptionChangeObserverWhenPromptNotShown {
622622
// Device registered with OneSignal so now make pushToken available.
623623
XCTAssertEqualObjects(observer->last.to.pushToken, @"0000000000000000000000000000000000000000000000000000000000000000");
624624

625-
XCTAssertFalse(observer->last.from.subscribed);
626-
XCTAssertFalse(observer->last.to.subscribed);
625+
XCTAssertFalse(observer->last.from.isSubscribed);
626+
XCTAssertFalse(observer->last.to.isSubscribed);
627627

628628
// Prompt and accept notifications
629629
[self registerForPushNotifications];
630630
[UnitTestCommonMethods answerNotificationPrompt:true];
631631
[UnitTestCommonMethods runBackgroundThreads];
632632

633633
// Shouldn't be subscribed yet as we called setSubscription:false before
634-
XCTAssertFalse(observer->last.from.subscribed);
635-
XCTAssertFalse(observer->last.to.subscribed);
634+
XCTAssertFalse(observer->last.from.isSubscribed);
635+
XCTAssertFalse(observer->last.to.isSubscribed);
636636

637637
// Device should be reported a subscribed now as all conditions are true.
638638
[OneSignal disablePush:false];
639639
[UnitTestCommonMethods runBackgroundThreads];
640-
XCTAssertFalse(observer->last.from.subscribed);
641-
XCTAssertTrue(observer->last.to.subscribed);
640+
XCTAssertFalse(observer->last.from.isSubscribed);
641+
XCTAssertTrue(observer->last.to.isSubscribed);
642642
}
643643

644644
- (void)testInitAcceptingNotificationsWithoutCapabilitesSet {
@@ -1768,19 +1768,19 @@ -(void)testDelayedSubscriptionUpdate {
17681768
[UnitTestCommonMethods runBackgroundThreads];
17691769

17701770
// Shouldn't be subscribed yet as we called setSubscription:false before
1771-
XCTAssertFalse(observer->last.from.subscribed);
1772-
XCTAssertFalse(observer->last.to.subscribed);
1771+
XCTAssertFalse(observer->last.from.isSubscribed);
1772+
XCTAssertFalse(observer->last.to.isSubscribed);
17731773

17741774
// Device should be reported a subscribed now as all condiditions are true.
17751775
[OneSignalClientOverrider setShouldExecuteInstantaneously:false];
17761776
[OneSignal disablePush:false];
17771777

17781778
[OneSignalClientOverrider setShouldExecuteInstantaneously:true];
1779-
XCTAssertFalse(observer->last.to.subscribed);
1779+
XCTAssertFalse(observer->last.to.isSubscribed);
17801780

17811781
[UnitTestCommonMethods runBackgroundThreads];
17821782

1783-
XCTAssertTrue(observer->last.to.subscribed);
1783+
XCTAssertTrue(observer->last.to.isSubscribed);
17841784
}
17851785

17861786
// Checks to make sure that media URL's will not fail the extension-type check if they have query parameters
@@ -1813,7 +1813,7 @@ - (void)testPushNotificationToken {
18131813

18141814
XCTAssertNil(observer->last.from.userId);
18151815
XCTAssertNil(observer->last.to.userId);
1816-
XCTAssertFalse(observer->last.to.subscribed);
1816+
XCTAssertFalse(observer->last.to.isSubscribed);
18171817

18181818
[OneSignal disablePush:false];
18191819
[UnitTestCommonMethods runBackgroundThreads];

0 commit comments

Comments
 (0)