FRANotificationHandler.m revision 6c1420dd55f69d09f39dd213ee6c97ba901b8d92
0N/A/*
3909N/A * The contents of this file are subject to the terms of the Common Development and
0N/A * Distribution License (the License). You may not use this file except in compliance with the
0N/A * License.
0N/A *
0N/A * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
2362N/A * specific language governing permission and limitations under the License.
0N/A *
2362N/A * When distributing Covered Software, include this CDDL Header Notice in each file and include
0N/A * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
0N/A * Header, with the fields enclosed by brackets [] replaced by your own identifying
0N/A * information: "Portions copyright [year] [name of copyright owner]".
0N/A *
0N/A * Copyright 2016 ForgeRock AS.
0N/A */
0N/A
0N/A#import "FRAIdentity.h"
0N/A#import "FRAIdentityDatabase.h"
0N/A#import "FRAPushMechanism.h"
0N/A#import "FRANotification.h"
2362N/A#import "FRANotificationHandler.h"
2362N/A
2362N/A/*!
0N/A * Private interface.
0N/A */
0N/A@interface FRANotificationHandler ()
0N/A
0N/A/*!
0N/A * The database.
0N/A */
0N/A@property (nonatomic, strong, readonly) FRAIdentityDatabase *database;
0N/A
0N/A@end
0N/A
0N/A
0N/A@implementation FRANotificationHandler
0N/A
0N/A#pragma mark -
0N/A#pragma mark Lifecycle
0N/A
0N/A- (instancetype)initWithDatabase:(FRAIdentityDatabase *)database {
0N/A self = [super init];
0N/A if (self) {
0N/A _database = database;
0N/A }
0N/A return self;
0N/A}
0N/A
0N/A+ (instancetype)handlerWithDatabase:(FRAIdentityDatabase *)database {
0N/A return [[FRANotificationHandler alloc] initWithDatabase:database];
0N/A}
0N/A
0N/A#pragma mark -
0N/A#pragma mark Remote Notifications
0N/A
0N/A- (void)handleRemoteNotification:(NSDictionary *)userInfo {
0N/A
0N/A NSLog(@"first %@", [userInfo objectForKey:@"first"]);
0N/A NSLog(@"second %@", [userInfo objectForKey:@"second"]);
4632N/A
0N/A // TODO: Read relevant attributes from userInfo (object graph representation of JSON notification)
0N/A // and populate FRANotification appropriately.
0N/A
0N/A FRANotification *notification = [[FRANotification alloc] init];
0N/A
0N/A // Until registration & mechanismIds are implemented, just add the notification to the dummy push mechanism on Alice
1592N/A
0N/A FRAPushMechanism* dummyPushMechanism = nil;
0N/A for (FRAIdentity* identity in [self.database identities]) {
1592N/A for (FRAMechanism* mechanism in identity.mechanisms) {
0N/A if ([mechanism isKindOfClass:[FRAPushMechanism class]]) {
0N/A dummyPushMechanism = (FRAPushMechanism *) mechanism;
0N/A break;
1592N/A }
0N/A }
0N/A if (dummyPushMechanism) {
4632N/A break;
4632N/A }
4632N/A }
4632N/A [dummyPushMechanism addNotification:notification];
0N/A}
0N/A
0N/A@end
0N/A