move notification action handlers to environment
This commit is contained in:
parent
c2aee429b1
commit
a6a7616fdb
|
@ -179,6 +179,16 @@ static NSTimeInterval launchStartedAt;
|
|||
return AppEnvironment.shared.notificationPresenter;
|
||||
}
|
||||
|
||||
- (OWSUserNotificationActionHandler *)userNotificationActionHandler
|
||||
{
|
||||
return AppEnvironment.shared.userNotificationActionHandler;
|
||||
}
|
||||
|
||||
- (OWSLegacyNotificationActionHandler *)legacyNotificationActionHandler
|
||||
{
|
||||
return AppEnvironment.shared.legacyNotificationActionHandler;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
|
@ -1159,8 +1169,8 @@ static NSTimeInterval launchStartedAt;
|
|||
return;
|
||||
}
|
||||
|
||||
[LegacyNotificationActionHandler.shared
|
||||
handleNotificationResponseWithActionIdentifier:LegacyNotificationActionHandler.kDefaultActionIdentifier
|
||||
[self.legacyNotificationActionHandler
|
||||
handleNotificationResponseWithActionIdentifier:OWSLegacyNotificationActionHandler.kDefaultActionIdentifier
|
||||
notification:notification
|
||||
responseInfo:@{}
|
||||
completionHandler:^{
|
||||
|
@ -1194,10 +1204,10 @@ static NSTimeInterval launchStartedAt;
|
|||
return;
|
||||
}
|
||||
|
||||
[LegacyNotificationActionHandler.shared handleNotificationResponseWithActionIdentifier:identifier
|
||||
notification:notification
|
||||
responseInfo:@{}
|
||||
completionHandler:completionHandler];
|
||||
[self.legacyNotificationActionHandler handleNotificationResponseWithActionIdentifier:identifier
|
||||
notification:notification
|
||||
responseInfo:@{}
|
||||
completionHandler:completionHandler];
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -1230,10 +1240,10 @@ static NSTimeInterval launchStartedAt;
|
|||
return;
|
||||
}
|
||||
|
||||
[LegacyNotificationActionHandler.shared handleNotificationResponseWithActionIdentifier:identifier
|
||||
notification:notification
|
||||
responseInfo:responseInfo
|
||||
completionHandler:completionHandler];
|
||||
[self.legacyNotificationActionHandler handleNotificationResponseWithActionIdentifier:identifier
|
||||
notification:notification
|
||||
responseInfo:responseInfo
|
||||
completionHandler:completionHandler];
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -1529,7 +1539,7 @@ static NSTimeInterval launchStartedAt;
|
|||
{
|
||||
OWSLogInfo(@"");
|
||||
[AppReadiness runNowOrWhenAppDidBecomeReady:^() {
|
||||
[UserNotificationActionHandler.shared handleNotificationResponse:response completionHandler:completionHandler];
|
||||
[self.userNotificationActionHandler handleNotificationResponse:response completionHandler:completionHandler];
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
|
@ -217,16 +217,12 @@ extension LegacyNotificationPresenterAdaptee: NotificationPresenterAdaptee {
|
|||
}
|
||||
}
|
||||
|
||||
@objc
|
||||
@objc(OWSLegacyNotificationActionHandler)
|
||||
public class LegacyNotificationActionHandler: NSObject {
|
||||
|
||||
@objc
|
||||
public static let kDefaultActionIdentifier = "LegacyNotificationActionHandler.kDefaultActionIdentifier"
|
||||
|
||||
// TODO move this to environment?
|
||||
@objc
|
||||
static let shared: LegacyNotificationActionHandler = LegacyNotificationActionHandler()
|
||||
|
||||
var actionHandler: NotificationActionHandler {
|
||||
return NotificationActionHandler.shared
|
||||
}
|
||||
|
|
|
@ -202,14 +202,10 @@ extension UserNotificationPresenterAdaptee: NotificationPresenterAdaptee {
|
|||
}
|
||||
}
|
||||
|
||||
@objc
|
||||
@objc(OWSUserNotificationActionHandler)
|
||||
@available(iOS 10.0, *)
|
||||
public class UserNotificationActionHandler: NSObject {
|
||||
|
||||
// TODO move this to environment?
|
||||
@objc
|
||||
static let shared: UserNotificationActionHandler = UserNotificationActionHandler()
|
||||
|
||||
var actionHandler: NotificationActionHandler {
|
||||
return NotificationActionHandler.shared
|
||||
}
|
||||
|
|
|
@ -52,6 +52,30 @@ import SignalMessaging
|
|||
@objc
|
||||
public var backup: OWSBackup
|
||||
|
||||
private var _legacyNotificationActionHandler: LegacyNotificationActionHandler
|
||||
@objc
|
||||
public var legacyNotificationActionHandler: LegacyNotificationActionHandler {
|
||||
get {
|
||||
if #available(iOS 10, *) {
|
||||
owsFailDebug("shouldn't user legacyNotificationActionHandler on modern iOS")
|
||||
}
|
||||
return _legacyNotificationActionHandler
|
||||
}
|
||||
set {
|
||||
_legacyNotificationActionHandler = newValue
|
||||
}
|
||||
}
|
||||
|
||||
// Stored properties cannot be marked as `@available`, only classes and functions.
|
||||
// Instead, store a private `Any` and wrap it with a public `@available` getter
|
||||
private var _userNotificationActionHandler: Any?
|
||||
|
||||
@objc
|
||||
@available(iOS 10.0, *)
|
||||
public var userNotificationActionHandler: UserNotificationActionHandler {
|
||||
return _userNotificationActionHandler as! UserNotificationActionHandler
|
||||
}
|
||||
|
||||
@objc
|
||||
public var backupLazyRestore: BackupLazyRestore
|
||||
|
||||
|
@ -66,6 +90,10 @@ import SignalMessaging
|
|||
self.sessionResetJobQueue = SessionResetJobQueue()
|
||||
self.backup = OWSBackup()
|
||||
self.backupLazyRestore = BackupLazyRestore()
|
||||
if #available(iOS 10.0, *) {
|
||||
self._userNotificationActionHandler = UserNotificationActionHandler()
|
||||
}
|
||||
self._legacyNotificationActionHandler = LegacyNotificationActionHandler()
|
||||
|
||||
super.init()
|
||||
|
||||
|
|
Loading…
Reference in New Issue