Merge branch 'develop' into feature/imageurlcache

This commit is contained in:
Pan, Xinlei (Ryan) 2018-04-09 13:34:42 -04:00
commit e4e617581c
4 changed files with 151 additions and 26 deletions

View File

@ -6,6 +6,20 @@
objectVersion = 48;
objects = {
/* Begin PBXAggregateTarget section */
AF954914206EAEAD000095EC /* FatLibrary */ = {
isa = PBXAggregateTarget;
buildConfigurationList = AF954917206EAEAD000095EC /* Build configuration list for PBXAggregateTarget "FatLibrary" */;
buildPhases = (
AF954918206EAF1A000095EC /* ShellScript */,
);
dependencies = (
);
name = FatLibrary;
productName = FatLibrary;
};
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
30349BF11FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */; settings = {ATTRIBUTES = (Public, ); }; };
30349BF21FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 30349BF01FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m */; };
@ -679,6 +693,10 @@
CreatedOnToolsVersion = 9.1;
ProvisioningStyle = Automatic;
};
AF954914206EAEAD000095EC = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 8876D5C31FB50A9E00EB2E3D /* Build configuration list for PBXProject "MVMCore" */;
@ -694,6 +712,7 @@
projectRoot = "";
targets = (
8876D5C81FB50A9E00EB2E3D /* MVMCore */,
AF954914206EAEAD000095EC /* FatLibrary */,
);
};
/* End PBXProject section */
@ -712,6 +731,22 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
AF954918206EAF1A000095EC /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCore\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\"\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator -arch i386 -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\"\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${CONFIGURATION}-iphoneos/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
8876D5C41FB50A9E00EB2E3D /* Sources */ = {
isa = PBXSourcesBuildPhase;
@ -905,7 +940,7 @@
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../../SharedFrameworks";
INFOPLIST_FILE = MVMCore/Info.plist;
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";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
@ -933,7 +968,7 @@
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../../SharedFrameworks";
INFOPLIST_FILE = MVMCore/Info.plist;
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";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
@ -947,6 +982,22 @@
};
name = Release;
};
AF954915206EAEAD000095EC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
AF954916206EAEAD000095EC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@ -968,6 +1019,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
AF954917206EAEAD000095EC /* Build configuration list for PBXAggregateTarget "FatLibrary" */ = {
isa = XCConfigurationList;
buildConfigurations = (
AF954915206EAEAD000095EC /* Debug */,
AF954916206EAEAD000095EC /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 8876D5C01FB50A9E00EB2E3D /* Project object */;

View File

@ -28,8 +28,8 @@
// Prepares to call the previous submit request again. Can overwrite for special loading. Be sure to call submit() block to perform the actual load.
- (void)prepareRequestForPreviousSubmission:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData submit:(nonnull void (^)(MVMCoreRequestParameters * _Nonnull requestParameters, NSDictionary * _Nullable dataForPage))submit;
// 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;
// Handles the linkaway action. Call the block to continue to linkaway.
- (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
- (void)willShowPopupWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject alertJson:(nonnull NSDictionary *)alertJson;

View File

@ -36,9 +36,6 @@ extern NSString * _Nonnull const KeyActionTypeOpen;
// Tries to open a page
- (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
- (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.
- (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
// Sends the request to the load handler.

View File

@ -27,6 +27,7 @@
#import "MVMCoreSessionObject.h"
#import "MVMCoreObject.h"
#import "MVMCorePresentationDelegateProtocol.h"
#import <SafariServices/SafariServices.h>
NSString * const KeyActionType = @"actionType";
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 {
// 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
+ (void)defaultLogAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate{