/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2016 ForgeRock AS.
*/
#import "FRABlockAlertView.h"
#import "FRAIdentity.h"
#import "FRAIdentityModel.h"
#import "FRAPushMechanism.h"
#import "FRANotification.h"
#import "FRANotificationHandler.h"
#import "FRANotificationViewController.h"
#import "FRAMessageUtils.h"
#import "FRAQRUtils.h"
#import <JWT.h>
/*!
* Private interface.
*/
@interface FRANotificationHandler ()
/*!
* The identity model.
*/
/*!
* The database to which notifications should be persisted.
*/
@end
- (instancetype)initWithDatabase:(FRAIdentityDatabase *)database identityModel:(FRAIdentityModel *)identityModel {
if (self) {
}
return self;
}
+ (instancetype)handlerWithDatabase:(FRAIdentityDatabase *)database identityModel:(FRAIdentityModel *)identityModel {
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)messageData {
// if the notification is nil then there was a problem looking up the mechanism
// if the notification is not pending, then the notification timed out or was dealt with by opening the app
// from the homescreen and navigating to the notification; either way, there's nothing further to do here
return;
}
}
// Decode JWT from modessage
if (!payload) {
}
// Lookup push mechanism to which the notification should be added
if (!mechanism) {
return nil;
}
// Try to look up an existing notification (in case this message has already been handled)
FRANotification *notification = [mechanism notificationWithMessageId:[messageData valueForKeyPath:MESSAGE_ID_KEY_PATH]];
if (notification) {
return notification;
}
// otherwise, create the notification from the message and add it to the mechanism
NSString * loadBalancerCookieData = [[NSString alloc] initWithData:[FRAQRUtils decodeBase64:[payload objectForKey:LOAD_BALANCE_KEY]] encoding:NSUTF8StringEncoding];
}
return notification;
}
return (FRAPushMechanism *)mechanism;
} else {
return nil;
}
}
- (void)showNotification:(FRANotification *)notification ifForegroundApplication:(UIApplication *)application {
// jump to the notification if the app was in the foreground when the notification arrived or has
// been opened by clicking on the notification
void (^showNotification)() = ^{
FRANotificationViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:FRANotificationViewControllerStoryboardIdentifer];
};
switch (application.applicationState) {
case UIApplicationStateBackground: {
// don't show notification if app is running in background
}
break;
case UIApplicationStateActive: {
// the notification arrived while the app was in the foreground
}
break;
case UIApplicationStateInactive: {
// the application is being opened from the notification
}
break;
}
}
- (void)showAlertWithTitle:(NSString *)title message:(NSString *)message handler:(void (^)(NSInteger))handler {
}
@end