From 5cf1f2cb7e1e427aab3498c3c3fcceb2fc5fdce9 Mon Sep 17 00:00:00 2001 From: Nan Date: Fri, 11 Jul 2025 14:02:26 -0700 Subject: [PATCH] cleanup unused code --- lib/src/defines.dart | 28 ---------------- lib/src/permission.dart | 14 -------- lib/src/utils.dart | 74 ----------------------------------------- test/mock_channel.dart | 7 ---- 4 files changed, 123 deletions(-) delete mode 100644 lib/src/permission.dart diff --git a/lib/src/defines.dart b/lib/src/defines.dart index 77b04665..f1a9e565 100644 --- a/lib/src/defines.dart +++ b/lib/src/defines.dart @@ -1,10 +1,3 @@ -// Determines how notifications should be displayed -enum OSNotificationDisplayType { none, alert, notification } - -/// Indicates whether a user tapped a notification (`opened`) -/// or took a specific action by tapping a button (`actionTaken`) -enum OSNotificationActionType { opened, actionTaken } - enum OSNotificationPermission { notDetermined, denied, @@ -17,24 +10,3 @@ enum OSNotificationPermission { /// use with the OneSignal SDK, going from the least verbose (none) /// to verbose (print all comments). enum OSLogLevel { none, fatal, error, warn, info, debug, verbose } - -/// Various iOS Settings that can be passed during initialization -enum OSiOSSettings { - autoPrompt, - inAppAlerts, - inAppLaunchUrl, - promptBeforeOpeningPushUrl, - inFocusDisplayOption -} - -enum OSSession { DIRECT, INDIRECT, UNATTRIBUTED, DISABLED } - -/// Applies to iOS notifications only -/// Determines if the badgeCount is used to increment -/// the existing badge count, or sets the badge count directly -enum OSCreateNotificationBadgeType { increase, setTo } - -/// control how the notification is delayed -/// timezone: Deliver at a specific time of day in each user's timezone -/// last-active: Deliver at the same time the user last used your app -enum OSCreateNotificationDelayOption { timezone, lastActive } diff --git a/lib/src/permission.dart b/lib/src/permission.dart deleted file mode 100644 index 7e3a5c14..00000000 --- a/lib/src/permission.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:onesignal_flutter/src/utils.dart'; - -class OSPermissionState extends JSONStringRepresentable { - bool permission = false; - OSPermissionState(Map json) { - if (json.containsKey('permission')) { - permission = json['permission'] as bool; - } - } - - String jsonRepresentation() { - return convertToJsonString({'permission': this.permission}); - } -} diff --git a/lib/src/utils.dart b/lib/src/utils.dart index 0f9e1bbd..b931cd46 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -1,79 +1,5 @@ -import 'package:onesignal_flutter/src/defines.dart'; import 'dart:convert'; -// produces a string like this: 2018-07-23T17:56:30.951030 UTC-7:00 -String dateToStringWithOffset(DateTime date) { - var offsetHours = date.timeZoneOffset.inHours; - var offsetMinutes = date.timeZoneOffset.inMinutes % 60; - var dateString = "${date.toIso8601String()} "; - - dateString += "UTC" + - ((offsetHours > 10 || offsetHours < 0) - ? "$offsetHours" - : "0$offsetHours"); - dateString += ":" + - ((offsetMinutes.abs() > 10) ? "$offsetMinutes" : "0$offsetMinutes:00"); - - return dateString; -} - -// in some places, we want to send an enum value to -// ObjC. Before we can do this, we must convert it -// to a string/int/etc. -// However, in some places such as iOS init settings, -// there could be multiple different types of enum, -// so we've combined it into this one function. -dynamic convertEnumCaseToValue(dynamic key) { - switch (key) { - case OSiOSSettings.autoPrompt: - return "kOSSettingsKeyAutoPrompt"; - case OSiOSSettings.inAppAlerts: - return "kOSSettingsKeyInAppAlerts"; - case OSiOSSettings.inAppLaunchUrl: - return "kOSSettingsKeyInAppLaunchURL"; - case OSiOSSettings.inFocusDisplayOption: - return "kOSSettingsKeyInFocusDisplayOption"; - case OSiOSSettings.promptBeforeOpeningPushUrl: - return "kOSSSettingsKeyPromptBeforeOpeningPushURL"; - } - - switch (key) { - case OSCreateNotificationBadgeType.increase: - return "Increase"; - case OSCreateNotificationBadgeType.setTo: - return "SetTo"; - } - - switch (key) { - case OSCreateNotificationDelayOption.lastActive: - return "last_active"; - case OSCreateNotificationDelayOption.timezone: - return "timezone"; - } - - switch (key) { - case OSNotificationDisplayType.none: - return 0; - case OSNotificationDisplayType.alert: - return 1; - case OSNotificationDisplayType.notification: - return 2; - } - - switch (key) { - case OSSession.DIRECT: - return "DIRECT"; - case OSSession.INDIRECT: - return "INDIRECT"; - case OSSession.UNATTRIBUTED: - return "UNATTRIBUTED"; - case OSSession.DISABLED: - return "DISABLED"; - } - - return key; -} - /// An abstract class to provide JSON decoding abstract class JSONStringRepresentable { String jsonRepresentation(); diff --git a/test/mock_channel.dart b/test/mock_channel.dart index d062038a..ecc33ec3 100644 --- a/test/mock_channel.dart +++ b/test/mock_channel.dart @@ -97,7 +97,6 @@ class OneSignalState { bool? consentGiven = false; bool? calledPromptPermission; bool? locationShared; - OSNotificationDisplayType? inFocusDisplayType; bool? disablePush; String? externalId; String? language; @@ -137,12 +136,6 @@ class OneSignalState { this.latestLogStatement = params['message']; } - void setDisplayType(Map params) { - var type = params['displayType'] as int?; - if (type != null) - this.inFocusDisplayType = OSNotificationDisplayType.values[type]; - } - void setEmail(Map params) { this.email = params['email'] as String?; this.emailAuthHashToken = params['emailAuthHashToken'] as String?;