@@ -47,15 +47,15 @@ - (instancetype)initAsToWithPermision:(BOOL)permission {
4747 let standardUserDefaults = OneSignalUserDefaults.initStandard ;
4848 _userId = [standardUserDefaults getSavedStringForKey: OSUD_PLAYER_ID_TO defaultValue: nil ];
4949 _pushToken = [standardUserDefaults getSavedStringForKey: OSUD_PUSH_TOKEN_TO defaultValue: nil ];
50- _userSubscriptionSetting = ! [standardUserDefaults keyExists: OSUD_USER_SUBSCRIPTION_TO];
50+ _isPushDisabled = [standardUserDefaults keyExists: OSUD_USER_SUBSCRIPTION_TO];
5151
5252 return self;
5353}
5454
5555- (BOOL )compare : (OSSubscriptionState*)from {
5656 return ![self .userId ?: @" " isEqualToString: from.userId ?: @" " ] ||
5757 ![self .pushToken ?: @" " isEqualToString: from.pushToken ?: @" " ] ||
58- self.userSubscriptionSetting != from.userSubscriptionSetting ||
58+ self.isPushDisabled != from.isPushDisabled ||
5959 self.accpeted != from.accpeted ;
6060}
6161
@@ -64,14 +64,14 @@ - (instancetype)initAsFrom {
6464 _accpeted = [standardUserDefaults getSavedBoolForKey: OSUD_PERMISSION_ACCEPTED_FROM defaultValue: false ];
6565 _userId = [standardUserDefaults getSavedStringForKey: OSUD_PLAYER_ID_FROM defaultValue: nil ];
6666 _pushToken = [standardUserDefaults getSavedStringForKey: OSUD_PUSH_TOKEN_FROM defaultValue: nil ];
67- _userSubscriptionSetting = ![standardUserDefaults keyExists : OSUD_USER_SUBSCRIPTION_FROM];
67+ _isPushDisabled = ![standardUserDefaults getSavedBoolForKey : OSUD_USER_SUBSCRIPTION_FROM defaultValue: NO ];
6868
6969 return self;
7070}
7171
7272- (void )persistAsFrom {
7373 NSString * strUserSubscriptionSetting = nil ;
74- if (!_userSubscriptionSetting )
74+ if (_isPushDisabled )
7575 strUserSubscriptionSetting = @" no" ;
7676
7777 let standardUserDefaults = OneSignalUserDefaults.initStandard ;
@@ -87,7 +87,7 @@ - (instancetype)copyWithZone:(NSZone*)zone {
8787 if (copy) {
8888 copy->_userId = [_userId copy ];
8989 copy->_pushToken = [_pushToken copy ];
90- copy->_userSubscriptionSetting = _userSubscriptionSetting ;
90+ copy->_isPushDisabled = _isPushDisabled ;
9191 copy->_accpeted = _accpeted;
9292 }
9393
@@ -116,16 +116,16 @@ - (void)setPushToken:(NSString*)pushToken {
116116 }
117117}
118118
119- - (void )setUserSubscriptionSetting : (BOOL )userSubscriptionSetting {
120- BOOL changed = userSubscriptionSetting != _userSubscriptionSetting ;
121- _userSubscriptionSetting = userSubscriptionSetting ;
119+ - (void )setIsPushDisabled : (BOOL )isPushDisabled {
120+ BOOL changed = isPushDisabled != _isPushDisabled ;
121+ _isPushDisabled = isPushDisabled ;
122122 if (self.observable && changed)
123123 [self .observable notifyChange: self ];
124124}
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 {
145- return _userId && _pushToken && _userSubscriptionSetting && _accpeted;
144+ - (BOOL )isSubscribed {
145+ return _userId && _pushToken && !_isPushDisabled && _accpeted;
146146}
147147
148148- (NSString *)description {
149- static NSString * format = @" <OSSubscriptionState: userId: %@ , pushToken: %@ , userSubscriptionSetting : %d , subscribed : %d >" ;
150- return [NSString stringWithFormat: format, self .userId, self .pushToken, self .userSubscriptionSetting , self .subscribed ];
149+ static NSString * format = @" <OSSubscriptionState: userId: %@ , pushToken: %@ , isPushDisabled : %d , isSubscribed : %d >" ;
150+ return [NSString stringWithFormat: format, self .userId, self .pushToken, self .isPushDisabled , self .isSubscribed ];
151151}
152152
153153- (NSDictionary *)toDictionary {
154154 return @{
155155 @" userId" : _userId ?: [NSNull null ],
156156 @" pushToken" : _pushToken ?: [NSNull null ],
157- @" userSubscriptionSetting " : @(_userSubscriptionSetting ),
158- @" subscribed " : @(self.subscribed )
157+ @" isPushDisabled " : @(_isPushDisabled ),
158+ @" isSubscribed " : @(self.isSubscribed )
159159 };
160160}
161161
0 commit comments