mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-15 08:42:49 +08:00
commit
001ce88d2a
@ -16,11 +16,32 @@
|
|||||||
@implementation AppDelegate (JPush)
|
@implementation AppDelegate (JPush)
|
||||||
|
|
||||||
+(void)load{
|
+(void)load{
|
||||||
Method origin1;
|
|
||||||
Method swizzle1;
|
static dispatch_once_t onceToken;
|
||||||
origin1 = class_getInstanceMethod([self class],@selector(init));
|
dispatch_once(&onceToken, ^{
|
||||||
swizzle1 = class_getInstanceMethod([self class], @selector(init_plus));
|
Class class = [self class];
|
||||||
method_exchangeImplementations(origin1, swizzle1);
|
|
||||||
|
SEL originalSelector = @selector(init);
|
||||||
|
SEL swizzledSelector = @selector(init_plus);
|
||||||
|
|
||||||
|
Method origin = class_getInstanceMethod(class, originalSelector);
|
||||||
|
Method swizzle = class_getInstanceMethod(class, swizzledSelector);
|
||||||
|
|
||||||
|
BOOL didAddMethod =
|
||||||
|
class_addMethod(class,
|
||||||
|
originalSelector,
|
||||||
|
method_getImplementation(swizzle),
|
||||||
|
method_getTypeEncoding(swizzle));
|
||||||
|
|
||||||
|
if (didAddMethod) {
|
||||||
|
class_replaceMethod(class,
|
||||||
|
swizzledSelector,
|
||||||
|
method_getImplementation(origin),
|
||||||
|
method_getTypeEncoding(origin));
|
||||||
|
} else {
|
||||||
|
method_exchangeImplementations(origin, swizzle);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
-(instancetype)init_plus{
|
-(instancetype)init_plus{
|
||||||
|
Loading…
Reference in New Issue
Block a user