关于iOS15.7 iOS16.0 [SKStoreProductViewController sceneDisconnected:]崩溃问题

1.点击广告,打开app stroe下载页面,杀死app触发
2.加载或者展示出广告,杀死app也可能触发

解决办法:写个类别,弄个钩子

#import "SKStoreProductViewController+CSJAd.h"
#import 


@implementation SKStoreProductViewController (CSJAd)

+ (void)load {
    NSString *selName = @"";
    SEL sel;
    
    selName = @"sceneDisconnected:";
    sel = NSSelectorFromString(selName);
    Method method1 = class_getInstanceMethod([self class], sel);
    if (method1 == nil) {
        class_addMethod([self class], sel, (IMP)csj_custom_sceneDisconnected, "v@:@");
    }
    
    selName = @"appWillTerminate";
    sel = NSSelectorFromString(selName);
    Method method2 = class_getInstanceMethod([self class], sel);
    if (method2 == nil) {
        class_addMethod([self class], sel, (IMP)csj_custom_appWillTerminate, "v@");
    }
}

void csj_custom_sceneDisconnected(id self, SEL _cmd, id params) {
    // DoNothing
}

void csj_custom_appWillTerminate(id self, SEL _cmd) {
    // DoNothing
}

@end

你可能感兴趣的:(关于iOS15.7 iOS16.0 [SKStoreProductViewController sceneDisconnected:]崩溃问题)