Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
de-push-proxy-plugin / src / ios / DEPushNotificationHandlerRegistry.m
Size: Mime:
//
//  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