There's a crash in parameter casting:
Could not cast value of type NSStackBlock (0x1030b1e78) to '(__C.UNNotificationPresentationOptions) -> ()' (0x1030b0208). 2018-02-19 17:40:31.204021+0200 [2407:480530]
Could not cast value of type NSStackBlock (0x1030b1e78) to '(C.UNNotificationPresentationOptions) -> ()' (0x1030b0208).
extension Reactive where Base: UNUserNotificationCenter {
public var delegate: DelegateProxy<UNUserNotificationCenter, UNUserNotificationCenterDelegate> {
return RxNotificationServiceDelegateProxy.proxy(for: base)
}
var didReceiveResponce: Observable<UNNotificationResponse> {
return delegate.methodInvoked(#selector(UNUserNotificationCenterDelegate.userNotificationCenter(_:didReceive:withCompletionHandler:))).map { parameters in
return parameters[1] as! UNNotificationResponse
}
}
var willPresentNotification: Observable<((UNNotificationPresentationOptions) -> Void)> {
return delegate.methodInvoked(#selector(UNUserNotificationCenterDelegate.userNotificationCenter(_:willPresent:withCompletionHandler:))).map { parameters in
return parameters[2] as! ((UNNotificationPresentationOptions) -> Void) **CRASH!!!**
}
}
}
All I need is to show localNotifications in the foreground, so delegate method needed accordingly, but can not figure out how to do so I can pass the closure as a parameter to an Observable or if it's not possible or not needed I will be glad to read about your way of solving such issue in RxSwift manner.