Skip to content

Commit 625d40f

Browse files
westy92Jeasmine
authored andcommitted
Re-expose notificationPermissionStatus.
1 parent b248f2e commit 625d40f

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/src/defines.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
String sdkVersion = "2.2.0";
1+
String sdkVersion = "3.1.0";
22

33
/// Determines how notifications should be displayed
44
enum OSNotificationDisplayType { none, alert, notification }
@@ -7,8 +7,13 @@ enum OSNotificationDisplayType { none, alert, notification }
77
/// or took a specific action by tapping a button (`actionTaken`)
88
enum OSNotificationActionType { opened, actionTaken }
99

10-
//// NOTE: provisional permission is only available in iOS 12
11-
enum OSNotificationPermission { notDetermined, denied, authorized, provisional }
10+
enum OSNotificationPermission {
11+
notDetermined,
12+
denied,
13+
authorized,
14+
provisional, // only available in iOS 12
15+
ephemeral, // only available in iOS 14
16+
}
1217

1318
/// An enum that declares different types of log levels you can
1419
/// use with the OneSignal SDK, going from the least verbose (none)

lib/src/permission.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class OSDeviceState extends JSONStringRepresentable {
9696
String? emailAddress;
9797
String? smsUserId;
9898
String? smsNumber;
99+
OSNotificationPermission? notificationPermissionStatus;
99100

100101
OSDeviceState(Map<String, dynamic> json) {
101102
this.hasNotificationPermission = json['hasNotificationPermission'] as bool;
@@ -109,6 +110,7 @@ class OSDeviceState extends JSONStringRepresentable {
109110
this.emailAddress = json['emailAddress'] as String?;
110111
this.smsUserId = json['smsUserId'] as String?;
111112
this.smsNumber = json['smsNumber'] as String?;
113+
this.notificationPermissionStatus = json['notificationPermissionStatus'] == null ? null : OSNotificationPermission.values[json['notificationPermissionStatus']];
112114
}
113115

114116
String jsonRepresentation() {
@@ -123,7 +125,8 @@ class OSDeviceState extends JSONStringRepresentable {
123125
'emailAddress': this.emailAddress,
124126
'isSMSSubscribed': this.smsSubscribed,
125127
'smsUserId': this.smsUserId,
126-
'smsNumber': this.smsNumber
128+
'smsNumber': this.smsNumber,
129+
'notificationPermissionStatus': this.notificationPermissionStatus?.index,
127130
});
128131
}
129132
}

0 commit comments

Comments
 (0)