mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-04-19 00:03:45 +08:00
Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7cb3e22e14 | |||
| a3ad96f786 | |||
| 42d64ca2f0 | |||
| 0af2f60dbb | |||
| 0da9f0ed26 | |||
| f3bc83d97b | |||
| 8b674bb777 | |||
| 181ab80dab | |||
| de59d7919b | |||
| 1102ad3a57 | |||
| a8e4060b4d | |||
| 3b234f3101 | |||
| 7c580b4eaf | |||
| af267eda94 | |||
| d93b35611b | |||
| d94ccfb8d8 | |||
| b24b7064ba | |||
| f12e7a35d0 | |||
| 37c1d308eb | |||
| c2818fb193 | |||
| 32d3ecc917 | |||
| 138fde1587 | |||
| f54252dd4f | |||
| 96c27448a0 | |||
| 2211e68e68 | |||
| 6a74a1697b | |||
| 3196aeff72 | |||
| ca2e52fe54 | |||
| a2c311730d | |||
| f624670b4f | |||
| 5ade8c3300 | |||
| c2f957acbe | |||
| b10bc7dbb4 | |||
| 126e54d5b1 | |||
| c826b0d94a | |||
| 79d0b5e037 | |||
| 5836cac41f | |||
| 8ea95cd5ef | |||
| ef339a1b96 | |||
| 0233a10906 | |||
| cb8f8412b4 |
@@ -19,71 +19,33 @@ l## JPush PhoneGap Plugin ##
|
|||||||
|
|
||||||
###Cordova CLI/Phonegap 安装 Android & iOS
|
###Cordova CLI/Phonegap 安装 Android & iOS
|
||||||
|
|
||||||
3. 使用git命令将jpush phonegap插件下载的本地,将这个目录标记为`$JPUSH_PLUGIN_DIR`
|
1). 安装JPush PhoneGap Plugin。 有两种方法。
|
||||||
|
|
||||||
|
方法一: 在线安装
|
||||||
|
|
||||||
|
cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git --variable API_KEY=your_jpush_appkey
|
||||||
|
|
||||||
|
方法二:下载到本地再安装
|
||||||
|
|
||||||
|
使用git命令将jpush phonegap插件下载的本地,将这个目录标记为`$JPUSH_PLUGIN_DIR`
|
||||||
|
|
||||||
|
|
||||||
git clone https://github.com/jpush/jpush-phonegap-plugin.git
|
git clone https://github.com/jpush/jpush-phonegap-plugin.git
|
||||||
|
cordova plugin add $JPUSH_PLUGIN_DIR --variable API_KEY=your_jpush_appkey
|
||||||
|
|
||||||
|
|
||||||
4. 将`$JPUSH_PLUGIN_DIR/plugin.xml`文件中的AppKey替换为在Portal上注册该应用的的Key,例如(9fed5bcb7b9b87413678c407)
|
|
||||||
|
|
||||||
<meta-data android:name="JPUSH_APPKEY" android:value="your appkey"/>
|
2). 安装org.apache.cordova.device
|
||||||
|
|
||||||
5. 在`$JPUSH_PLUGIN_DIR/src/android/JPushPlugin.java` 文件`import your.package.name.R`替换为在Portal上注册该应用的包名,例如(com.thi.pushtest)
|
|
||||||
|
|
||||||
|
|
||||||
6. cordova cli 添加jpush phonegap插件和依赖的device插件:
|
|
||||||
|
|
||||||
cordova plugin add $JPUSH_PLUGIN_DIR
|
|
||||||
cordova plugin add org.apache.cordova.device
|
cordova plugin add org.apache.cordova.device
|
||||||
|
|
||||||
7. iOS添加初始化JPush sdk代码 如果你要先部署android平台,可以先忽略这一步,当需要iOS 平台时,只加上这个步骤即可
|
|
||||||
|
|
||||||
+ 用xcode 打开 Myproj下的iOS工程
|
3). 在js中调用函数,初始化jpush sdk
|
||||||
+ 打开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
|
|
||||||
|
|
||||||
window.plugins.jPushPlugin.init();
|
window.plugins.jPushPlugin.init();
|
||||||
//由于phonegap插件采用了Lazy load的特性, 所以这里建议在js文件能执行的最开始就加
|
//由于phonegap插件采用了Lazy load的特性, 所以这里建议在js文件能执行的最开始就加
|
||||||
|
|
||||||
|
|
||||||
### Android 手工安装
|
### Android 手工安装
|
||||||
|
|
||||||
[Android 手工安装文档地址](document/Android_handle_install.md)
|
[Android 手工安装文档地址](document/Android_handle_install.md)
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ ps:点击通知后传递的json object 保存在window.plugins.jPushPlugin.ope
|
|||||||
|
|
||||||
var alertContent
|
var alertContent
|
||||||
if(device.platform == "Android"){
|
if(device.platform == "Android"){
|
||||||
alertContent=window.plugins.jPushPlugin.openNotification.alert;
|
alertContent=window.plugins.jPushPlugin.receiveNotification.alert;
|
||||||
}else{
|
}else{
|
||||||
alertContent = event.aps.alert;
|
alertContent = event.aps.alert;
|
||||||
}
|
}
|
||||||
@@ -351,7 +351,7 @@ ps:点击通知后传递的json object 保存在window.plugins.jPushPlugin.rec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ps:点击通知后传递的json object 保存在window.plugins.jPushPlugin.receiveNotification,直接访问即可,字段示例,根据实际推送情况,可能略有差别,请注意
|
ps:点击通知后传递的json object 保存在window.plugins.jPushPlugin.receiveMessage,直接访问即可,字段示例,根据实际推送情况,可能略有差别,请注意
|
||||||
|
|
||||||
+ android
|
+ android
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -54,13 +54,13 @@
|
|||||||
}
|
}
|
||||||
var onReceiveNotification = function(event){
|
var onReceiveNotification = function(event){
|
||||||
try{
|
try{
|
||||||
var alert
|
var alertContent
|
||||||
if(device.platform == "Android"){
|
if(device.platform == "Android"){
|
||||||
alert = window.plugins.jPushPlugin.receiveNotification.alert;
|
alertContent = window.plugins.jPushPlugin.receiveNotification.alert;
|
||||||
}else{
|
}else{
|
||||||
alert = event.aps.alert;
|
alertContent = event.aps.alert;
|
||||||
}
|
}
|
||||||
$("#notificationResult").html(alert);
|
$("#notificationResult").html(alertContent);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(exeption){
|
catch(exeption){
|
||||||
|
|||||||
+19
-10
@@ -10,12 +10,14 @@
|
|||||||
<keywords>JPush,push</keywords>
|
<keywords>JPush,push</keywords>
|
||||||
<license>Apache 2.0 License</license>
|
<license>Apache 2.0 License</license>
|
||||||
|
|
||||||
|
<preference name="API_KEY" />
|
||||||
|
|
||||||
<engines>
|
<engines>
|
||||||
<engine name="cordova" version=">=3.0"/>
|
<engine name="cordova" version=">=3.0"/>
|
||||||
</engines>
|
</engines>
|
||||||
|
|
||||||
<js-module src="www/JPushPlugin.js" name="JPushPlugin">
|
<js-module src="www/JPushPlugin.js" name="JPushPlugin">
|
||||||
<clobbers target="window.plugins.jPushPlugin"/>
|
<clobbers target="jPushPlugin"/>
|
||||||
</js-module>
|
</js-module>
|
||||||
|
|
||||||
<platform name="ios">
|
<platform name="ios">
|
||||||
@@ -29,10 +31,10 @@
|
|||||||
<source-file src="src/ios/Plugins/JPushPlugin.m"/>
|
<source-file src="src/ios/Plugins/JPushPlugin.m"/>
|
||||||
|
|
||||||
<header-file src="src/ios/lib/APService.h" />
|
<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" />
|
<resource-file src="src/ios/PushConfig.plist" />
|
||||||
|
|
||||||
<framework src="CFNetwork.framework" weak="true" />
|
<framework src="CFNetwork.framework" weak="true" />
|
||||||
<framework src="CoreFoundation.framework" weak="true" />
|
<framework src="CoreFoundation.framework" weak="true" />
|
||||||
<framework src="CoreTelephony.framework" weak="true" />
|
<framework src="CoreTelephony.framework" weak="true" />
|
||||||
@@ -43,10 +45,17 @@
|
|||||||
<framework src="Security.framework" weak="true" />
|
<framework src="Security.framework" weak="true" />
|
||||||
<framework src="libz.dylib" weak="true" />
|
<framework src="libz.dylib" weak="true" />
|
||||||
|
|
||||||
|
<config-file target="*PushConfig.plist" parent="APP_KEY">
|
||||||
|
<string>$API_KEY</string>
|
||||||
|
</config-file>
|
||||||
</platform>
|
</platform>
|
||||||
|
|
||||||
<!-- android -->
|
<!-- android -->
|
||||||
<platform name="android">
|
<platform name="android">
|
||||||
|
<hook type="after_plugin_add" src="scripts/android-install.js" />
|
||||||
|
<hook type="after_plugin_install" src="scripts/android-install.js" />
|
||||||
|
<hook type="before_plugin_rm" src="scripts/android-install.js" />
|
||||||
|
<hook type="before_plugin_uninstall" src="scripts/android-install.js" />
|
||||||
|
|
||||||
<config-file target="res/xml/config.xml" parent="/*">
|
<config-file target="res/xml/config.xml" parent="/*">
|
||||||
<feature name="JPushPlugin">
|
<feature name="JPushPlugin">
|
||||||
@@ -152,14 +161,14 @@
|
|||||||
<receiver android:name="cn.jpush.android.service.AlarmReceiver"/>
|
<receiver android:name="cn.jpush.android.service.AlarmReceiver"/>
|
||||||
<!-- Required . Enable it you can get statistics data with channel -->
|
<!-- Required . Enable it you can get statistics data with channel -->
|
||||||
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
|
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
|
||||||
<meta-data android:name="JPUSH_APPKEY" android:value="your appkey"/>
|
<meta-data android:name="JPUSH_APPKEY" android:value="$API_KEY"/>
|
||||||
</config-file>
|
</config-file>
|
||||||
<source-file src="src/android/jpush-sdk-release1.7.5.jar" target-dir="libs"/>
|
<source-file src="src/android/jpush-android-2.0.5.jar" target-dir="libs"/>
|
||||||
<source-file src="src/android/armeabi/libjpush175.so" target-dir="libs/armeabi"/>
|
<source-file src="src/android/armeabi/libjpush205.so" target-dir="libs/armeabi"/>
|
||||||
<source-file src="src/android/armeabi-v7a/libjpush175.so" target-dir="libs/armeabi-v7a"/>
|
<source-file src="src/android/armeabi-v7a/libjpush205.so" target-dir="libs/armeabi-v7a"/>
|
||||||
<source-file src="src/android/arm64-v8a/libjpush175.so" target-dir="libs/armeabi-v8a"/>
|
<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/JPushPlugin.java" target-dir="src/cn/jpush/phonegap"/>-->
|
||||||
<source-file src="src/android/MyReceiver.java" target-dir="src/cn/jpush/phonegap"/>
|
<source-file src="src/android/MyReceiver.java" target-dir="src/cn/jpush/phonegap"/>
|
||||||
<source-file src="src/android/test_notification_layout.xml" target-dir="res/layout"/>
|
<source-file src="src/android/test_notification_layout.xml" target-dir="res/layout"/>
|
||||||
<source-file src="src/android/jpush_notification_icon.png" target-dir="res/drawable"/>
|
<source-file src="src/android/jpush_notification_icon.png" target-dir="res/drawable"/>
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
module.exports = function (context) {
|
||||||
|
var path = context.requireCordovaModule('path'),
|
||||||
|
fs = context.requireCordovaModule('fs'),
|
||||||
|
shell = context.requireCordovaModule('shelljs'),
|
||||||
|
projectRoot = context.opts.projectRoot,
|
||||||
|
ConfigParser = context.requireCordovaModule('cordova-lib/src/configparser/ConfigParser'),
|
||||||
|
config = new ConfigParser(path.join(context.opts.projectRoot, "config.xml")),
|
||||||
|
packageName = config.android_packageName() || config.packageName();
|
||||||
|
|
||||||
|
console.info("Running android-install.Hook: " + context.hook + ", Package: " + packageName + ", Path: " + projectRoot + ".");
|
||||||
|
|
||||||
|
if (!packageName) {
|
||||||
|
console.error("Package name could not be found!");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// android platform available?
|
||||||
|
if (context.opts.cordova.platforms.indexOf("android") === -1) {
|
||||||
|
console.info("Android platform has not been added.");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
var targetDir = path.join(projectRoot, "platforms", "android", "src", "cn", "jpush", "phonegap");
|
||||||
|
targetFile = path.join(targetDir, "JPushPlugin.java");
|
||||||
|
console.log(targetDir);
|
||||||
|
|
||||||
|
if (['after_plugin_add', 'after_plugin_install', 'after_platform_add'].indexOf(context.hook) === -1) {
|
||||||
|
// remove it?
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(targetFile);
|
||||||
|
} catch (err) {}
|
||||||
|
} else {
|
||||||
|
// create directory
|
||||||
|
shell.mkdir('-p', targetDir);
|
||||||
|
|
||||||
|
// sync the content
|
||||||
|
fs.readFile(path.join(context.opts.plugin.dir, 'src', 'android', 'JPushPlugin.java'), {encoding: 'utf-8'}, function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = data.replace(/^import __PACKAGE_NAME__.R;/m, 'import ' + packageName + '.R;');
|
||||||
|
fs.writeFileSync(targetFile, data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -19,13 +19,15 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import your.package.name.R;
|
import __PACKAGE_NAME__.R;
|
||||||
|
|
||||||
import cn.jpush.android.api.BasicPushNotificationBuilder;
|
import cn.jpush.android.api.BasicPushNotificationBuilder;
|
||||||
import cn.jpush.android.api.CustomPushNotificationBuilder;
|
import cn.jpush.android.api.CustomPushNotificationBuilder;
|
||||||
import cn.jpush.android.api.JPushInterface;
|
import cn.jpush.android.api.JPushInterface;
|
||||||
import cn.jpush.android.data.JPushLocalNotification;
|
import cn.jpush.android.data.JPushLocalNotification;
|
||||||
import cn.jpush.android.api.TagAliasCallback;
|
import cn.jpush.android.api.TagAliasCallback;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
||||||
public class JPushPlugin extends CordovaPlugin {
|
public class JPushPlugin extends CordovaPlugin {
|
||||||
private final static List<String> methodList =
|
private final static List<String> methodList =
|
||||||
@@ -46,6 +48,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
"setLatestNotificationNum",
|
"setLatestNotificationNum",
|
||||||
"setPushTime",
|
"setPushTime",
|
||||||
"clearAllNotification",
|
"clearAllNotification",
|
||||||
|
"clearNotificationById",
|
||||||
"addLocalNotification",
|
"addLocalNotification",
|
||||||
"removeLocalNotification",
|
"removeLocalNotification",
|
||||||
"clearLocalNotifications",
|
"clearLocalNotifications",
|
||||||
@@ -55,9 +58,13 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
|
|
||||||
private ExecutorService threadPool = Executors.newFixedThreadPool(1);
|
private ExecutorService threadPool = Executors.newFixedThreadPool(1);
|
||||||
private static JPushPlugin instance;
|
private static JPushPlugin instance;
|
||||||
|
private static String TAG = "Client JPushPlugin";
|
||||||
|
|
||||||
|
public static boolean bOpenNotificationAlert = true;
|
||||||
public static String notificationAlert;
|
public static String notificationAlert;
|
||||||
public static Map<String, Object> notificationExtras=new HashMap<String, Object>();
|
public static Map<String, Object> notificationExtras=new HashMap<String, Object>();
|
||||||
|
public static String openNotificationAlert;
|
||||||
|
public static Map<String, Object> openNotificationExtras=new HashMap<String, Object>();
|
||||||
|
|
||||||
public JPushPlugin() {
|
public JPushPlugin() {
|
||||||
instance = this;
|
instance = this;
|
||||||
@@ -67,6 +74,23 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
||||||
super.initialize(cordova, webView);
|
super.initialize(cordova, webView);
|
||||||
//JPushInterface.setDebugMode(true);
|
//JPushInterface.setDebugMode(true);
|
||||||
|
|
||||||
|
//JPushPlugin.notificationAlert = alert;
|
||||||
|
//JPushPlugin.notificationExtras = extras;
|
||||||
|
|
||||||
|
if(JPushPlugin.bOpenNotificationAlert){
|
||||||
|
|
||||||
|
JPushPlugin.bOpenNotificationAlert = false;
|
||||||
|
if(JPushPlugin.openNotificationAlert != null){
|
||||||
|
JPushPlugin.transmitOpen(JPushPlugin.openNotificationAlert, JPushPlugin.openNotificationExtras);
|
||||||
|
}
|
||||||
|
if(JPushPlugin.notificationAlert!=null){
|
||||||
|
JPushPlugin.transmitReceive(JPushPlugin.notificationAlert, JPushPlugin.notificationExtras);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//JPushInterface.init(cordova.getActivity().getApplicationContext());
|
//JPushInterface.init(cordova.getActivity().getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +237,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
JSONArray.class, CallbackContext.class);
|
JSONArray.class, CallbackContext.class);
|
||||||
method.invoke(JPushPlugin.this, data, callbackContext);
|
method.invoke(JPushPlugin.this, data, callbackContext);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e.toString());
|
Log.e(TAG,e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class MyReceiver extends BroadcastReceiver {
|
|||||||
|
|
||||||
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
|
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())) {
|
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
|
||||||
handlingReceivedMessage(intent);
|
handlingReceivedMessage(intent);
|
||||||
@@ -48,9 +48,9 @@ public class MyReceiver extends BroadcastReceiver {
|
|||||||
Intent launch = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
|
Intent launch = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
|
||||||
launch.addCategory(Intent.CATEGORY_LAUNCHER);
|
launch.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||||
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
|
JPushPlugin.bOpenNotificationAlert = true;
|
||||||
JPushPlugin.notificationAlert = alert;
|
JPushPlugin.openNotificationAlert = alert;
|
||||||
JPushPlugin.notificationExtras = extras;
|
JPushPlugin.openNotificationExtras = extras;
|
||||||
|
|
||||||
JPushPlugin.transmitOpen(alert, extras);
|
JPushPlugin.transmitOpen(alert, extras);
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Executable
BIN
Binary file not shown.
Regular → Executable
BIN
Binary file not shown.
Regular → Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Binary file not shown.
@@ -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
|
||||||
@@ -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;
|
NSNumber *result;
|
||||||
if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications ]) {
|
if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications ]) {
|
||||||
result=@(1);
|
|
||||||
}else{
|
|
||||||
result=@(0);
|
result=@(0);
|
||||||
|
}else{
|
||||||
|
result=@(1);
|
||||||
}
|
}
|
||||||
CDVPluginResult * pushResult=[self pluginResultForValue:result];
|
CDVPluginResult * pushResult=[self pluginResultForValue:result];
|
||||||
if (pushResult) {
|
if (pushResult) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>APP_KEY</key>
|
<key>APP_KEY</key>
|
||||||
<string>7d431e42dfa6a6d693ac2d04</string>
|
<string></string>
|
||||||
<key>CHANNEL</key>
|
<key>CHANNEL</key>
|
||||||
<string>Subscription</string>
|
<string>Subscription</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
//
|
//
|
||||||
// Created by JPush on 12-8-15.
|
// Created by JPush on 12-8-15.
|
||||||
// Copyright (c) 2012年 HXHG. All rights reserved.
|
// Copyright (c) 2012年 HXHG. All rights reserved.
|
||||||
// Version: 1.8.3
|
// Version: 1.8.8
|
||||||
|
|
||||||
@class CLRegion;
|
@class CLRegion;
|
||||||
@class UILocalNotification;
|
@class UILocalNotification;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -253,6 +253,13 @@ JPushPlugin.prototype.clearAllNotification = function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JPushPlugin.prototype.clearNotificationById = function(notificationId){
|
||||||
|
if(device.platform == "Android") {
|
||||||
|
data=[]
|
||||||
|
this.call_native("clearNotificationById",[notificationId],null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setLatestNotificationNum = function(num){
|
JPushPlugin.prototype.setLatestNotificationNum = function(num){
|
||||||
if(device.platform == "Android") {
|
if(device.platform == "Android") {
|
||||||
this.call_native("setLatestNotificationNum",[num],null);
|
this.call_native("setLatestNotificationNum",[num],null);
|
||||||
|
|||||||
Reference in New Issue
Block a user