linkway changes
This commit is contained in:
parent
56f53e061f
commit
306be1f93d
@ -905,7 +905,7 @@
|
|||||||
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../../SharedFrameworks";
|
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../../SharedFrameworks";
|
||||||
INFOPLIST_FILE = MVMCore/Info.plist;
|
INFOPLIST_FILE = MVMCore/Info.plist;
|
||||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||||
LIBRARY_SEARCH_PATHS = (
|
LIBRARY_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
@ -933,7 +933,7 @@
|
|||||||
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../../SharedFrameworks";
|
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../../SharedFrameworks";
|
||||||
INFOPLIST_FILE = MVMCore/Info.plist;
|
INFOPLIST_FILE = MVMCore/Info.plist;
|
||||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||||
LIBRARY_SEARCH_PATHS = (
|
LIBRARY_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
// Handles the linkaway action. Return YES if successful, NO if an error should be returned.
|
// Handles the linkaway action. Return YES if successful, NO if an error should be returned.
|
||||||
- (BOOL)linkedAwaySuccessfullyWithURL:(nullable NSString *)URL appURL:(nullable NSString *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData;
|
- (BOOL)linkedAwaySuccessfullyWithURL:(nullable NSString *)URL appURL:(nullable NSString *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData;
|
||||||
|
- (void)shouldLinkAwayWithURL:(nullable NSURL *)URL appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData linkAwayBlock:(nonnull void (^)(NSURL * _Nullable appURL, NSURL * _Nullable URL, NSDictionary * _Nullable actionInformation, NSDictionary * _Nullable additionalData))linkAwayBlock;
|
||||||
|
|
||||||
// Gives the delegate a chance to alter the alert object
|
// Gives the delegate a chance to alter the alert object
|
||||||
- (void)willShowPopupWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject alertJson:(nonnull NSDictionary *)alertJson;
|
- (void)willShowPopupWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject alertJson:(nonnull NSDictionary *)alertJson;
|
||||||
|
|||||||
@ -36,9 +36,6 @@ extern NSString * _Nonnull const KeyActionTypeOpen;
|
|||||||
// Tries to open a page
|
// Tries to open a page
|
||||||
- (void)openPageAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate;
|
- (void)openPageAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate;
|
||||||
|
|
||||||
// Links away to app or browser
|
|
||||||
- (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate;
|
|
||||||
|
|
||||||
// restarts the app
|
// restarts the app
|
||||||
- (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate;
|
- (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate;
|
||||||
|
|
||||||
@ -78,6 +75,20 @@ extern NSString * _Nonnull const KeyActionTypeOpen;
|
|||||||
// Handles action errors.
|
// Handles action errors.
|
||||||
- (void)handleActionError:(nullable MVMCoreErrorObject *)error actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate;
|
- (void)handleActionError:(nullable MVMCoreErrorObject *)error actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate;
|
||||||
|
|
||||||
|
#pragma mark - Link away action
|
||||||
|
|
||||||
|
// Links away to app or browser
|
||||||
|
- (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate;
|
||||||
|
|
||||||
|
// Can subclass to add to urls if needed at global level (delegate is also called)
|
||||||
|
- (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate;
|
||||||
|
|
||||||
|
// Opens the url
|
||||||
|
- (void)openURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate;
|
||||||
|
|
||||||
|
// opens the url in a webview.
|
||||||
|
- (void)openURLInWebView:(nullable NSURL *)url actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate;
|
||||||
|
|
||||||
#pragma mark - Default Action Protocol Functions
|
#pragma mark - Default Action Protocol Functions
|
||||||
|
|
||||||
// Sends the request to the load handler.
|
// Sends the request to the load handler.
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
#import "MVMCoreSessionObject.h"
|
#import "MVMCoreSessionObject.h"
|
||||||
#import "MVMCoreObject.h"
|
#import "MVMCoreObject.h"
|
||||||
#import "MVMCorePresentationDelegateProtocol.h"
|
#import "MVMCorePresentationDelegateProtocol.h"
|
||||||
|
#import <SafariServices/SafariServices.h>
|
||||||
|
|
||||||
NSString * const KeyActionType = @"actionType";
|
NSString * const KeyActionType = @"actionType";
|
||||||
NSString * const KeyActionTypeLinkAway = @"openURL";
|
NSString * const KeyActionTypeLinkAway = @"openURL";
|
||||||
@ -127,25 +128,6 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
|
|
||||||
// Linkaway to the browser or app.
|
|
||||||
NSString *appURL = [actionInformation stringForKey:KeyLinkAwayAppURL];
|
|
||||||
NSString *otherURL = [actionInformation stringForKey:KeyLinkAwayURL];
|
|
||||||
|
|
||||||
BOOL successful = NO;
|
|
||||||
if ([delegate respondsToSelector:@selector(linkedAwaySuccessfullyWithURL:appURL:actionInformation:additionalData:)]) {
|
|
||||||
successful = [delegate linkedAwaySuccessfullyWithURL:otherURL appURL:appURL actionInformation:actionInformation additionalData:additionalData];
|
|
||||||
} else {
|
|
||||||
successful = [MVMCoreActionUtility linkAway:otherURL appURLString:appURL];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cannot linkaway, show error.
|
|
||||||
if (!successful) {
|
|
||||||
MVMCoreErrorObject *error = error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeLinkawayFailed domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeLinkAway]];
|
|
||||||
[self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
|
- (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
|
||||||
|
|
||||||
// Invalidates the session before restarting.
|
// Invalidates the session before restarting.
|
||||||
@ -291,6 +273,78 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - open url functions
|
||||||
|
|
||||||
|
- (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
|
||||||
|
|
||||||
|
// Gets the app url
|
||||||
|
NSURL *appURL = nil;
|
||||||
|
NSString *appURLString = [actionInformation string:KeyLinkAwayAppURL];
|
||||||
|
if (appURLString.length > 0) {
|
||||||
|
appURL = [NSURL URLWithString:appURLString];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets the browser url
|
||||||
|
NSURL *otherURL = nil;
|
||||||
|
NSString *otherURLString = [actionInformation string:KeyLinkAwayURL];
|
||||||
|
if (otherURLString.length > 0) {
|
||||||
|
otherURL = [NSURL URLWithString:otherURLString];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Provide the URL and App URL to be modified if needed by a subclass or delegate.
|
||||||
|
[self prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionInformation additionalData:additionalData delegate:delegate];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
|
||||||
|
|
||||||
|
void(^openURL)(NSURL *, NSURL *, NSDictionary *, NSDictionary *) = ^(NSURL *appURL, NSURL *URL, NSDictionary *actionInformation, NSDictionary *additionalData) {
|
||||||
|
[self openURL:url appURL:appURL actionInformation:actionInformation additionalData:additionalData delegate:delegate];
|
||||||
|
};
|
||||||
|
|
||||||
|
// Allow delegate to modify before opening the url.
|
||||||
|
if ([delegate respondsToSelector:@selector(shouldLinkAwayWithURL:appURL:actionInformation:additionalData:linkAwayBlock:)]) {
|
||||||
|
[delegate shouldLinkAwayWithURL:url appURL:appURL actionInformation:actionInformation additionalData:additionalData linkAwayBlock:openURL];
|
||||||
|
} else {
|
||||||
|
openURL(appURL,url,actionInformation,additionalData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)openURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
|
||||||
|
|
||||||
|
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||||
|
|
||||||
|
// First try to open the application.
|
||||||
|
if (appURL && [[UIApplication sharedApplication] canOpenURL:appURL]) {
|
||||||
|
[[UIApplication sharedApplication] openURL:appURL options:@{} completionHandler:NULL];
|
||||||
|
} else if (url && [[UIApplication sharedApplication] canOpenURL:url]) {
|
||||||
|
|
||||||
|
// Check if we should load in webview
|
||||||
|
BOOL openInWebview = [actionInformation boolForKey:@"openInWebview"];
|
||||||
|
if (openInWebview) {
|
||||||
|
[self openURLInWebView:url actionInformation:actionInformation additionalData:additionalData delegate:delegate];
|
||||||
|
} else {
|
||||||
|
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:NULL];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
[MVMCoreDispatchUtility performBlockInBackground:^{
|
||||||
|
// Cannot linkaway, show error.
|
||||||
|
MVMCoreErrorObject *error = error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeLinkawayFailed domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeLinkAway]];
|
||||||
|
[self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)openURLInWebView:(nullable NSURL *)url actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
|
||||||
|
|
||||||
|
// Presents standard webview.
|
||||||
|
SFSafariViewController *safariViewController = [[SFSafariViewController alloc] initWithURL:url];
|
||||||
|
//safariViewController.delegate = self;
|
||||||
|
safariViewController.preferredBarTintColor = [UIColor whiteColor];
|
||||||
|
safariViewController.preferredControlTintColor = [UIColor blackColor];
|
||||||
|
[[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:safariViewController animated:YES];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Default Action Protocol Functions
|
#pragma mark - Default Action Protocol Functions
|
||||||
|
|
||||||
+ (void)defaultLogAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate{
|
+ (void)defaultLogAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user