mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-01-18 21:12:56 +08:00
iOS-优化代码
1.AppDelegate+JPush.m中不再使用runtime
This commit is contained in:
parent
a9f5fc45bd
commit
c2babc3a39
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user