Created
February 4, 2014 01:11
-
-
Save jdewind/8795714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment