Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to specify app page jump in html5

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

In this article Xiaobian for you to introduce in detail "how to specify app page jump in html5", the content is detailed, the steps are clear, the details are handled properly, I hope this "how to specify app page jump in html5" article can help you solve your doubts, the following follows the editor's ideas slowly in depth, together to learn new knowledge.

1. Set up urlschemes

Urlschemes tries to set a unique string, for example, it can be set to: iOS+ company English name + project project name

For example, if I set mine to iOSTencentTest, enter the address iOSTencentTest:// in the browser and then jump to my app.

two。 Jump to the specified page

When opening app with iOSTencentTest://, the proxy method of AppDelegate is called:

-(BOOL) application: (UIApplication *) app openURL: (NSURL *) url options: (NSDictionary *) options

Jump to specify the page to operate in this method

Parameters can be added after iOSTencentTest://, such as iOSTencentTest://goodsDetails?id=xxxxx

GoodsDetails can be obtained directly through url.host

Id=xxxxx parameters can be obtained directly through url.query

You can set different host and parameters according to your own needs.

H6 only needs to execute:

_ window.location.href = 'iOSTencentTest://goodsDetails?id=xxxxx'

Attached:

/ / get the ViewController- (UIViewController*) currentViewController currently displayed by Window {/ / get the root view of the current active window UIViewController* vc = [UIApplication sharedApplication] .keyWindow.rootViewController; while (1) {/ / according to different page switching methods, gradually obtain the top viewController if ([vc isKindOfClass: [UITabBarController class]]) {vc = ((UITabBarController*) vc) .selectedViewController } if ([vc isKindOfClass: [UINavigationController class]]) {vc = ((UINavigationController*) vc) .visibleViewController;} if (vc.presentedViewController) {vc = vc.presentedViewController;} else {break;}} return vc } / / NSString category method / / obtain parameter characters through url.query and divide them into dictionaries-(NSMutableDictionary *) getURLParameters {if (! self.length) {return nil;} NSMutableDictionary * params = [NSMutableDictionary dictionary]; if ([self containsString:@ "&"]) {NSArray * urlComponents = [self componentsSeparatedByString:@ "&"] For (NSString* keyValuePair in urlComponents) {/ / generate key/value NSArray * pairComponents = [keyValuePair componentsSeparatedByString:@ "="]; NSString* key= [pairComponents.firstObject stringByRemovingPercentEncoding]; NSString*value = [pairComponents.lastObject stringByRemovingPercentEncoding]; / / key cannot be nil if (key==nil | | value = = nil) continue; id existValue = [params valueForKey:key] If (existValue! = nil) {/ / existing values to generate an array. If ([existValue isKindOfClass: [NSArray class]]) {/ / the existing value generation array NSMutableArray*items = [NSMutableArray arrayWithArray:existValue]; [items addObject:value]; [params setValue:items forKey:key] } else {/ / non-array [params setValue:@ [existValue,value] forKey:key];}} else {/ / set value [params setValue:value forKey:key] } else {/ / single parameter generation key/value NSArray * pairComponents = [self componentsSeparatedByString:@ "="]; if (pairComponents.count==1) {return nil;} / / delimited value NSString * key = [pairComponents.firstObject stringByRemovingPercentEncoding]; NSString * value = [pairComponents.lastObject stringByRemovingPercentEncoding] / / key cannot be nil if (key = = nil | | value = = nil) return nil; / / set the value [params setValue:value forKey:key];} return params } after reading this, the article "how to specify app Page Jump in html5" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report