forked from github/jpush-phonegap-plugin
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2818fb193 | ||
|
|
32d3ecc917 | ||
|
|
f54252dd4f | ||
|
|
96c27448a0 | ||
|
|
2211e68e68 | ||
|
|
6a74a1697b | ||
|
|
a2c311730d | ||
|
|
f624670b4f |
46
README.md
46
README.md
@@ -28,6 +28,9 @@ l## JPush PhoneGap Plugin ##
|
||||
|
||||
<meta-data android:name="JPUSH_APPKEY" android:value="your appkey"/>
|
||||
|
||||
4. 打开`$JPUSH_PLUGIN_DIR/src/ios/PushConfig.plist`文件将文件中的`7d431e42dfa6a6d693ac2d04`替换为在Portal上注册该应用的的Key,例如(9fed5bcb7b9b87413678c407)
|
||||
|
||||
|
||||
5. 在`$JPUSH_PLUGIN_DIR/src/android/JPushPlugin.java` 文件`import your.package.name.R`替换为在Portal上注册该应用的包名,例如(com.thi.pushtest)
|
||||
|
||||
|
||||
@@ -35,49 +38,6 @@ l## JPush PhoneGap Plugin ##
|
||||
|
||||
cordova plugin add $JPUSH_PLUGIN_DIR
|
||||
cordova plugin add org.apache.cordova.device
|
||||
|
||||
7. iOS添加初始化JPush sdk代码 如果你要先部署android平台,可以先忽略这一步,当需要iOS 平台时,只加上这个步骤即可
|
||||
|
||||
+ 用xcode 打开 Myproj下的iOS工程
|
||||
+ 打开xcode右边工程目录下`Resources/PushConfig.plist`
|
||||
|
||||
在APP_KEY和CHANNLE字段 分别添加您的appkey和channle
|
||||
|
||||
+ 打开xcode右边工程目录下`AppDelegate.m`,包含以下头文件
|
||||
|
||||
#import "APService.h"
|
||||
#import "JPushPlugin.h"
|
||||
|
||||
+ 在AppDelegate.m文件中,添加JPush SDK 提供的 API 来实现功能
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
|
||||
//原内容保持不变
|
||||
//Required add
|
||||
[JPushPlugin setLaunchOptions:launchOptions];
|
||||
return YES;
|
||||
}
|
||||
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
||||
//原内容保持不变
|
||||
// Required add
|
||||
[APService registerDeviceToken:deviceToken];
|
||||
}
|
||||
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
|
||||
//原内容保持不变
|
||||
// Required
|
||||
[APService handleRemoteNotification:userInfo];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginReceiveNotification
|
||||
object:userInfo];
|
||||
}
|
||||
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
||||
|
||||
// IOS 7 Support Required
|
||||
[APService handleRemoteNotification:userInfo];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginReceiveNotification
|
||||
object:userInfo];
|
||||
|
||||
completionHandler(UIBackgroundFetchResultNewData);
|
||||
}
|
||||
|
||||
|
||||
7. 在js中调用函数,初始化jpush sdk
|
||||
|
||||
|
||||
14
plugin.xml
14
plugin.xml
@@ -29,10 +29,10 @@
|
||||
<source-file src="src/ios/Plugins/JPushPlugin.m"/>
|
||||
|
||||
<header-file src="src/ios/lib/APService.h" />
|
||||
<source-file src="src/ios/lib/libPushSDK-1.8.3.a" framework="true" />
|
||||
|
||||
<source-file src="src/ios/lib/libPushSDK-1.8.8.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" />
|
||||
@@ -154,10 +154,10 @@
|
||||
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
|
||||
<meta-data android:name="JPUSH_APPKEY" android:value="your appkey"/>
|
||||
</config-file>
|
||||
<source-file src="src/android/jpush-sdk-release1.7.5.jar" target-dir="libs"/>
|
||||
<source-file src="src/android/armeabi/libjpush175.so" target-dir="libs/armeabi"/>
|
||||
<source-file src="src/android/armeabi-v7a/libjpush175.so" target-dir="libs/armeabi-v7a"/>
|
||||
<source-file src="src/android/arm64-v8a/libjpush175.so" target-dir="libs/arm64-v8a"/>
|
||||
<source-file src="src/android/jpush-android-2.0.5.jar" target-dir="libs"/>
|
||||
<source-file src="src/android/armeabi/libjpush205.so" target-dir="libs/armeabi"/>
|
||||
<source-file src="src/android/armeabi-v7a/libjpush205.so" target-dir="libs/armeabi-v7a"/>
|
||||
<source-file src="src/android/arm64-v8a/libjpush205.so" target-dir="libs/arm64-v8a"/>
|
||||
|
||||
<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jpush/phonegap"/>
|
||||
<source-file src="src/android/MyReceiver.java" target-dir="src/cn/jpush/phonegap"/>
|
||||
|
||||
@@ -18,7 +18,7 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
|
||||
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
|
||||
|
||||
}else if (JPushInterface.ACTION_UNREGISTER.equals(intent.getAction())){
|
||||
// }else if (JPushInterface.ACTION_UNREGISTER.equals(intent.getAction())){
|
||||
|
||||
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
|
||||
handlingReceivedMessage(intent);
|
||||
|
||||
Binary file not shown.
BIN
src/android/arm64-v8a/libjpush205.so
Executable file
BIN
src/android/arm64-v8a/libjpush205.so
Executable file
Binary file not shown.
BIN
src/android/armeabi-v7a/libjpush175.so → src/android/armeabi-v7a/libjpush205.so
Normal file → Executable file
BIN
src/android/armeabi-v7a/libjpush175.so → src/android/armeabi-v7a/libjpush205.so
Normal file → Executable file
Binary file not shown.
BIN
src/android/armeabi/libjpush175.so → src/android/armeabi/libjpush205.so
Normal file → Executable file
BIN
src/android/armeabi/libjpush175.so → src/android/armeabi/libjpush205.so
Normal file → Executable file
Binary file not shown.
BIN
src/android/jpush-android-2.0.5.jar
Executable file
BIN
src/android/jpush-android-2.0.5.jar
Executable file
Binary file not shown.
Binary file not shown.
15
src/ios/Plugins/AppDelegate+JPush.h
Normal file
15
src/ios/Plugins/AppDelegate+JPush.h
Normal 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
|
||||
74
src/ios/Plugins/AppDelegate+JPush.m
Normal file
74
src/ios/Plugins/AppDelegate+JPush.m
Normal 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_getInstanceMethod([self class],@selector(init));
|
||||
swizzle=class_getInstanceMethod([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
|
||||
@@ -109,9 +109,9 @@ static NSDictionary *_luanchOptions=nil;
|
||||
|
||||
NSNumber *result;
|
||||
if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications ]) {
|
||||
result=@(1);
|
||||
}else{
|
||||
result=@(0);
|
||||
}else{
|
||||
result=@(1);
|
||||
}
|
||||
CDVPluginResult * pushResult=[self pluginResultForValue:result];
|
||||
if (pushResult) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// Created by JPush on 12-8-15.
|
||||
// Copyright (c) 2012年 HXHG. All rights reserved.
|
||||
// Version: 1.8.3
|
||||
// Version: 1.8.8
|
||||
|
||||
@class CLRegion;
|
||||
@class UILocalNotification;
|
||||
|
||||
Binary file not shown.
BIN
src/ios/lib/libPushSDK-1.8.8.a
Normal file
BIN
src/ios/lib/libPushSDK-1.8.8.a
Normal file
Binary file not shown.
Reference in New Issue
Block a user