iOS逆向:去除【系统更新】的弹窗

2021-01-11  本文已影响0人  风ai翔

背景:

主要逻辑:

缺陷:

扩展:

/// Tweak.xm

#import <UIKit/UIKit.h>

@interface LincMethodList

- (id)title;
- (id)cancelAction;
- (id)actions;
- (id)firstObject;
- (void)_setHidden:(BOOL)arg1;
- (id)currentIsNeedHookAlert;

@end

%hook _SBAlertController

%new
- (id)currentIsNeedHookAlert
{
    id vc = self;
    id action = [vc cancelAction];
    if (action == nil) {
        action = [[vc actions] firstObject];
    }

    if (action && [[vc title] isKindOfClass:%c(NSString)] && [[vc title] isEqualToString:@"\xe8\xbd\xaf\xe4\xbb\xb6\xe6\x9b\xb4\xe6\x96\xb0"]) {
        return action;
    }

    return nil;
}

/// 将要出现到屏幕上时,将它隐藏
/// 这里如果放到viewDidAppear,还是能看到这个Alert
- (void)viewWillAppear:(BOOL)arg1
{
    %orig;

    id vc = self;
    if ([vc currentIsNeedHookAlert]) {
        [vc _setHidden:YES];
    }
}

/// 已经出现到屏幕上后,触发它的cancelAction的block,系统会将该Alert移除
/// 为什么不放在viewWillAppear:
/// 如果遇到需要同时弹出多个Alert这种场景,系统会维护一个Alert队列,只有用户点击了前一个Alert 下一个Alert的viewDidAppear才会触发,但是,每个Alert的viewWillAppear却在加入队列时就已经触发了。
- (void)viewDidAppear:(BOOL)arg1
{
    %orig;

    id vc = self;
    id action = [vc currentIsNeedHookAlert];
    if (action && [vc respondsToSelector:@selector(_dismissAnimated:triggeringAction:)]) {
        [vc performSelector:@selector(_dismissAnimated:triggeringAction:) withObject:@(NO) withObject:action];
    }
}

%end

/// 顺便去除一下所有推送的数字角标
%hook SBIconParallaxBadgeView

- (id)init
{
    return nil;
}

%end

上一篇下一篇

猜你喜欢

热点阅读