mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-01-31 22:42:51 +08:00
Optimize installition & update Android SDK to 2.1.7
This commit is contained in:
parent
7ffec241fa
commit
c615f8255e
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[![Build Status](https://travis-ci.org/jpush/jpush-phonegap-plugin.svg?branch=master)](https://travis-ci.org/jpush/jpush-phonegap-plugin)
|
[![Build Status](https://travis-ci.org/jpush/jpush-phonegap-plugin.svg?branch=master)](https://travis-ci.org/jpush/jpush-phonegap-plugin)
|
||||||
[![QQ Group](https://img.shields.io/badge/QQ%20Group-413602425-red.svg)]()
|
[![QQ Group](https://img.shields.io/badge/QQ%20Group-413602425-red.svg)]()
|
||||||
[![release](https://img.shields.io/badge/release-2.2.0-blue.svg)](https://github.com/jpush/jpush-phonegap-plugin/releases)
|
[![release](https://img.shields.io/badge/release-2.2.1-blue.svg)](https://github.com/jpush/jpush-phonegap-plugin/releases)
|
||||||
[![platforms](https://img.shields.io/badge/platforms-iOS%7CAndroid-lightgrey.svg)](https://github.com/jpush/jpush-phonegap-plugin)
|
[![platforms](https://img.shields.io/badge/platforms-iOS%7CAndroid-lightgrey.svg)](https://github.com/jpush/jpush-phonegap-plugin)
|
||||||
[![weibo](https://img.shields.io/badge/weibo-JPush-blue.svg)](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
|
[![weibo](https://img.shields.io/badge/weibo-JPush-blue.svg)](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
|
||||||
|
|
||||||
@ -63,7 +63,8 @@
|
|||||||
|
|
||||||
## 常见问题
|
## 常见问题
|
||||||
|
|
||||||
若要使用 CLI 来编译项目,注意应使用 cordova compile 而不是 cordova build 命令,因为 cordova build 会清除对插件文件的修改。
|
若要使用 CLI 来编译项目,注意应使用 cordova compile 而不是 cordova build 命令,因为如果修改了插件安装时默认写入到 AndroidManifest.xml
|
||||||
|
中的代码,cordova build 可能会导致对 AndroidManifest.xml 的修改。
|
||||||
Cordova CLI 的具体用法可参考 [Cordova CLI 官方文档](https://cordova.apache.org/docs/en/latest/reference/cordova-cli/index.html)。
|
Cordova CLI 的具体用法可参考 [Cordova CLI 官方文档](https://cordova.apache.org/docs/en/latest/reference/cordova-cli/index.html)。
|
||||||
|
|
||||||
### 1. Android
|
### 1. Android
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "jpush-phonegap-plugin",
|
"name": "jpush-phonegap-plugin",
|
||||||
"version": "2.2.0",
|
"version": "2.2.1",
|
||||||
"description": "JPush for cordova plugin",
|
"description": "JPush for cordova plugin",
|
||||||
"cordova": {
|
"cordova": {
|
||||||
"id": "cn.jpush.phonegap.JPushPlugin",
|
"id": "cn.jpush.phonegap.JPushPlugin",
|
||||||
|
21
plugin.xml
21
plugin.xml
@ -2,7 +2,7 @@
|
|||||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
id="cn.jpush.phonegap.JPushPlugin"
|
id="cn.jpush.phonegap.JPushPlugin"
|
||||||
version="2.2.0">
|
version="2.2.1">
|
||||||
|
|
||||||
<name>JPush Plugin</name>
|
<name>JPush Plugin</name>
|
||||||
<description>JPush for cordova plugin</description>
|
<description>JPush for cordova plugin</description>
|
||||||
@ -55,9 +55,6 @@
|
|||||||
|
|
||||||
<!-- android -->
|
<!-- android -->
|
||||||
<platform name="android">
|
<platform name="android">
|
||||||
<hook type="after_plugin_install" 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">
|
||||||
<param name="android-package" value="cn.jpush.phonegap.JPushPlugin"/>
|
<param name="android-package" value="cn.jpush.phonegap.JPushPlugin"/>
|
||||||
@ -139,7 +136,6 @@
|
|||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.PACKAGE_ADDED"/>
|
<action android:name="android.intent.action.PACKAGE_ADDED"/>
|
||||||
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
|
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
|
||||||
<data android:scheme="package"/>
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
@ -169,20 +165,21 @@
|
|||||||
</receiver>
|
</receiver>
|
||||||
<!-- Required SDK核心功能-->
|
<!-- Required SDK核心功能-->
|
||||||
<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="$API_KEY"/>
|
<meta-data android:name="JPUSH_APPKEY" android:value="$API_KEY"/>
|
||||||
</config-file>
|
</config-file>
|
||||||
|
|
||||||
<source-file src="src/android/jpush-android-2.1.5.jar" target-dir="libs"/>
|
<source-file src="src/android/jpush-android-2.1.7.jar" target-dir="libs"/>
|
||||||
<source-file src="src/android/armeabi/libjpush215.so" target-dir="libs/armeabi"/>
|
<source-file src="src/android/armeabi/libjpush217.so" target-dir="libs/armeabi"/>
|
||||||
<source-file src="src/android/armeabi-v7a/libjpush215.so" target-dir="libs/armeabi-v7a"/>
|
<source-file src="src/android/armeabi-v7a/libjpush217.so" target-dir="libs/armeabi-v7a"/>
|
||||||
<source-file src="src/android/arm64-v8a/libjpush215.so" target-dir="libs/arm64-v8a"/>
|
<source-file src="src/android/arm64-v8a/libjpush217.so" target-dir="libs/arm64-v8a"/>
|
||||||
<source-file src="src/android/x86/libjpush215.so" target-dir="libs/x86"/>
|
<source-file src="src/android/x86/libjpush217.so" target-dir="libs/x86"/>
|
||||||
<source-file src="src/android/x86_64/libjpush215.so" target-dir="libs/x86_64"/>
|
<source-file src="src/android/x86_64/libjpush217.so" target-dir="libs/x86_64"/>
|
||||||
|
|
||||||
<!--<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/JPushPlugin.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"/>
|
||||||
|
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
#!/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-common/src/configparser/ConfigParser'),
|
|
||||||
config = new ConfigParser(path.join(context.opts.projectRoot, "config.xml")),
|
|
||||||
packageName = config.android_packageName() || config.packageName();
|
|
||||||
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
@ -5,8 +5,6 @@ import android.content.Context;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import __PACKAGE_NAME__.R;
|
|
||||||
|
|
||||||
import org.apache.cordova.CallbackContext;
|
import org.apache.cordova.CallbackContext;
|
||||||
import org.apache.cordova.CordovaInterface;
|
import org.apache.cordova.CordovaInterface;
|
||||||
import org.apache.cordova.CordovaPlugin;
|
import org.apache.cordova.CordovaPlugin;
|
||||||
@ -438,19 +436,23 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义推送通知栏样式,需要自己实现具体代码。
|
||||||
|
* http://docs.jiguang.cn/client/android_tutorials/#_11
|
||||||
|
*/
|
||||||
void setCustomPushNotificationBuilder(JSONArray data,
|
void setCustomPushNotificationBuilder(JSONArray data,
|
||||||
CallbackContext callbackContext) {
|
CallbackContext callbackContext) {
|
||||||
CustomPushNotificationBuilder builder = new CustomPushNotificationBuilder(
|
// CustomPushNotificationBuilder builder = new CustomPushNotificationBuilder(
|
||||||
this.cordova.getActivity(), R.layout.test_notification_layout,
|
// this.cordova.getActivity(), R.layout.test_notification_layout,
|
||||||
R.id.icon, R.id.title, R.id.text);
|
// R.id.icon, R.id.title, R.id.text);
|
||||||
builder.developerArg0 = "Custom Builder 1";
|
// builder.developerArg0 = "Custom Builder 1";
|
||||||
JPushInterface.setPushNotificationBuilder(2, builder);
|
// JPushInterface.setPushNotificationBuilder(2, builder);
|
||||||
JSONObject obj = new JSONObject();
|
// JSONObject obj = new JSONObject();
|
||||||
try {
|
// try {
|
||||||
obj.put("id", 2);
|
// obj.put("id", 2);
|
||||||
} catch (JSONException e) {
|
// } catch (JSONException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearAllNotification(JSONArray data, CallbackContext callbackContext) {
|
void clearAllNotification(JSONArray data, CallbackContext callbackContext) {
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
src/android/jpush-android-2.1.7.jar
Normal file
BIN
src/android/jpush-android-2.1.7.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user