Commit d3c9d58b by lee

include app internal deeplink|change app open webview|add deeplink protocol

parent 73fffe50
...@@ -354,6 +354,8 @@ ...@@ -354,6 +354,8 @@
DA4E369E1F188B400007E4D0 /* BUYClient+FilterSoldout.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4E369D1F188B400007E4D0 /* BUYClient+FilterSoldout.m */; }; DA4E369E1F188B400007E4D0 /* BUYClient+FilterSoldout.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4E369D1F188B400007E4D0 /* BUYClient+FilterSoldout.m */; };
DA4E36A11F18A6CB0007E4D0 /* KWMPageResult.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4E36A01F18A6CB0007E4D0 /* KWMPageResult.m */; }; DA4E36A11F18A6CB0007E4D0 /* KWMPageResult.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4E36A01F18A6CB0007E4D0 /* KWMPageResult.m */; };
DA7DF8E51F1DB01600D5239B /* NSString+Format.m in Sources */ = {isa = PBXBuildFile; fileRef = DA7DF8E41F1DB01600D5239B /* NSString+Format.m */; }; DA7DF8E51F1DB01600D5239B /* NSString+Format.m in Sources */ = {isa = PBXBuildFile; fileRef = DA7DF8E41F1DB01600D5239B /* NSString+Format.m */; };
DA8D64121F31C67F00B8F4A6 /* DeepLinkURLProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8D64111F31C67F00B8F4A6 /* DeepLinkURLProtocol.m */; };
DA8D64151F31CD2600B8F4A6 /* DPWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8D64141F31CD2600B8F4A6 /* DPWebViewController.m */; };
DAB6431A1F04CFE5002CD7FE /* AppDelegate+Deeplink.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB643191F04CFE5002CD7FE /* AppDelegate+Deeplink.m */; }; DAB6431A1F04CFE5002CD7FE /* AppDelegate+Deeplink.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB643191F04CFE5002CD7FE /* AppDelegate+Deeplink.m */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
...@@ -985,6 +987,10 @@ ...@@ -985,6 +987,10 @@
DA4E36A01F18A6CB0007E4D0 /* KWMPageResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMPageResult.m; sourceTree = "<group>"; }; DA4E36A01F18A6CB0007E4D0 /* KWMPageResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMPageResult.m; sourceTree = "<group>"; };
DA7DF8E31F1DB01600D5239B /* NSString+Format.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Format.h"; sourceTree = "<group>"; }; DA7DF8E31F1DB01600D5239B /* NSString+Format.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Format.h"; sourceTree = "<group>"; };
DA7DF8E41F1DB01600D5239B /* NSString+Format.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Format.m"; sourceTree = "<group>"; }; DA7DF8E41F1DB01600D5239B /* NSString+Format.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Format.m"; sourceTree = "<group>"; };
DA8D64101F31C67F00B8F4A6 /* DeepLinkURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeepLinkURLProtocol.h; sourceTree = "<group>"; };
DA8D64111F31C67F00B8F4A6 /* DeepLinkURLProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DeepLinkURLProtocol.m; sourceTree = "<group>"; };
DA8D64131F31CD2600B8F4A6 /* DPWebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DPWebViewController.h; sourceTree = "<group>"; };
DA8D64141F31CD2600B8F4A6 /* DPWebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DPWebViewController.m; sourceTree = "<group>"; };
DAB643181F04CFE5002CD7FE /* AppDelegate+Deeplink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "AppDelegate+Deeplink.h"; sourceTree = "<group>"; }; DAB643181F04CFE5002CD7FE /* AppDelegate+Deeplink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "AppDelegate+Deeplink.h"; sourceTree = "<group>"; };
DAB643191F04CFE5002CD7FE /* AppDelegate+Deeplink.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AppDelegate+Deeplink.m"; sourceTree = "<group>"; }; DAB643191F04CFE5002CD7FE /* AppDelegate+Deeplink.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AppDelegate+Deeplink.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
...@@ -1333,6 +1339,8 @@ ...@@ -1333,6 +1339,8 @@
9B0F56B71ECD3424009FC5FE /* UIViewController+AppearLog.m */, 9B0F56B71ECD3424009FC5FE /* UIViewController+AppearLog.m */,
DAB643181F04CFE5002CD7FE /* AppDelegate+Deeplink.h */, DAB643181F04CFE5002CD7FE /* AppDelegate+Deeplink.h */,
DAB643191F04CFE5002CD7FE /* AppDelegate+Deeplink.m */, DAB643191F04CFE5002CD7FE /* AppDelegate+Deeplink.m */,
DA8D64101F31C67F00B8F4A6 /* DeepLinkURLProtocol.h */,
DA8D64111F31C67F00B8F4A6 /* DeepLinkURLProtocol.m */,
); );
path = Class; path = Class;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1448,6 +1456,8 @@ ...@@ -1448,6 +1456,8 @@
C034E7B21D6AFC3B006EE129 /* KWMMainVC.m */, C034E7B21D6AFC3B006EE129 /* KWMMainVC.m */,
80598D451D99193400BF0F97 /* KWMInformationVC.h */, 80598D451D99193400BF0F97 /* KWMInformationVC.h */,
80598D461D99193400BF0F97 /* KWMInformationVC.m */, 80598D461D99193400BF0F97 /* KWMInformationVC.m */,
DA8D64131F31CD2600B8F4A6 /* DPWebViewController.h */,
DA8D64141F31CD2600B8F4A6 /* DPWebViewController.m */,
); );
path = UI; path = UI;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2692,6 +2702,7 @@ ...@@ -2692,6 +2702,7 @@
8091DFA11D6E878C0020519C /* KWMGuideVC.m in Sources */, 8091DFA11D6E878C0020519C /* KWMGuideVC.m in Sources */,
C034E84A1D6B10A0006EE129 /* UIImage+Color.m in Sources */, C034E84A1D6B10A0006EE129 /* UIImage+Color.m in Sources */,
801230F21DD30704008C7904 /* KWMSearchBrandsCell.m in Sources */, 801230F21DD30704008C7904 /* KWMSearchBrandsCell.m in Sources */,
DA8D64151F31CD2600B8F4A6 /* DPWebViewController.m in Sources */,
C048342E1F13254200A5BFB4 /* KWMMenuHeader.m in Sources */, C048342E1F13254200A5BFB4 /* KWMMenuHeader.m in Sources */,
C0DD531E1EE54F5D002D1E0C /* KWMMineTitleView.m in Sources */, C0DD531E1EE54F5D002D1E0C /* KWMMineTitleView.m in Sources */,
805C04351DD1FA4900ACC071 /* KWMBrandsTypeModel.m in Sources */, 805C04351DD1FA4900ACC071 /* KWMBrandsTypeModel.m in Sources */,
...@@ -2763,6 +2774,7 @@ ...@@ -2763,6 +2774,7 @@
807AF4A61DC984950000A326 /* KWMDataProduct.m in Sources */, 807AF4A61DC984950000A326 /* KWMDataProduct.m in Sources */,
80C8014F1D78134800002306 /* KWMTBVSectionHeardView.m in Sources */, 80C8014F1D78134800002306 /* KWMTBVSectionHeardView.m in Sources */,
C034E7C21D6B0B62006EE129 /* KWMMineVC.m in Sources */, C034E7C21D6B0B62006EE129 /* KWMMineVC.m in Sources */,
DA8D64121F31C67F00B8F4A6 /* DeepLinkURLProtocol.m in Sources */,
C08FDA271D9A5F3400EBDB0D /* KWMAddGiftCardVC.m in Sources */, C08FDA271D9A5F3400EBDB0D /* KWMAddGiftCardVC.m in Sources */,
C07267821F15D62400C5A869 /* NSLayoutConstraint+Multiplier.m in Sources */, C07267821F15D62400C5A869 /* NSLayoutConstraint+Multiplier.m in Sources */,
C02C7D9E1E643323008DC29C /* KWMShareVC.m in Sources */, C02C7D9E1E643323008DC29C /* KWMShareVC.m in Sources */,
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#import "KWMUserModel.h" #import "KWMUserModel.h"
#import <AlipaySDK/AlipaySDK.h> #import <AlipaySDK/AlipaySDK.h>
#import "AppDelegate+Deeplink.h" #import "AppDelegate+Deeplink.h"
#import "DeepLinkURLProtocol.h"
@interface AppDelegate () @interface AppDelegate ()
...@@ -70,7 +71,8 @@ ...@@ -70,7 +71,8 @@
isProduction = NO; isProduction = NO;
#endif #endif
// 注册DeepLinkURLProtocol 来实现App内H5跳转
[NSURLProtocol registerClass:[DeepLinkURLProtocol class]];
//首页还是引导页 //首页还是引导页
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstTime"]) { if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstTime"]) {
[self toGuide]; [self toGuide];
......
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
} }
- (void)registerRouter { - (void)registerRouter {
JLRoutes *routes = [JLRoutes routesForScheme:@"cemarose"]; // JLRoutes *routes = [JLRoutes routesForScheme:@"cemarose"];
JLRoutes *routes = [JLRoutes globalRoutes];
[routes addRoute:@"/collections/:handle/*" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) { [routes addRoute:@"/collections/:handle/*" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
NSArray *tags = parameters[JLRouteWildcardComponentsKey]; NSArray *tags = parameters[JLRouteWildcardComponentsKey];
NSString *handle = parameters[@"handle"]; NSString *handle = parameters[@"handle"];
......
...@@ -9,8 +9,10 @@ ...@@ -9,8 +9,10 @@
#import "UIViewController+HTTP.h" #import "UIViewController+HTTP.h"
#import <JLRoutes/JLRoutes.h> #import <JLRoutes/JLRoutes.h>
#import <RegexKitLite/RegexKitLite.h> #import <RegexKitLite/RegexKitLite.h>
#import <TOWebViewController/TOWebViewController.h> //#import <TOWebViewController/TOWebViewController.h>
#import "DPWebViewController.h"
#import "AppDelegate.h" #import "AppDelegate.h"
#import "KWMWebViewVC.h"
@implementation UIViewController (HTTP) @implementation UIViewController (HTTP)
...@@ -23,14 +25,16 @@ ...@@ -23,14 +25,16 @@
NSTextCheckingResult *tcr=matchs[i]; NSTextCheckingResult *tcr=matchs[i];
encodeURL=[encodeURL stringByReplacingCharactersInRange:tcr.range withString:[[encodeURL substringWithRange:tcr.range] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; encodeURL=[encodeURL stringByReplacingCharactersInRange:tcr.range withString:[[encodeURL substringWithRange:tcr.range] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
} }
NSURL *url = [[NSURL alloc] initWithString:[encodeURL stringByReplacingOccurrencesOfRegex:@"^https?" withString:@"cemarose"]]; // NSURL *url = [[NSURL alloc] initWithString:[encodeURL stringByReplacingOccurrencesOfRegex:@"^https?" withString:@"cemarose"]];
NSURL *url = [[NSURL alloc] initWithString:URLString];
if ([JLRoutes canRouteURL:url]) { if ([JLRoutes canRouteURL:url]) {
[JLRoutes routeURL:url]; [JLRoutes routeURL:url];
// }else if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) { // }else if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) {
// [application openURL:[NSURL URLWithString:URLString] options:@{} completionHandler:nil]; // [application openURL:[NSURL URLWithString:URLString] options:@{} completionHandler:nil];
} else { } else {
// [application openURL:[NSURL URLWithString:URLString]]; // [application openURL:[NSURL URLWithString:URLString]];
TOWebViewController *wv = [[TOWebViewController alloc] initWithURLString:URLString]; TOWebViewController *wv = [[DPWebViewController alloc] initWithURLString:URLString];
wv.hidesBottomBarWhenPushed = YES;
[[AppDelegate mainViewController].selectedViewController pushViewController:wv animated:YES]; [[AppDelegate mainViewController].selectedViewController pushViewController:wv animated:YES];
} }
} }
......
//
// DeepLinkURLProtocol.h
// iCemarose
//
// Created by Sanchew on 2017/8/2.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface DeepLinkURLProtocol : NSURLProtocol
@end
//
// DeepLinkURLProtocol.m
// iCemarose
//
// Created by Sanchew on 2017/8/2.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "DeepLinkURLProtocol.h"
#import <JLRoutes/JLRoutes.h>
@implementation DeepLinkURLProtocol
+ (BOOL)canInitWithRequest:(NSURLRequest *)request {
if ([JLRoutes canRouteURL:request.URL]) {
return YES;
}
return NO;
}
+ (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request {
return request;
}
- (void)startLoading {
[JLRoutes routeURL:self.request.URL];
}
-(void)stopLoading {
}
@end
//
// DPWebViewController.h
// iCemarose
//
// Created by Sanchew on 2017/8/2.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <TOWebViewController/TOWebViewController.h>
@interface DPWebViewController : TOWebViewController
@end
//
// DPWebViewController.m
// iCemarose
//
// Created by Sanchew on 2017/8/2.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "DPWebViewController.h"
@interface DPWebViewController ()
@end
@implementation DPWebViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationButtonsHidden = YES;
// Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO];
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment