ytx

YTXModule

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

Showing:

Popularity

Downloads/wk

0

GitHub Stars

73

Maintenance

Last Commit

3yrs ago

Contributors

8

Package

Dependencies

0

License

MIT

Categories

Readme

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.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100