iOS 无嵌入埋点(页面统计)

记录自用

    [DYViewController aspect_hookSelector:@selector(viewDidAppear:)
                              withOptions:AspectPositionAfter
                               usingBlock:^(id info){
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            NSArray *pageArray = [self page];
            for (NSDictionary *dict in pageArray) {
                BOOL isSwitch = [dict jk_boolForKey:@"switch"];
                if (!isSwitch) {
                    return;
                }
                NSString *className = [dict jk_stringForKey:@"className"];
                NSString *pageName = [dict jk_stringForKey:@"pageName"];
                if ([className isEqualToString:[info.instance className]]) {
                    NSLog(@"[统计]-viewDidAppear:%@", pageName);
                    [MobClick beginLogPageView:pageName];
                }
            }
        });
    }
                                    error:NULL];

    [DYViewController aspect_hookSelector:@selector(viewDidDisappear:)
                              withOptions:AspectPositionAfter
                               usingBlock:^(id info) {
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            NSArray *pageArray = [self page];
            for (NSDictionary *dict in pageArray) {
                BOOL isSwitch = [dict jk_boolForKey:@"switch"];
                if (!isSwitch) {
                    return;
                }
                NSString *className = [dict jk_stringForKey:@"className"];
                NSString *pageName = [dict jk_stringForKey:@"pageName"];
                if ([className isEqualToString:[info.instance className]]) {
                    NSLog(@"[统计]-viewDidDisappear:%@", pageName);
                    [MobClick endLogPageView:pageName];
                }
            }
        });
    }
                                    error:NULL];

你可能感兴趣的:(iOS 无嵌入埋点(页面统计))