Compare commits

..

29 Commits

Author SHA1 Message Date
Hevin
8e7e957884 Merge remote-tracking branch 'refs/remotes/origin/dev' 2016-06-28 16:00:04 +08:00
Hevin
c615f8255e Optimize installition & update Android SDK to 2.1.7 2016-06-28 15:57:34 +08:00
E.B
7ffec241fa iOS - fix #151
1. fix #151
2016-06-27 10:59:26 +08:00
Hevin
de32f4a057 Format README 2016-06-27 10:40:03 +08:00
Hevin
1cd7ecf3e5 Merge remote-tracking branch 'refs/remotes/origin/dev' 2016-06-27 10:37:39 +08:00
Hevin
b01b4bf259 Add dependency & Update README 2016-06-27 10:34:16 +08:00
Hevin
f8efb4f010 Merge remote-tracking branch 'refs/remotes/origin/master' into dev 2016-06-27 10:29:39 +08:00
Hevin
870fc12c0d Merge remote-tracking branch 'refs/remotes/origin/dev' 2016-06-23 13:23:13 +08:00
Hevin
dc2cdda00c Update README
Add QQ group badge.
2016-06-23 13:18:27 +08:00
Hevin
1c96487869 Update install script. 2016-06-17 17:44:42 +08:00
Hevin
8d24ce7c48 Merge remote-tracking branch 'refs/remotes/origin/dev' 2016-06-17 13:41:20 +08:00
Hevin
280846779d Update Android SDK to 2.1.5 2016-06-17 13:39:23 +08:00
Hevin
1ba048ee1b Update README 2016-06-12 16:25:11 +08:00
E.B
e4500dd513 iOS - update
1.拼写错误
2016-05-31 13:36:43 +08:00
Hevin
a511072101 Merge remote-tracking branch 'refs/remotes/origin/dev' 2016-05-30 18:01:17 +08:00
Hevin
851ff1f23b Update version. 2016-05-30 18:00:47 +08:00
Hevin
5cf5bd39d1 Merge remote-tracking branch 'refs/remotes/origin/master' into dev 2016-05-30 17:58:41 +08:00
E.B
07bb05f337 Merge branch 'dev' 2016-05-30 17:34:32 +08:00
E.B
ceeb2fc7cf iOS - fix #147
1.fix #147
2016-05-30 17:29:07 +08:00
E.B
1eccd58059 Merge branch 'dev' 2016-05-27 13:58:45 +08:00
E.B
a82382eddf iOS - update
1.更新 iOS SDK v2.1.7
2.IDFA 默认关闭
2016-05-27 10:04:57 +08:00
Hevin
be6dbf4fe6 Merge remote-tracking branch 'refs/remotes/origin/dev' 2016-05-25 16:15:02 +08:00
Hevin
e898c7933c Merge branch 'master' into dev 2016-05-18 14:19:12 +08:00
Hevin
bce5b4df68 fix warming when add and remove plugin. 2016-05-18 14:19:09 +08:00
Hevin
3810209ca6 Merge pull request #146 from withwind8/master
add dependent plugin cordova-plugin-device
2016-05-13 13:39:04 +08:00
Hevin
39155bf63c Merge branch 'dev' 2016-05-13 13:38:27 +08:00
Hevin
93989a7ad1 update README 2016-05-13 13:37:00 +08:00
Li Qing
8c6044b6a6 add dependent plugin cordova-plugin-device 2016-05-13 11:53:12 +08:00
Hevin
9c0c2c0bd1 Merge branch 'master' into dev 2016-05-13 11:31:07 +08:00
22 changed files with 80 additions and 171 deletions

117
README.md
View File

@@ -1,79 +1,39 @@
# JPush PhoneGap / Cordova Plugin
[![Build Status](https://travis-ci.org/jpush/jpush-phonegap-plugin.svg?branch=master)](https://travis-ci.org/jpush/jpush-phonegap-plugin)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jpush/jpush-phonegap-plugin)
[![release](https://img.shields.io/badge/release-2.1.5-blue.svg)](https://github.com/jpush/jpush-phonegap-plugin/releases)
[![QQ Group](https://img.shields.io/badge/QQ%20Group-413602425-red.svg)]()
[![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)
[![weibo](https://img.shields.io/badge/weibo-JPush-blue.svg)](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
支持 iOS, Android 的 Cordova 推送插件。
> 如需要 IM 功能的插件,可关注 [jmessage-phonegap-plugin](https://github.com/jpush/jmessage-phonegap-plugin)。
## 功能特性
+ 发送推送通知。
+ 发送推送自定义消息。
+ 设置推送标签和别名。
+ 设置角标iOS
## 集成步骤
集成 JPush PhoneGap Plugin 有两种方法:
*如需要 IM 功能插件,请关注 [jmessage-phonegap-plugin](https://github.com/jpush/jmessage-phonegap-plugin)*
### 在线安装
- 通过 Cordova Plugins 安装,要求 PhoneGap/Cordova CLI 5.0+
## 安装
### 准备工作
cordova plugin add jpush-phonegap-plugin --variable API_KEY=your_jpush_appkey
1. cordova create 文件夹名字 包名 应用名字
- 直接通过 url 安装:
cordova create Myproj com.myproj.jpush MyTestProj
cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git --variable API_KEY=your_jpush_appkey
2. 添加平台:
cd Myproj
cordova platform add android
cordova platform add ios
ps: 这里请注意iOS平台必须先执行 cordova platform add ios,
然后再执行 cordova plugin add xxxxx 命令,不然有一些必须要的链接库需要手动添加。
### 安装插件(Android & iOS)
#### 1.安装 JPush PhoneGap Plugin
安装 JPush PhoneGap Plugin 有两种方法:
方法一:在线安装
通过 cordova plugins 安装,要求 phonegap/cordova CLI 5.0+:
cordova plugin add jpush-phonegap-plugin --variable API_KEY=your_jpush_appkey
直接通过 url 安装:
cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git --variable API_KEY=your_jpush_appkey
方法二:下载到本地再安装
使用 git 命令将 JPush PhoneGap 插件下载的本地,目录标记为 $JPUSH_PLUGIN_DIR。
### 本地安装
使用 git 命令将 JPush PhoneGap 插件下载的本地,目录标记为 $JPUSH_PLUGIN_DIR
git clone https://github.com/jpush/jpush-phonegap-plugin.git
cordova plugin add $JPUSH_PLUGIN_DIR --variable API_KEY=your_jpush_appkey
[Android 手动安装文档地址](/doc/Android_handle_install.md)
[IOS 手动安装文档地址](/doc/iOS_install.md)
#### 2.安装 cordova device 插件
cordova plugin add cordova-plugin-device
#### 3.在 js 中调用函数,初始化 JPush
//由于 PhoneGap 插件采用了 Lazy load 的特性,所以建议在 js 文件能执行的最开始就添加
window.plugins.jPushPlugin.init();
- [Android 手动安装文档地址](/doc/Android_handle_install.md)
- [iOS 手动安装文档地址](/doc/iOS_install.md)。
## Demo
插件中包含示例 Demo。若想参考可以在 $JPUSH_PLUGIN_DIR/example 文件夹内找到并拷贝以下文件:
插件项目中包含一个简单的 Demo。若想参考可以在 /example 文件夹内找到并拷贝以下文件:
src/example/index.html -> www/index.html
src/example/css/* -> www/css
@@ -81,57 +41,52 @@
## 关于 PhoneGap build 云服务
该项目基于 cordova 实现,目前无法使用 PhoneGap build 云服务进行打包,建议使用本地环境进行打包。
该项目基于 Cordova 实现,目前无法使用 PhoneGap build 云服务进行打包,建议使用本地环境进行打包。
## API 说明
插件的 API 集中在 JPushPlugin.js 文件中,该文件的具体位置如下:
Android:
插件的 API 在 JPushPlugin.js 文件中,该文件的具体位置如下:
### Android
[Project]/assets/www/plugins/cn.jpush.phonegap.JPushPlugin/www
iOS:
### iOS
[Project]/www/plugins/cn.jpush.phonegap.JPushPlugin/www
### 具体的 API 请参考:
- [公共 API](/doc/Common_detail_api.md)
- [公共 API](/doc/Common_detail_api.md)
- [iOS API](/doc/iOS_API.md)
- [iOS API](/doc/iOS_API.md)
- [Android API](/doc/Android_detail_api.md)
- [Android API](/doc/Android_detail_api.md)
## 常见问题
若要使用 CLI 来编译项目,注意使用 cordova compile 而不是 cordova build,因为 cordova build 会清除对插件文件的修改。
具体 cordova CLI 用法可参考[cordova CLI 官方文档](https://cordova.apache.org/docs/en/latest/reference/cordova-cli/index.html)
若要使用 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)。
### 1. Android
eclipse 中 import PhoneGap 工程之后出现:`Type CallbackContext cannot be resolved to a type`
Eclipse 中 import PhoneGap 工程之后出现:*Type CallbackContext cannot be resolved to a type*
解决方案:eclipse 中右键单击工程名Build Path -> Config Build Path -> Projects -> 选中工程名称 -> CordovaLib -> 点击 add。
解决方案:Eclipse 中右键单击工程名Build Path -> Config Build Path -> Projects -> 选中工程名称 -> CordovaLib -> 点击 add。
### 2. iOS
- 收不到推送:
请首先按照正确方式再次配置证书、描述文件
[iOS 证书设置指南](http://docs.jpush.io/client/ios_tutorials/#ios_1)
- 收不到推送
请首先按照正确方式再次配置证书、描述文件,具体可参考 [iOS 证书设置指南](http://docs.jpush.io/client/ios_tutorials/#ios_1)。
- 设置 PushConfig.plist
- APP_KEY应用标识
- CHANNEL渠道标识
- IsProduction是否生产环境
- IsIDFA是否使用 IDFA 启动 sdk
- APP_KEY应用标识。
- CHANNEL渠道标识
- IsProduction是否生产环境。
- IsIDFA是否使用 IDFA 启动 SDK。
## 更多
[JPush 官网文档](http://docs.jpush.io/)
[JPush 官网文档](http://docs.jpush.io/)
如有问题可访问[极光社区](http://community.jpush.cn/)
如有问题可访问[极光社区](http://community.jpush.cn/)

View File

@@ -57,7 +57,7 @@ JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数
### API - isPushStopped
iOS平台检查推送服务是否注册
iOS平台检查推送服务是否停止
#### 接口定义
@@ -69,12 +69,12 @@ iOS平台检查推送服务是否注册。
- callback 回调函数,用来通知 JPush 的推送服务是否开启。
#### 代码示例
window.plugins.jPushPlugin.resumePush(callback)
var onCallback = function(data) {
window.plugins.jPushPlugin.isPushStopped(callback)
var callback = function(data) {
if(data > 0) {
// 开启
// 已关闭
} else {
// 关闭
// 已开启
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "jpush-phonegap-plugin",
"version": "2.1.7",
"version": "2.2.1",
"description": "JPush for cordova plugin",
"cordova": {
"id": "cn.jpush.phonegap.JPushPlugin",
@@ -16,6 +16,7 @@
"keywords": [
"JPush",
"push",
"Push",
"ecosystem:cordova",
"cordova-ios",
"cordova-android"
@@ -26,6 +27,9 @@
"version": ">=3.0"
}
],
"peerDependencies": {
"cordova-plugin-device": ">=1.0.0"
},
"author": "jpush",
"license": "Apache 2.0 License",
"bugs": {

View File

@@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cn.jpush.phonegap.JPushPlugin"
version="2.1.7">
version="2.2.1">
<name>JPush Plugin</name>
<description>JPush for cordova plugin</description>
@@ -16,6 +16,8 @@
<engine name="cordova" version=">=3.0"/>
</engines>
<dependency id="org.apache.cordova.device" url="https://github.com/apache/cordova-plugin-device.git" />
<js-module src="www/JPushPlugin.js" name="JPushPlugin">
<clobbers target="jPushPlugin"/>
</js-module>
@@ -31,7 +33,7 @@
<source-file src="src/ios/Plugins/JPushPlugin.m"/>
<header-file src="src/ios/lib/JPUSHService.h" />
<source-file src="src/ios/lib/jpush-ios-2.1.6.a" framework="true" />
<source-file src="src/ios/lib/jpush-ios-2.1.7.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" />
@@ -53,11 +55,6 @@
<!-- 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="/*">
<feature name="JPushPlugin">
<param name="android-package" value="cn.jpush.phonegap.JPushPlugin"/>
@@ -139,7 +136,6 @@
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
@@ -169,20 +165,21 @@
</receiver>
<!-- Required SDK核心功能-->
<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_APPKEY" android:value="$API_KEY"/>
</config-file>
<source-file src="src/android/jpush-android-2.1.3.jar" target-dir="libs"/>
<source-file src="src/android/armeabi/libjpush213.so" target-dir="libs/armeabi"/>
<source-file src="src/android/armeabi-v7a/libjpush213.so" target-dir="libs/armeabi-v7a"/>
<source-file src="src/android/arm64-v8a/libjpush213.so" target-dir="libs/arm64-v8a"/>
<source-file src="src/android/x86/libjpush213.so" target-dir="libs/x86"/>
<source-file src="src/android/x86_64/libjpush213.so" target-dir="libs/x86_64"/>
<source-file src="src/android/jpush-android-2.1.7.jar" target-dir="libs"/>
<source-file src="src/android/armeabi/libjpush217.so" target-dir="libs/armeabi"/>
<source-file src="src/android/armeabi-v7a/libjpush217.so" target-dir="libs/armeabi-v7a"/>
<source-file src="src/android/arm64-v8a/libjpush217.so" target-dir="libs/arm64-v8a"/>
<source-file src="src/android/x86/libjpush217.so" target-dir="libs/x86"/>
<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/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/jpush_notification_icon.png" target-dir="res/drawable"/>

View File

@@ -1,49 +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-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);
});
}
};

View File

@@ -5,8 +5,6 @@ import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import __PACKAGE_NAME__.R;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
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,
CallbackContext callbackContext) {
CustomPushNotificationBuilder builder = new CustomPushNotificationBuilder(
this.cordova.getActivity(), R.layout.test_notification_layout,
R.id.icon, R.id.title, R.id.text);
builder.developerArg0 = "Custom Builder 1";
JPushInterface.setPushNotificationBuilder(2, builder);
JSONObject obj = new JSONObject();
try {
obj.put("id", 2);
} catch (JSONException e) {
e.printStackTrace();
}
// CustomPushNotificationBuilder builder = new CustomPushNotificationBuilder(
// this.cordova.getActivity(), R.layout.test_notification_layout,
// R.id.icon, R.id.title, R.id.text);
// builder.developerArg0 = "Custom Builder 1";
// JPushInterface.setPushNotificationBuilder(2, builder);
// JSONObject obj = new JSONObject();
// try {
// obj.put("id", 2);
// } catch (JSONException e) {
// e.printStackTrace();
// }
}
void clearAllNotification(JSONArray data, CallbackContext callbackContext) {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -16,7 +16,7 @@ static NSString *const JP_APP_CHANNEL = @"CHANNEL";
static NSString *const JP_APP_ISPRODUCTION = @"IsProduction";
static NSString *const JP_APP_ISIDFA = @"IsIDFA";
static NSString *const JPushConfigFileName = @"PushConfig";
static NSDictionary *_luanchOptions = nil;
static NSDictionary *_launchOptions = nil;
@implementation JPushPlugin
@@ -92,8 +92,8 @@ static NSDictionary *_luanchOptions = nil;
name:kJPushPluginReceiveNotification
object:nil];
if (_luanchOptions) {
NSDictionary *userInfo = [_luanchOptions
if (_launchOptions) {
NSDictionary *userInfo = [_launchOptions
valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if ([userInfo count] >0) {
NSError *error;
@@ -261,7 +261,7 @@ static NSDictionary *_luanchOptions = nil;
#pragma mark-
+(void)setLaunchOptions:(NSDictionary *)theLaunchOptions{
_luanchOptions = theLaunchOptions;
_launchOptions = theLaunchOptions;
[JPUSHService setDebugMode];
@@ -289,7 +289,7 @@ static NSDictionary *_luanchOptions = nil;
if(isIDFA){
advertisingId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
}
[JPUSHService setupWithOption:_luanchOptions
[JPUSHService setupWithOption:_launchOptions
appKey:appkey
channel:channel
apsForProduction:[isProduction boolValue]

View File

@@ -9,6 +9,6 @@
<key>IsProduction</key>
<false/>
<key>IsIDFA</key>
<true/>
<false/>
</dict>
</plist>

View File

@@ -9,7 +9,7 @@
* Copyright (c) 2011 ~ 2015 Shenzhen HXHG. All rights reserved.
*/
#define JPUSH_VERSION_NUMBER 2.1.6
#define JPUSH_VERSION_NUMBER 2.1.7
#import <Foundation/Foundation.h>