Skip to content

Commit

Permalink
Re-expose notificationPermissionStatus.
Browse files Browse the repository at this point in the history
  • Loading branch information
westy92 authored and Jeasmine committed Aug 2, 2021
1 parent b248f2e commit 625d40f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/src/defines.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
String sdkVersion = "2.2.0";
String sdkVersion = "3.1.0";

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

//// NOTE: provisional permission is only available in iOS 12
enum OSNotificationPermission { notDetermined, denied, authorized, provisional }
enum OSNotificationPermission {
notDetermined,
denied,
authorized,
provisional, // only available in iOS 12
ephemeral, // only available in iOS 14
}

/// An enum that declares different types of log levels you can
/// use with the OneSignal SDK, going from the least verbose (none)
Expand Down
5 changes: 4 additions & 1 deletion lib/src/permission.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class OSDeviceState extends JSONStringRepresentable {
String? emailAddress;
String? smsUserId;
String? smsNumber;
OSNotificationPermission? notificationPermissionStatus;

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

String jsonRepresentation() {
Expand All @@ -123,7 +125,8 @@ class OSDeviceState extends JSONStringRepresentable {
'emailAddress': this.emailAddress,
'isSMSSubscribed': this.smsSubscribed,
'smsUserId': this.smsUserId,
'smsNumber': this.smsNumber
'smsNumber': this.smsNumber,
'notificationPermissionStatus': this.notificationPermissionStatus?.index,
});
}
}

0 comments on commit 625d40f

Please sign in to comment.