Skip to content

Commit 362e0b0

Browse files
committed
Add DeviceState SMS data
* Include SMS data under OSDeviceState
1 parent 992be95 commit 362e0b0

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

android/src/main/java/com/onesignal/flutter/OneSignalSerializer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,13 @@ static HashMap<String, Object> convertDeviceStateToMap(OSDeviceState state) {
7878
hash.put("pushDisabled", state.isPushDisabled());
7979
hash.put("subscribed", state.isSubscribed());
8080
hash.put("emailSubscribed", state.isEmailSubscribed());
81+
hash.put("smsSubscribed", state.isSMSSubscribed());
8182
hash.put("userId", state.getUserId());
8283
hash.put("pushToken", state.getPushToken());
8384
hash.put("emailUserId", state.getEmailUserId());
8485
hash.put("emailAddress", state.getEmailAddress());
86+
hash.put("smsUserId", state.getSMSUserId());
87+
hash.put("smsNumber", state.getSMSNumber());
8588

8689
return hash;
8790
}

ios/Classes/OneSignalPlugin.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ - (void)getDeviceState:(FlutterMethodCall *)call withResult:(FlutterResult)resul
218218
json[@"emailUserId"] = deviceState.emailUserId;
219219
json[@"emailAddress"] = deviceState.emailAddress;
220220
json[@"emailSubscribed"] = @(deviceState.isEmailSubscribed);
221+
json[@"smsUserId"] = deviceState.smsUserId;
222+
json[@"smsNumber"] = deviceState.smsNumber;
223+
json[@"smsSubscribed"] = @(deviceState.isSMSSubscribed);
221224
json[@"notificationPermissionStatus"] = @(deviceState.notificationPermissionStatus);
222225

223226
result(json);

lib/src/permission.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,26 @@ class OSDeviceState extends JSONStringRepresentable {
8989
bool pushDisabled = false;
9090
bool subscribed = false;
9191
bool emailSubscribed = false;
92+
bool smsSubscribed = false;
9293
String? userId;
9394
String? pushToken;
9495
String? emailUserId;
9596
String? emailAddress;
97+
String? smsUserId;
98+
String? smsNumber;
9699

97100
OSDeviceState(Map<String, dynamic> json) {
98101
this.hasNotificationPermission = json['hasNotificationPermission'] as bool;
99102
this.pushDisabled = json['pushDisabled'] as bool;
100103
this.subscribed = json['subscribed'] as bool;
101104
this.emailSubscribed = json['emailSubscribed'] as bool;
105+
this.smsSubscribed = json['smsSubscribed'] as bool;
102106
this.userId = json['userId'] as String?;
103107
this.pushToken = json['pushToken'] as String?;
104108
this.emailUserId = json['emailUserId'] as String?;
105109
this.emailAddress = json['emailAddress'] as String?;
110+
this.smsUserId = json['smsUserId'] as String?;
111+
this.smsNumber = json['smsNumber'] as String?;
106112
}
107113

108114
String jsonRepresentation() {
@@ -114,7 +120,10 @@ class OSDeviceState extends JSONStringRepresentable {
114120
'pushToken': this.pushToken,
115121
'isEmailSubscribed': this.emailSubscribed,
116122
'emailUserId': this.emailUserId,
117-
'emailAddress': this.emailAddress
123+
'emailAddress': this.emailAddress,
124+
'isSMSSubscribed': this.smsSubscribed,
125+
'smsUserId': this.smsUserId,
126+
'smsNumber': this.smsNumber
118127
});
119128
}
120129
}

0 commit comments

Comments
 (0)