This commit is contained in:
zhangqinghe 2015-08-03 13:34:36 +08:00
parent 5ade8c3300
commit f624670b4f
3 changed files with 91 additions and 2 deletions

View File

@ -30,9 +30,9 @@
<header-file src="src/ios/lib/APService.h" />
<source-file src="src/ios/lib/libPushSDK-1.8.3.a" framework="true" />
<header-file src="src/ios/Plugins/AppDelegate+JPush.h"/>
<source-file src="src/ios/Plugins/AppDelegate+JPush.m"/>
<resource-file src="src/ios/PushConfig.plist" />
<framework src="CFNetwork.framework" weak="true" />
<framework src="CoreFoundation.framework" weak="true" />
<framework src="CoreTelephony.framework" weak="true" />

View File

@ -0,0 +1,15 @@
//
// AppDelegate+JPush.h
// delegateExtention
//
// Created by 张庆贺 on 15/8/3.
// Copyright (c) 2015年 JPush. All rights reserved.
//
#import "AppDelegate.h"
@interface AppDelegate (JPush)
//@property(nonatomic,strong)NSDictionary *luanchOption;
@end

View File

@ -0,0 +1,74 @@
//
// AppDelegate+JPush.m
// delegateExtention
//
// Created by on 15/8/3.
// Copyright (c) 2015 JPush. All rights reserved.
//
#import "AppDelegate+JPush.h"
#import <objc/runtime.h>
#import "JPushPlugin.h"
#import "APService.h"
static char launchNotificationKey;
@implementation AppDelegate (JPush)
+(void)load{
Method origin;
Method swizzle;
origin=class_getClassMethod([self class],@selector(init));
swizzle=class_getClassMethod([self class], @selector(init_plus));
method_exchangeImplementations(origin, swizzle);
}
-(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];
}
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[APService registerDeviceToken:deviceToken];
}
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
[APService handleRemoteNotification:userInfo];
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginReceiveNotification
object:userInfo];
}
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
[APService handleRemoteNotification:userInfo];
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginReceiveNotification
object:userInfo];
}
//delegate
//-(NSDictionary *)luanchOption{
// return objc_getAssociatedObject(self, &launchNotificationKey);
//}
//-(void)setLuanchOption:(NSDictionary *)luanchOption{
// objc_setAssociatedObject(self, &launchNotificationKey, luanchOption, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
//}
//-(void)dealloc{
// self.luanchOption=nil;
//}
@end