6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell/*
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * The contents of this file are subject to the terms of the Common Development and
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * Distribution License (the License). You may not use this file except in compliance with the
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * License.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell *
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * specific language governing permission and limitations under the License.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell *
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * When distributing Covered Software, include this CDDL Header Notice in each file and include
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * Header, with the fields enclosed by brackets [] replaced by your own identifying
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * information: "Portions copyright [year] [name of copyright owner]".
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell *
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * Copyright 2016 ForgeRock AS.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell */
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell@class FRAIdentityDatabase;
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell@class FRAIdentityModel;
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell/*!
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * Consumer for notifications received by FRANotificationGateway.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell *
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * This handler creates FRANotification objects from the data payload of a push notification and persists them to the
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * appropriate FRAPushMechanism in the FRAIdentityModel.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell */
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell@interface FRANotificationHandler : NSObject
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark -
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark Lifecycle
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell/*!
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * Init method.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell *
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param database The database to which this object can be persisted.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param identityModel The identity model to which FRANotification objects will be persisted.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @return The initialized notification handler or nil if initialization failed.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell- (instancetype)initWithDatabase:(FRAIdentityDatabase *)database identityModel:(FRAIdentityModel *)identityModel;
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell/*!
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * Static factory.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell *
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param identityModel The identity model to which FRANotification objects will be persisted.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * @return The notification handler or nil if initialization failed.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell+ (instancetype)handlerWithDatabase:(FRAIdentityDatabase *)database identityModel:(FRAIdentityModel *)identityModel;
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark -
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark Remote Notifications
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell/*!
916ef74523ecddc8140815c084ab6971ee366bcfCraig McDonnell * Method copied from UIApplicationDelegate protocol.
916ef74523ecddc8140815c084ab6971ee366bcfCraig McDonnell *
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * Called by FRANotificationGateway when a push notification is received.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell *
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * This method attempts to build an FRANotification object from the provided userInfo and persists it to the
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * FRAIdentityModel under the appropriate FRAPushMechanism.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell *
916ef74523ecddc8140815c084ab6971ee366bcfCraig McDonnell * @param application The application object.
916ef74523ecddc8140815c084ab6971ee366bcfCraig McDonnell * @param messageData An object graph representing the push notification message received.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell */
916ef74523ecddc8140815c084ab6971ee366bcfCraig McDonnell- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)messageData;
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell@end