mdsb100 / YTXModule

YTXModule supports widget communication with URL and register application life by easy way.This is an easy and important library for widgetify.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

YTXModule

Example

In .m

YTXMODULE_EXTERN()
{
    //This is load
    isLoad = YES;
}

//check userInfo/completion should be nil

YTXMODULE_EXTERN_ROUTER_METHOD(@"URL")
{
    YTXMODULE_EXAPAND_PARAMETERS(parameters)
    NSLog(@"%@ %@", userInfo, completion);
    isCallRouterMacro1 = YES;
    completionExits = completion;
    userInfoExits = userInfo;
    completion(@"Success");
}

YTXMODULE_EXTERN_ROUTER_OBJECT_METHOD(@"object")
{
    YTXMODULE_EXAPAND_PARAMETERS(parameters)
    NSLog(@"%@ %@", userInfo, completion);
    isCallRouterObjectMacro1 = YES;
    completionExits1 = completion;
    userInfoExits1 = userInfo;
    return @"我是个类型";
}

YTXMODULE_EXTERN_ROUTER_METHOD(@"YTX://QUERY/:query")
{
    YTXMODULE_EXAPAND_PARAMETERS(parameters)
    NSLog(@"%@ %@", userInfo, completion);
    
    testQueryStringQueryValue = parameters[@"query"];;
    testQueryStringNameValue = parameters[@"name"];
    testQueryStringAgeValue = parameters[@"age"];
}

other .m

[YTXModule openURL:@"URL" withUserInfo:@{@"Test":@1} completion:^(id result) {
    NSLog(@"completion:%@", result);
}];

NSString * testObject1 = [YTXModule objectForURL:@"object" withUserInfo:@{@"Test":@1}];

[YTXModule openURL:@"YTX://QUERY/query?age=18&name=CJ"];

Application life. Support all application life.

YTXMODULE_EXTERN()
{
    
}
+ (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions
{
    applicationLifCycle1 = YES;
    [YTXModule registerURLPattern:@"YTX://Test/targetSelector" withTarget:self withSelector:@selector(testRegisterTargetSelector)];
    testRegisterTargetSelector = [YTXModule objectForURL:@"YTX://Test/targetSelector"];
    return YES;
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [YTXModule registerAppDelegateObject:self];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [YTXModule unregisterAppDelegateObject:self];
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    NSLog(@"Receive BecomeActive");
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    NSLog(@"Receive ResignActive");
}

More infomation, please check test case

Requirements

Installation

YTXModule is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "YTXModule"

Author

caojun, 78612846@qq.com

License

YTXModule is available under the MIT license. See the LICENSE file for more info.

About

YTXModule supports widget communication with URL and register application life by easy way.This is an easy and important library for widgetify.

License:MIT License


Languages

Language:Objective-C 94.2%Language:Shell 3.2%Language:Ruby 2.6%