Skip to content

Commit 0bb0512

Browse files
committed
Rename properties to isSubscribed and isPushDisabled
Renaming Subscription State properties from: - `subscribed` to `isSubscribed` - `userSubscriptionSetting` to `isPushDisabled`
1 parent bd5ecff commit 0bb0512

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

lib/src/permission.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ class OSPermissionStateChanges extends JSONStringRepresentable {
8686
class OSDeviceState extends JSONStringRepresentable {
8787

8888
bool hasNotificationPermission = false;
89-
bool pushDisabled = false;
90-
bool subscribed = false;
89+
bool isPushDisabled = false;
90+
bool isSubscribed = false;
9191
bool emailSubscribed = false;
9292
bool smsSubscribed = false;
9393
String? userId;
@@ -100,8 +100,8 @@ class OSDeviceState extends JSONStringRepresentable {
100100

101101
OSDeviceState(Map<String, dynamic> json) {
102102
this.hasNotificationPermission = json['hasNotificationPermission'] as bool;
103-
this.pushDisabled = json['pushDisabled'] as bool;
104-
this.subscribed = json['subscribed'] as bool;
103+
this.isPushDisabled = json['isPushDisabled'] as bool;
104+
this.isSubscribed = json['isSubscribed'] as bool;
105105
this.emailSubscribed = json['emailSubscribed'] as bool;
106106
this.smsSubscribed = json['smsSubscribed'] as bool;
107107
this.userId = json['userId'] as String?;
@@ -116,8 +116,8 @@ class OSDeviceState extends JSONStringRepresentable {
116116
String jsonRepresentation() {
117117
return convertToJsonString({
118118
'hasNotificationPermission': this.hasNotificationPermission,
119-
'isPushDisabled': this.pushDisabled,
120-
'isSubscribed': this.subscribed,
119+
'isPushDisabled': this.isPushDisabled,
120+
'isSubscribed': this.isSubscribed,
121121
'userId': this.userId,
122122
'pushToken': this.pushToken,
123123
'isEmailSubscribed': this.emailSubscribed,

lib/src/subscription.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import 'package:onesignal_flutter/src/utils.dart';
44
class OSSubscriptionState extends JSONStringRepresentable {
55
/// Indicates if you have ever called setSubscription(false) to
66
/// programmatically disable notifications for this user
7-
bool userSubscriptionSetting = false;
7+
bool isPushDisabled = false;
88

99
/// A boolean parameter that indicates if the user
1010
/// is subscribed to your app with OneSignal
1111
/// This is only true if the `userId`, `pushToken`, and
12-
/// `userSubscriptionSetting` parameters are defined/true.
13-
bool subscribed = false;
12+
/// `isPushDisabled` parameters are defined/true.
13+
bool isSubscribed = false;
1414

1515
/// The current user's User ID (AKA playerID) with OneSignal
1616
String? userId; //the user's 'playerId' on OneSignal
@@ -19,8 +19,8 @@ class OSSubscriptionState extends JSONStringRepresentable {
1919
String? pushToken;
2020

2121
OSSubscriptionState(Map<String, dynamic> json) {
22-
this.subscribed = json['subscribed'] as bool;
23-
this.userSubscriptionSetting = json['userSubscriptionSetting'] as bool;
22+
this.isSubscribed = json['isSubscribed'] as bool;
23+
this.isPushDisabled = json['isPushDisabled'] as bool;
2424

2525
if (json.containsKey('userId')) this.userId = json['userId'] as String?;
2626
if (json.containsKey('pushToken'))
@@ -29,8 +29,8 @@ class OSSubscriptionState extends JSONStringRepresentable {
2929

3030
String jsonRepresentation() {
3131
return convertToJsonString({
32-
'subscribed': this.subscribed,
33-
'userSubscriptionSetting': this.userSubscriptionSetting,
32+
'isSubscribed': this.isSubscribed,
33+
'isPushDisabled': this.isPushDisabled,
3434
'pushToken': this.pushToken,
3535
'userId': this.userId
3636
});

test.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"subscription_changed_test" : {
33
"from": {
4-
"subscribed": false,
5-
"userSubscriptionSetting": true,
4+
"isSubscribed": false,
5+
"isPushDisabled": true,
66
"pushToken": "07afbb0b4cb6e7ae5e81efc7fd5d35267ea9a4f12120045aebe29945e52ea30e",
77
"userId": null
88
},
99
"to": {
10-
"subscribed": true,
11-
"userSubscriptionSetting": true,
10+
"isSubscribed": true,
11+
"isPushDisabled": true,
1212
"pushToken": "07afbb0b4cb6e7ae5e81efc7fd5d35267ea9a4f12120045aebe29945e52ea30e",
1313
"userId": "c1b395fc-3b17-4c18-aaa6-195cd3461311"
1414
}

test/subscription_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ void main() {
2323
subscriptionChanges.to.pushToken, subscriptionChanges.from.pushToken);
2424
});
2525

26-
test('expect subscription correctly parses `subscribed`', () {
27-
expect(subscriptionChanges.to.subscribed,
28-
!subscriptionChanges.from.subscribed);
26+
test('expect subscription correctly parses `isSubscribed`', () {
27+
expect(subscriptionChanges.to.isSubscribed,
28+
!subscriptionChanges.from.isSubscribed);
2929
});
3030

31-
test('expect subscription correctly parses `userSubscriptionSetting`', () {
32-
expect(subscriptionChanges.to.userSubscriptionSetting, true);
31+
test('expect subscription correctly parses `isPushDisabled`', () {
32+
expect(subscriptionChanges.to.isPushDisabled, true);
3333
});
3434

3535
// Email Subscription State Tests

0 commit comments

Comments
 (0)