Repository URL to install this package:
|
Version:
1.0.1 ▾
|
//
// DEPushNotificationHandlerRegistry.m
// TestIOSPush
//
// Created by Marco Bonati on 23/05/2017.
//
//
#import <Foundation/Foundation.h>
#import "DEPushNotificationHandlerRegistry.h"
@implementation DEPushNotificationHandlerRegistry
{
NSMutableArray *handlers_;
}
+ (id)sharedInstance {
static DEPushNotificationHandlerRegistry *_sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedInstance = [[self alloc] init];
});
return _sharedInstance;
}
- (id)init {
if (self = [super init]) {
handlers_ = [[NSMutableArray alloc]init];
}
return self;
}
- (void)registerNotificationHandler:(id<DEPushNotificationHandler>)handler
{
[handlers_ addObject:handler];
}
- (void)unregisterNotificationHandler:(id<DEPushNotificationHandler>)handler
{
[handlers_ removeObject:handler];
}
- (BOOL)canHandleMessage:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
for (id<DEPushNotificationHandler> handler in handlers_)
{
BOOL handled = [handler canHandleMessage:application didReceiveRemoteNotification:userInfo];
if (handled){
return YES;
}
}
return NO;
}
@end