Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 62dca46c8e | |||
| 7ce63d7cb9 | |||
| 54743f8bf5 | |||
| 27c5d80655 | |||
| fe63a9f47f | |||
| 86fa5f3c23 | |||
| 1afa09cf25 | |||
| 4e579e6947 | |||
| ff8032e88c | |||
| 9df019fb98 | |||
| 29cbfc5448 | |||
| 9b38c7744c | |||
| cffcbc1a08 | |||
| ca72e500d1 | |||
| 1a8cba8e75 | |||
| 9887672545 | |||
| c627166521 |
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[](https://travis-ci.org/jpush/jpush-phonegap-plugin)
|
[](https://travis-ci.org/jpush/jpush-phonegap-plugin)
|
||||||
[]()
|
[]()
|
||||||
[](https://github.com/jpush/jpush-phonegap-plugin/releases)
|
[](https://github.com/jpush/jpush-phonegap-plugin/releases)
|
||||||
[](https://github.com/jpush/jpush-phonegap-plugin)
|
[](https://github.com/jpush/jpush-phonegap-plugin)
|
||||||
[](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
|
[](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
|
||||||
|
|
||||||
@@ -58,9 +58,15 @@
|
|||||||
- IsProduction:是否生产环境。
|
- IsProduction:是否生产环境。
|
||||||
- IsIDFA:是否使用 IDFA 启动 SDK。
|
- IsIDFA:是否使用 IDFA 启动 SDK。
|
||||||
|
|
||||||
#### 收不到推送了。
|
#### 刚集成完插件收不到推送怎么办?
|
||||||
请首先按照正确方式再次配置证书、描述文件,具体可参考 [iOS 证书设置指南](http://docs.jpush.io/client/ios_tutorials/#ios_1)。
|
请首先按照正确方式再次配置证书、描述文件,具体可参考 [iOS 证书设置指南](http://docs.jpush.io/client/ios_tutorials/#ios_1)。
|
||||||
|
|
||||||
|
#### iOS 集成插件白屏、或无法启动插件、或打包报错无法找到需要引入的文件怎么办?
|
||||||
|
按照以下步骤逐个尝试:
|
||||||
|
|
||||||
|
- 升级至 Xcode 8
|
||||||
|
- 先删除插件、再重装插件
|
||||||
|
- 先使用 `cordova platform add ios`,后使用 `cordova plugin add`
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
- QQ 群:413602425
|
- QQ 群:413602425
|
||||||
|
|||||||
@@ -201,7 +201,7 @@
|
|||||||
当用户需要定制默认的通知栏样式时,则可调用此方法。
|
当用户需要定制默认的通知栏样式时,则可调用此方法。
|
||||||
需要用户去自定义 ../JPushPlugin.java 中的同名方法代码,然后再在 js 端 调用该方法。
|
需要用户去自定义 ../JPushPlugin.java 中的同名方法代码,然后再在 js 端 调用该方法。
|
||||||
|
|
||||||
具体用法可参考[官方文档](http://docs.jpush.io/client/android_tutorials/#_11)。
|
具体用法可参考[官方文档](http://docs.jiguang.cn/jpush/client/Android/android_api/#api_6)。
|
||||||
|
|
||||||
JPush SDK 提供了 2 个用于定制通知栏样式的构建类:
|
JPush SDK 提供了 2 个用于定制通知栏样式的构建类:
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
- [日志等级设置](#日志等级设置)
|
- [日志等级设置](#日志等级设置)
|
||||||
- [地理位置上报](#地理位置上报)
|
- [地理位置上报](#地理位置上报)
|
||||||
- [设备平台判断](#设备平台判断)
|
- [设备平台判断](#设备平台判断)
|
||||||
|
- [iOS 10 进阶推送特性](#ios-10-进阶推送特性)
|
||||||
|
- [获取用户推送设置](#获取用户推送设置)
|
||||||
|
|
||||||
## 开始与停止推送服务
|
## 开始与停止推送服务
|
||||||
|
|
||||||
@@ -180,17 +182,17 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
|
|||||||
|
|
||||||
#### 错误码定义
|
#### 错误码定义
|
||||||
|
|
||||||
|Code|描述 |详细解释 |
|
| Code | 描述 | 详细解释 |
|
||||||
|----|:----------------------------------------|:--------|
|
| ---- | :-------------------------- | :-------------------------------- |
|
||||||
|6001|无效的设置,tag/alias 不应参数都为 null | |
|
| 6001 | 无效的设置,tag/alias 不应参数都为 null | |
|
||||||
|6002|设置超时 |建议重试。|
|
| 6002 | 设置超时 | 建议重试。 |
|
||||||
|6003|alias 字符串不合法 |有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。|
|
| 6003 | alias 字符串不合法 | 有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。 |
|
||||||
|6004|alias超长 |最多 40个字节 中文 UTF-8 是 3 个字节。|
|
| 6004 | alias超长 | 最多 40个字节 中文 UTF-8 是 3 个字节。 |
|
||||||
|6005|某一个 tag 字符串不合法 |有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。|
|
| 6005 | 某一个 tag 字符串不合法 | 有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。 |
|
||||||
|6006|某一个 tag 超长 |一个 tag 最多 40个字节 中文 UTF-8 是 3 个字节。|
|
| 6006 | 某一个 tag 超长 | 一个 tag 最多 40个字节 中文 UTF-8 是 3 个字节。 |
|
||||||
|6007|tags 数量超出限制(最多 100 个) |这是一台设备的限制。一个应用全局的标签数量无限制。|
|
| 6007 | tags 数量超出限制(最多 100 个) | 这是一台设备的限制。一个应用全局的标签数量无限制。 |
|
||||||
|6008|tag/alias 超出总长度限制 |总长度最多 1K 字节。|
|
| 6008 | tag/alias 超出总长度限制 | 总长度最多 1K 字节。 |
|
||||||
|6011|10s内设置tag或alias大于3次 |短时间内操作过于频繁。|
|
| 6011 | 10s内设置tag或alias大于3次 | 短时间内操作过于频繁。 |
|
||||||
|
|
||||||
|
|
||||||
## 获取 APNS 推送内容
|
## 获取 APNS 推送内容
|
||||||
@@ -569,3 +571,151 @@ value 取值范围:[0,99999]。
|
|||||||
} else {
|
} else {
|
||||||
// Android
|
// Android
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## iOS 10 进阶推送特性
|
||||||
|
|
||||||
|
### API - addDismissActions
|
||||||
|
|
||||||
|
添加通知操作,是展示在锁屏推送侧滑界面、通知中心推送侧滑界面、推送横幅下拉界面(iPhone 6s before)的按钮操作。
|
||||||
|
|
||||||
|
一条推送最多只能展示 2 个操作(在锁屏推送侧滑界面、通知中心推送侧滑界面会额外自动展示一个「清除」操作),超出的操作不会被展示。
|
||||||
|
|
||||||
|
建议在 App 初次启动时立刻调用本 API。
|
||||||
|
|
||||||
|
效果如下图所示:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
#### 接口定义
|
||||||
|
|
||||||
|
```
|
||||||
|
window.plugins.jPushPlugin.prototype.addDismissActions(actions, categoryId);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 参数说明
|
||||||
|
|
||||||
|
- actions:包含最多 2 个字典的数组,多余的字典无效,所有字段均为字符串,字段如下:
|
||||||
|
- title:必填,标题。
|
||||||
|
- identifier:必填,标识,获取 APNS 推送内容的时候可以通过该字段判断点击的是推送条目还是某项操作。
|
||||||
|
- option:必填,取值如下:
|
||||||
|
- UNNotificationActionOptionNone = 0
|
||||||
|
- UNNotificationActionOptionAuthenticationRequired = (1 << 0), Whether this action should require unlocking before being performed.
|
||||||
|
- UNNotificationActionOptionDestructive = (1 << 1), Whether this action should be indicated as destructive.
|
||||||
|
- UNNotificationActionOptionForeground = (1 << 2), Whether this action should cause the application to launch in the foreground.
|
||||||
|
- type:可选,值为 "textInput" 时,会创建一个可快速回复的操作。
|
||||||
|
- textInputButtonTitle:可选,快捷回复的回复按键标题。
|
||||||
|
- textInputPlaceholder:可选,快捷回复输入框占位符。
|
||||||
|
- categoryId:category id,用于标记这一组操作,推送时的 `payload` 添加 `category` 字段(在极光控制台 - 发送通知 - 可选设置 - category ),即可展示相应的这一组操作。例:id1 对应 [操作A,操作B],id2 对应 [操作A, 操作C]。
|
||||||
|
|
||||||
|
#### 代码示例
|
||||||
|
|
||||||
|
```
|
||||||
|
window.plugins.jPushPlugin.addDismissActions([{"title":"t1", "identifier":"id1", "option":"0"}, {"title":"t2", "identifier":"id2", "option":"3", "type":"textInput", "textInputButtonTitle":"回复", "textInputPlaceholder":"点此输入回复内容"}], "categoryId_t1_t2");
|
||||||
|
```
|
||||||
|
|
||||||
|
### API - addNotificationActions
|
||||||
|
|
||||||
|
轻触推送横幅,展示的更多操作。
|
||||||
|
|
||||||
|
iPhone 6s 及以后设备且 iOS 9 以后系统支持 3d-touch。
|
||||||
|
|
||||||
|
建议在 App 初次启动时立刻调用本 API。
|
||||||
|
|
||||||
|
效果如下图所示:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
#### 接口定义
|
||||||
|
|
||||||
|
```
|
||||||
|
window.plugins.jPushPlugin.prototype.addNotificationActions(actions, categoryId);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 参数说明
|
||||||
|
|
||||||
|
参数同 API - addDismissActions
|
||||||
|
|
||||||
|
#### 代码示例
|
||||||
|
|
||||||
|
代码示例同 API - addDismissActions
|
||||||
|
|
||||||
|
### Media Attachments
|
||||||
|
|
||||||
|
(iOS 10)在手机锁屏界面和通知中心界面的推送条目、应用菜单界面的推送横幅上,展示图片、gif、audio、video 等富媒体。效果如下图所示:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
#### 配置方法
|
||||||
|
|
||||||
|
1. 首先配置好 iOS 项目的证书。如下图所示没有任何异常警告:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
2. 打开 iOS Xcode Project - File - New - Target - iOS - Notification Service Extension - Next - Product Name 填写 `jpushNotificationService` - Finish,如下图所示: 
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
3. 在 Xcode 工程目录左侧系统自动创建了 jpushNotificationService 文件夹及三个文件,下载本插件目录 `jpush-phonegap-plugin/src/ios/notificationService/` 下的 `NotificationService.h`、`NotificationService.m` 文件,全部复制替换对应文件内代码。
|
||||||
|
|
||||||
|
4. 在 Xcode 中拖拽图片、gif、audio、video 等资源文件至 `jpushNotificationService` 文件夹目录下,弹出菜单选择如下: 
|
||||||
|
|
||||||
|
5. 在极光控制台 - 发送通知 - 可选设置 - mutable-content 打勾。
|
||||||
|
|
||||||
|
6. 添加附加字段, key 为 `JPushPluginAttachment` ,value 为资源名称如 `aPic.png`,该资源必须在第 4 步中已经添加至工程,且文件名和拓展名完全对应。5、6 如下图所示:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
另,5、6 亦可通过服务端自定义的 payload 实现,如下所示:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
aps:{
|
||||||
|
alert:{...},
|
||||||
|
mutable-content:1 //必须
|
||||||
|
}
|
||||||
|
JPushPluginAttachment:aPic.png //必须
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
7. 立即发送。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 获取用户推送设置
|
||||||
|
|
||||||
|
### API - getUserNotificationSettings
|
||||||
|
|
||||||
|
获取用户对本 App 的推送设置情况。
|
||||||
|
|
||||||
|
#### 接口定义
|
||||||
|
|
||||||
|
```
|
||||||
|
window.plugins.jPushPlugin.prototype.getUserNotificationSettings(callback);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 返回值
|
||||||
|
|
||||||
|
- iOS 10 before
|
||||||
|
- UIRemoteNotificationTypeNone = 0
|
||||||
|
- UIRemoteNotificationTypeBadge = 1 << 0
|
||||||
|
- UIRemoteNotificationTypeSound = 1 << 1
|
||||||
|
- UIRemoteNotificationTypeAlert = 1 << 2
|
||||||
|
- UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3
|
||||||
|
- iOS 10 after
|
||||||
|
- 字段 authorizationStatus,取值如下:
|
||||||
|
- UNAuthorizationStatusNotDetermined = 0, The user has not yet made a choice regarding whether the application may post user notifications.
|
||||||
|
- UNAuthorizationStatusDenied = 1, The application is not authorized to post user notifications.
|
||||||
|
- UNAuthorizationStatusAuthorized = 2, The application is authorized to post user notifications.
|
||||||
|
- 字段 soundSetting、badgeSetting、alertSetting、notificationCenterSetting、lockScreenSetting、carPlaySetting,取值如下:
|
||||||
|
- UNNotificationSettingNotSupported = 0, The application does not support this notification type.
|
||||||
|
- UNNotificationSettingDisabled = 1, The notification setting is turned off.
|
||||||
|
- UNNotificationSettingEnabled = 2, The notification setting is turned on.
|
||||||
|
- 字段 alertStyle,取值如下:
|
||||||
|
- UNAlertStyleNone = 0
|
||||||
|
- UNAlertStyleBanner = 1
|
||||||
|
- UNAlertStyleAlert = 2
|
||||||
|
|
||||||
|
|||||||
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 1.7 MiB |
|
After Width: | Height: | Size: 237 KiB |
|
After Width: | Height: | Size: 204 KiB |
|
After Width: | Height: | Size: 213 KiB |
|
After Width: | Height: | Size: 140 KiB |
|
After Width: | Height: | Size: 143 KiB |
|
After Width: | Height: | Size: 93 KiB |
|
After Width: | Height: | Size: 31 KiB |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "jpush-phonegap-plugin",
|
"name": "jpush-phonegap-plugin",
|
||||||
"version": "2.2.6",
|
"version": "2.2.8",
|
||||||
"description": "JPush for cordova plugin",
|
"description": "JPush for cordova plugin",
|
||||||
"cordova": {
|
"cordova": {
|
||||||
"id": "jpush-phonegap-plugin",
|
"id": "jpush-phonegap-plugin",
|
||||||
|
|||||||
@@ -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="jpush-phonegap-plugin"
|
id="jpush-phonegap-plugin"
|
||||||
version="2.2.5">
|
version="2.2.7">
|
||||||
|
|
||||||
<name>JPush Plugin</name>
|
<name>JPush Plugin</name>
|
||||||
<description>JPush for cordova plugin</description>
|
<description>JPush for cordova plugin</description>
|
||||||
@@ -81,7 +81,9 @@
|
|||||||
</config-file>
|
</config-file>
|
||||||
<config-file target="AndroidManifest.xml" parent="/manifest/application">
|
<config-file target="AndroidManifest.xml" parent="/manifest/application">
|
||||||
<!-- Required SDK核心功能-->
|
<!-- Required SDK核心功能-->
|
||||||
<activity android:name="cn.jpush.android.ui.PushActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="orientation|keyboardHidden">
|
<activity android:name="cn.jpush.android.ui.PushActivity"
|
||||||
|
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
||||||
|
android:configChanges="orientation|keyboardHidden">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="cn.jpush.android.ui.PushActivity" />
|
<action android:name="cn.jpush.android.ui.PushActivity" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
@@ -90,7 +92,9 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- Rich push 核心功能 since 2.0.6-->
|
<!-- Rich push 核心功能 since 2.0.6-->
|
||||||
<activity android:name="cn.jpush.android.ui.PopWinActivity" android:theme="@style/MyDialogStyle" android:exported="false">
|
<activity android:name="cn.jpush.android.ui.PopWinActivity"
|
||||||
|
android:theme="@style/MyDialogStyle"
|
||||||
|
android:exported="false">
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- Required SDK核心功能-->
|
<!-- Required SDK核心功能-->
|
||||||
@@ -168,25 +172,26 @@
|
|||||||
<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.9.jar" target-dir="libs" />
|
<source-file src="src/android/libs/jpush-android-2.2.0.jar" target-dir="libs" />
|
||||||
<source-file src="src/android/armeabi/libjpush219.so" target-dir="libs/armeabi" />
|
<source-file src="src/android/libs/armeabi/libjpush220.so" target-dir="libs/armeabi" />
|
||||||
<source-file src="src/android/armeabi-v7a/libjpush219.so" target-dir="libs/armeabi-v7a" />
|
<source-file src="src/android/libs/armeabi-v7a/libjpush220.so" target-dir="libs/armeabi-v7a" />
|
||||||
<source-file src="src/android/arm64-v8a/libjpush219.so" target-dir="libs/arm64-v8a" />
|
<source-file src="src/android/libs/arm64-v8a/libjpush220.so" target-dir="libs/arm64-v8a" />
|
||||||
<source-file src="src/android/x86/libjpush219.so" target-dir="libs/x86" />
|
<source-file src="src/android/libs/x86/libjpush220.so" target-dir="libs/x86" />
|
||||||
<source-file src="src/android/x86_64/libjpush219.so" target-dir="libs/x86_64" />
|
<source-file src="src/android/libs/x86_64/libjpush220.so" target-dir="libs/x86_64" />
|
||||||
|
|
||||||
<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/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" />
|
|
||||||
|
|
||||||
<!-- Rich Push resources -->
|
<source-file src="src/android/res/drawable-hdpi/jpush_richpush_btn_selector.xml" target-dir="res/drawable" />
|
||||||
<source-file src="src/android/ic_richpush_actionbar_back.png" target-dir="res/drawable" />
|
<source-file src="src/android/res/drawable-hdpi/jpush_richpush_progressbar.xml" target-dir="res/drawable" />
|
||||||
<source-file src="src/android/ic_richpush_actionbar_divider.png" target-dir="res/drawable" />
|
|
||||||
<source-file src="src/android/richpush_btn_selector.xml" target-dir="res/drawable" />
|
|
||||||
<source-file src="src/android/jpush_popwin_layout.xml" target-dir="res/layout" />
|
|
||||||
<source-file src="src/android/jpush_webview_layout.xml" target-dir="res/layout" />
|
|
||||||
<source-file src="src/android/jpush_style.xml" target-dir="res/values" />
|
|
||||||
|
|
||||||
|
<source-file src="src/android/res/drawable-hdpi/jpush_ic_richpush_actionbar_back.png" target-dir="res/drawable-hdpi" />
|
||||||
|
<source-file src="src/android/res/drawable-hdpi/jpush_ic_richpush_actionbar_divider.png" target-dir="res/drawable-hdpi" />
|
||||||
|
|
||||||
|
<source-file src="src/android/res/layout/jpush_popwin_layout.xml" target-dir="res/layout" />
|
||||||
|
<source-file src="src/android/res/layout/jpush_webview_layout.xml" target-dir="res/layout" />
|
||||||
|
<source-file src="src/android/res/layout/test_notification_layout.xml" target-dir="res/layout" />
|
||||||
|
|
||||||
|
<source-file src="src/android/res/values/jpush_style.xml" target-dir="res/values" />
|
||||||
</platform>
|
</platform>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@@ -438,6 +438,9 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义通知行为,声音、震动、呼吸灯等。
|
||||||
|
*/
|
||||||
void setBasicPushNotificationBuilder(JSONArray data,
|
void setBasicPushNotificationBuilder(JSONArray data,
|
||||||
CallbackContext callbackContext) {
|
CallbackContext callbackContext) {
|
||||||
BasicPushNotificationBuilder builder = new BasicPushNotificationBuilder(
|
BasicPushNotificationBuilder builder = new BasicPushNotificationBuilder(
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 695 B After Width: | Height: | Size: 695 B |
|
Before Width: | Height: | Size: 181 B After Width: | Height: | Size: 181 B |
@@ -5,7 +5,7 @@
|
|||||||
android:state_focused="true"
|
android:state_focused="true"
|
||||||
android:state_enabled="true"
|
android:state_enabled="true"
|
||||||
android:state_pressed="false"
|
android:state_pressed="false"
|
||||||
android:drawable="@drawable/ic_richpush_actionbar_back" />
|
android:drawable="@drawable/jpush_ic_richpush_actionbar_back" />
|
||||||
<!-- 按下时的背景图片 -->
|
<!-- 按下时的背景图片 -->
|
||||||
<item
|
<item
|
||||||
android:state_enabled="true"
|
android:state_enabled="true"
|
||||||
@@ -17,5 +17,5 @@
|
|||||||
android:state_checked="true"
|
android:state_checked="true"
|
||||||
android:drawable="@android:color/darker_gray" />
|
android:drawable="@android:color/darker_gray" />
|
||||||
<!-- 默认时的背景图片 -->
|
<!-- 默认时的背景图片 -->
|
||||||
<item android:drawable="@drawable/ic_richpush_actionbar_back" />
|
<item android:drawable="@drawable/jpush_ic_richpush_actionbar_back" />
|
||||||
</selector>
|
</selector>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
|
<!-- 背景 gradient是渐变,corners定义的是圆角 -->
|
||||||
|
<item android:id="@android:id/background">
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#ffffff" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<!-- 进度条 -->
|
||||||
|
<item android:id="@android:id/progress">
|
||||||
|
<clip>
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#4393ea" />
|
||||||
|
</shape>
|
||||||
|
</clip>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
</layer-list>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginLeft="9dp"
|
android:layout_marginLeft="9dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:background="@drawable/richpush_btn_selector" />
|
android:background="@drawable/jpush_richpush_btn_selector" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imgView"
|
android:id="@+id/imgView"
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_toRightOf="@id/imgRichpushBtnBack"
|
android:layout_toRightOf="@id/imgRichpushBtnBack"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:src="@drawable/ic_richpush_actionbar_divider" />
|
android:src="@drawable/jpush_ic_richpush_actionbar_divider" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvRichpushTitle"
|
android:id="@+id/tvRichpushTitle"
|
||||||
@@ -35,6 +35,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginLeft="7dp"
|
android:layout_marginLeft="7dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
android:layout_toRightOf="@id/imgView"
|
android:layout_toRightOf="@id/imgView"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:text=" "
|
android:text=" "
|
||||||
@@ -42,6 +43,13 @@
|
|||||||
android:textColor="#ffffff" />
|
android:textColor="#ffffff" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/pushPrograssBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:progress="0"
|
||||||
|
android:progressDrawable="@drawable/jpush_richpush_progressbar"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal" />
|
||||||
<WebView
|
<WebView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -79,9 +79,12 @@
|
|||||||
|
|
||||||
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{
|
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{
|
||||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:response.notification.request.content.userInfo];
|
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:response.notification.request.content.userInfo];
|
||||||
|
@try {
|
||||||
|
[userInfo setValue:[response valueForKey:@"userText"] forKey:@"userText"];
|
||||||
|
} @catch (NSException *exception) { }
|
||||||
|
[userInfo setValue:response.actionIdentifier forKey:@"actionIdentifier"];
|
||||||
[userInfo setValue:kJPushPluginiOS10ClickNotification forKey:@"JPushNotificationType"];
|
[userInfo setValue:kJPushPluginiOS10ClickNotification forKey:@"JPushNotificationType"];
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginiOS10ClickNotification object:userInfo];
|
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginiOS10ClickNotification object:userInfo];
|
||||||
|
|
||||||
completionHandler();
|
completionHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,10 @@
|
|||||||
//检查用户的推送设置情况
|
//检查用户的推送设置情况
|
||||||
-(void)getUserNotificationSettings:(CDVInvokedUrlCommand*)command;
|
-(void)getUserNotificationSettings:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
|
//ios 10 APIs
|
||||||
|
-(void)addDismissActions:(CDVInvokedUrlCommand*)command;
|
||||||
|
-(void)addNotificationActions:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 以下为js中可监听到的事件
|
* 以下为js中可监听到的事件
|
||||||
* jpush.openNotification 点击推送消息启动或唤醒app
|
* jpush.openNotification 点击推送消息启动或唤醒app
|
||||||
|
|||||||
@@ -308,6 +308,44 @@ static NSDictionary *_launchOptions = nil;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - ios 10 APIs
|
||||||
|
|
||||||
|
-(void)addDismissActions:(CDVInvokedUrlCommand*)command{
|
||||||
|
[self addActions:command dismiss:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)addNotificationActions:(CDVInvokedUrlCommand*)command{
|
||||||
|
[self addActions:command dismiss:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)addActions:(CDVInvokedUrlCommand*)command dismiss:(BOOL)dimiss{
|
||||||
|
NSArray *actionsData = [command argumentAtIndex:0];
|
||||||
|
NSString *categoryId = [command argumentAtIndex:1];
|
||||||
|
NSMutableArray *actions = [NSMutableArray array];
|
||||||
|
for (NSDictionary *dict in actionsData) {
|
||||||
|
NSString *title = dict[@"title"];
|
||||||
|
NSString *identifier = dict[@"identifier"];
|
||||||
|
NSString *option = dict[@"option"];
|
||||||
|
NSString *type = dict[@"type"];
|
||||||
|
if ([type isEqualToString:@"textInput"]) {
|
||||||
|
NSString *textInputButtonTitle = dict[@"textInputButtonTitle"];
|
||||||
|
NSString *textInputPlaceholder = dict[@"textInputPlaceholder"];
|
||||||
|
UNTextInputNotificationAction *inputAction = [UNTextInputNotificationAction actionWithIdentifier:identifier title:title options:option.integerValue textInputButtonTitle:textInputButtonTitle textInputPlaceholder:textInputPlaceholder];
|
||||||
|
[actions addObject:inputAction];
|
||||||
|
}else{
|
||||||
|
UNNotificationAction *action = [UNNotificationAction actionWithIdentifier:title title:title options:option.integerValue];
|
||||||
|
[actions addObject:action];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UNNotificationCategory *category;
|
||||||
|
if (dimiss) {
|
||||||
|
category = [UNNotificationCategory categoryWithIdentifier:categoryId actions:actions intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
|
||||||
|
}else{
|
||||||
|
category = [UNNotificationCategory categoryWithIdentifier:categoryId actions:actions intentIdentifiers:@[] options:UNNotificationCategoryOptionNone];
|
||||||
|
}
|
||||||
|
[[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:category]];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - 内部方法
|
#pragma mark - 内部方法
|
||||||
+(void)setLaunchOptions:(NSDictionary *)theLaunchOptions{
|
+(void)setLaunchOptions:(NSDictionary *)theLaunchOptions{
|
||||||
_launchOptions = theLaunchOptions;
|
_launchOptions = theLaunchOptions;
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
//
|
||||||
|
// NotificationService.h
|
||||||
|
// jpushNotificationService
|
||||||
|
//
|
||||||
|
// Created by wuxingchen on 16/10/10.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <UserNotifications/UserNotifications.h>
|
||||||
|
|
||||||
|
@interface NotificationService : UNNotificationServiceExtension
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// NotificationService.m
|
||||||
|
// jpushNotificationService
|
||||||
|
//
|
||||||
|
// Created by wuxingchen on 16/10/10.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "NotificationService.h"
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
@interface NotificationService ()
|
||||||
|
|
||||||
|
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
|
||||||
|
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NotificationService
|
||||||
|
|
||||||
|
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
|
||||||
|
|
||||||
|
self.contentHandler = contentHandler;
|
||||||
|
self.bestAttemptContent = [request.content mutableCopy];
|
||||||
|
|
||||||
|
@try {
|
||||||
|
NSString *urlStr = [request.content.userInfo valueForKey:@"JPushPluginAttachment"];
|
||||||
|
NSArray *urls = [urlStr componentsSeparatedByString:@"."];
|
||||||
|
NSURL *urlNative = [[NSBundle mainBundle] URLForResource:urls[0] withExtension:urls[1]];
|
||||||
|
UNNotificationAttachment *attachment = [UNNotificationAttachment attachmentWithIdentifier:urlStr URL:urlNative options:nil error:nil];
|
||||||
|
self.bestAttemptContent.attachments = @[attachment];
|
||||||
|
} @catch (NSException *exception) {
|
||||||
|
}
|
||||||
|
|
||||||
|
self.contentHandler(self.bestAttemptContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)serviceExtensionTimeWillExpire {
|
||||||
|
// Called just before the extension will be terminated by the system.
|
||||||
|
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
|
||||||
|
self.contentHandler(self.bestAttemptContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -222,6 +222,14 @@ JPushPlugin.prototype.getUserNotificationSettings = function (callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JPushPlugin.prototype.addDismissActions = function (actions, categoryId) {
|
||||||
|
this.call_native('addDismissActions', [actions, categoryId])
|
||||||
|
}
|
||||||
|
|
||||||
|
JPushPlugin.prototype.addNotificationActions = function (actions, categoryId) {
|
||||||
|
this.call_native('addNotificationActions', [actions, categoryId])
|
||||||
|
}
|
||||||
|
|
||||||
// Android methods
|
// Android methods
|
||||||
JPushPlugin.prototype.setDebugMode = function (mode) {
|
JPushPlugin.prototype.setDebugMode = function (mode) {
|
||||||
if (device.platform == 'Android') {
|
if (device.platform == 'Android') {
|
||||||
|
|||||||