Latest 1.0.0
Homepage https://github.com/jacoli/FMUrlRouter
License MIT
Platforms ios 7.0, requires ARC
Frameworks Foundation, UIKit
Authors

Version
License
Platform
Platform

  • A simple way to manage page route of native or h5. 页面统一跳转管理器

Installation

With CocoaPods, add this line to your Podfile.

pod 'FMUrlRouter'

and run pod install, then you’re all done!

Or copy *.h *.m files in FMUrlRouter folder to your project.

How to use

  • Setup

Setup in AppDelegate

    #define URL_ROUTER_LOCAL_SCHEME (@"fanmei")

    [[UrlRouter sharedInstance] startupWithNavController:(UINavigationController *)rootVC
                                        webContainerClass:FMWebViewController.class
                                            nativeUrlScheme:URL_ROUTER_LOCAL_SCHEME];

Setup in UIViewController subclass

+ (void)load {
    [UrlRouter registerPage:self.pageName forViewControllerClass:self.class];
}

+ (NSString *)pageName {
    return @"about_us";
}
  • Use

Open native page

    [UrlRouter openPage:@"about_us"];

Open page with callback

    WS(weakSelf)
    [UrlRouter openPage:@"comments_list" withParams:@{@"_id":self.activityId} withCallback:^(NSDictionary *userInfo) {
        [weakSelf getComments];
    }];

Open native url

        NSString *query = @"placeName=江户前寿司(黄龙店)&placeAddr=曙光路49号(至尊鲨鱼边)&placeLocation=120.14334,30.26593";
    query = [query stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    NSString *urlStr = [NSString stringWithFormat:@"fanmei://detail_address?%@", query];
    [UrlRouter openUrl:[NSURL URLWithString:urlStr]];

Open url

    NSString *url = "https://github.com/jacoli/FMUrlRouter";
    [UrlRouter openUrl:[NSURL URLWithString:url]];

Requirements

  • iOS 7.0+
  • ARC

Latest podspec

{
    "name": "FMUrlRouter",
    "version": "1.0.0",
    "summary": "A simple way to manage page route of native or h5.",
    "homepage": "https://github.com/jacoli/FMUrlRouter",
    "license": "MIT",
    "authors": {
        "jacoli": "[email protected]"
    },
    "source": {
        "git": "https://github.com/jacoli/FMUrlRouter.git",
        "tag": "1.0.0"
    },
    "frameworks": [
        "Foundation",
        "UIKit"
    ],
    "platforms": {
        "ios": "7.0"
    },
    "source_files": "FMUrlRouter/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This