@interface ApplicationDelegate<UIApplicationDelegate>
@end
@implementation ApplicationDelegate
- (RACSignal *)rac_registeredForRemoteNotifications {
RACSignal *signal = objc_getAssociatedObject(self, _cmd);
if (signal != nil) return signal;
RACSignal *didRegisterForRemoteNotification = [[self rac_signalForSelector: @selector(application:didRegisterForRemoteNotificationsWithDeviceToken:) fromProtocol: @protocol(UIApplicationDelegate)] map: ^(RACTuple *tuple) {
return tuple.second;
}];
RACSignal *failedToRegister = [[self rac_signalForSelector: @selector(application:didFailToRegisterForRemoteNotificationsWithError:) fromProtocol: @protocol(UIApplicationDelegate)] flattenMap: ^(RACTuple *tuple) {
return [RACSignal error: tuple.second];
}];
signal = [RACSignal merge:@[didRegisterForRemoteNotification, failedToRegister]];
objc_setAssociatedObject(self, _cmd, signal, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
return signal;
}
@end