by GeniusBrother

GeniusBrother / HZURLManager

URL routing library for iOS, support URL rewrite.

126 Stars 15 Forks Last release: Not found MIT License 32 Commits 3 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


License MIT  CocoaPods  CocoaPods  Support 

URL routing library for iOS, support URL rewrite.
(It's a component of HZExtend)


QQ Group:32272635

Email:[email protected]





  1. Add
    pod 'HZURLManager
    to your Podfile.
  2. Run
    pod install
    pod update
  3. Import <HZURLManager/HZURLManager.h>.


Full API documentation is available on CocoaDocs.


This library requires

iOS 8.0+
Xcode 8.0+


HZURLManager is provided under the MIT license. See LICENSE file for details.


URL Config

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

 //Loads URL-Controller &amp; URL-Method Config.
[[HZURLManagerConfig sharedConfig] loadURLCtrlConfig:[[NSBundle mainBundle] pathForResource:@"URL-Controller-Config" ofType:@"plist"] urlMethodConfig:[[NSBundle mainBundle] pathForResource:@"URL-Method-Config" ofType:@"plist"]];

//Adds URL Rewrite rule. You may be get the rule from remote.
  The variable can be used in the target and starts with $, For example, $1 ... $n represents the value of the corresponding tuple in the regular expression, $query represents the query string part in the URL. 

  For example, when the @{@"match":@"(?:https://)?www.hz.com/articles/(\\d)\\?(.*)",@"target":@"hz://page.hz/article?$query&amp;id=$1"} rule is applied, the rewrite engine rewrites the source URL as hz://page.hz/article?title=cool&amp;id=3 when we redirect to https://ww.hz.com/articles/3?title=cool , Finally we'll jump to hz://page.hz/article?title=cool&amp;id=3.
[[HZURLManagerConfig sharedConfig] addRewriteRules:@[@{@"match":@"(?:https://)?www.hz.com/articles/(\\d)\\?(.*)",@"target":@"hz://page.hz/article?$query&amp;id=$1"}]];

//Configs the default name of controller for Http(s) URL.
[HZURLManagerConfig sharedConfig].classOfWebViewCtrl = @"WebViewController";                                        



[URL_MANAGERN redirectToURL:@"hz://page.hz/article?title=present" animated:YES parmas:nil options:@{HZRedirectPresentMode:@(YES)} completion:nil];

//Push //The following URL will be converted to hz://page.hz/article by rewriting. [URL_MANAGERN redirectToURL:@"https://www.hz.com/articles/3?title=push" animated:YES];

Executes Method

@interface ShowAlertURLHandler ()
@implementation ShowAlertURLHandler

@param title @param message */

  • (id)handleURL:(NSURL *)url withParams:(id)params { NSDictionary *queryParam = url.queryDic;

    NSString *title = [queryParam objectForKey:@"title"]; NSString *message = [queryParam objectForKey:@"message"];

    UIAlertController *alerController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *confirmAtion = [UIAlertAction actionWithTitle:@"Confirm" style:UIAlertActionStyleDefault handler:nil]; [alerController addAction:confirmAtion]; UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"Cancle" style:UIAlertActionStyleCancel handler:nil]; [alerController addAction:cancleAction]; [[HZURLNavigation currentViewController] presentViewController:alerController animated:YES completion:nil];

    return nil; }


//show the alert [URL_MANAGERN handleURL:@"hz://urlmanger.kit/doAlert?title=alert&message=URL-showAlert" withParams:nil];


//Creates Controller
UIViewController *controller = [UIViewController viewControllerForURL:[NSURL URLWithString:@"hz://page.hz/article"]];

//Gets current Controller UIViewController *currentViewCtrl = [HZURLNavigation currentViewController];

//Gets current Navigation Controller UIViewController *currentNavViewCtrl = [HZURLNavigation currentNavigationViewController];

//Dismiss(Pop or dissmiss) View Controller [HZURLNavigation dismissCurrentAnimated:YES];


@interface UIViewController (HZURLManager)

/** The URL corresponding to the Controller */ @property(nonatomic, strong, readonly) NSString *originURL;

/** Consists of a query string and additional parameters passed by user. */ @property(nonatomic, strong, readonly) NSDictionary *params;


We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.