iOS-优化代码

1.AppDelegate+JPush.m中不再使用runtime
This commit is contained in:
E.B 2016-03-21 15:30:16 +08:00
parent a9f5fc45bd
commit c2babc3a39

View File

@ -9,30 +9,20 @@
#import "AppDelegate+JPush.h"
#import "JPushPlugin.h"
#import "JPUSHService.h"
#import <objc/runtime.h>
@implementation AppDelegate (JPush)
+(void)load{
Method origin;
Method swizzle;
origin=class_getInstanceMethod([self class],@selector(init));
swizzle=class_getInstanceMethod([self class], @selector(init_plus));
method_exchangeImplementations(origin, swizzle);
}
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[JPushPlugin setLaunchOptions:launchOptions];
-(instancetype)init_plus{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidLaunch:)
name:@"UIApplicationDidFinishLaunchingNotification"
object:nil];
return [self init_plus];
}
-(void)applicationDidLaunch:(NSNotification*)notification{
if (notification) {
[JPushPlugin setLaunchOptions:notification.userInfo];
}
//cordova didFinishLaunchingWithOptions
CGRect screenBounds = [[UIScreen mainScreen] bounds];
self.window = [[UIWindow alloc] initWithFrame:screenBounds];
self.viewController = [[CDVViewController alloc] init];
self.window.rootViewController = self.viewController;
self.window.autoresizesSubviews = YES;
[self.window makeKeyAndVisible];
return YES;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {