Some third-party SDK in development will BundleID do check.
For example, if the high moral map BundleID not registered will not be able to obtain the latitude and longitude and reverse geocoding.
For example biometric SDK can not use their turn biometric authentication.
But BundleID package of testing due to some limitations or restrictions can not use the Certificates registered in BundleID pack, how to do it.
1, find BundleID third party sdk is obtained by a method which system
比如我们的是 NSBundle 的 bundleIdentifier 属性
2. The first step is to find a method by which a third party sdk method call
比如我们的是第三方SDK初始化的时候 [ShengWuSDK getInstanceShengWu];
3, before and after the call to the second step of the method are tagged, to return the correct BundleID and returns the actual BundleID
Global_Variables.isNeedHook = YES;
[ShengWuSDK getInstanceShengWu];
Global_Variables.isNeedHook = NO;
4 Add categories alternative method bundleIdentifier NSBundle
.h
#import <Foundation/Foundation.h>
@interface NSBundle (swizz)
@end
.m
#import "NSBundle+swizz.h"
@implementation NSBundle (swizz)
+ (void)load{
Method originalMethod = class_getInstanceMethod([NSBundle class], @selector(bundleIdentifierSw));
Method swizzledMethod = class_getInstanceMethod([NSBundle class], @selector(bundleIdentifier));
method_exchangeImplementations(originalMethod, swizzledMethod);
}
- (NSString *)bundleIdentifierSw{
if (GlobalVariables.isNeedHook == YES) {
return @"注册过的";
}else{
return [self bundleIdentifierSw];
}
}
@end
ok