Skip to content

Commit b4d7a11

Browse files
author
Wonday
committed
version up to v1.0.14
1 parent 1f755c9 commit b4d7a11

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66

77
### 修改履历
8+
9+
v1.0.14
10+
1. 修正ios未启动app点击通知提示不在主线程执行
11+
2. 升级ShortcutBadger v1.1.22
12+
3. 升级阿里云移动推送sdk android v3.1.4
13+
4. 支持android8.0推送通道设置(MainApplication中加入代码有更新,注意查看readme.MD历史确认代码变更点),[阿里云文档](https://help.aliyun.com/knowledge_detail/67398.html?accounttraceid=86ba30f0-d830-43ff-ae14-4a279fb43df5)
14+
15+
816
v1.0.13
917
1. 更新android build tool到v26.0.3
1018

@@ -130,13 +138,21 @@ dependencies {
130138
4. 确保MainApplication.java中被添加如下代码
131139
```
132140
// 下面是被添加的代码
141+
142+
import android.app.NotificationChannel;
143+
import android.app.NotificationManager;
144+
import android.content.Context;
145+
import android.graphics.Color;
146+
import android.os.Build;
147+
133148
import org.wonday.aliyun.push.AliyunPushPackage;
134149
135150
import com.alibaba.sdk.android.push.CloudPushService;
136151
import com.alibaba.sdk.android.push.CommonCallback;
137152
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
138153
import com.alibaba.sdk.android.push.register.HuaWeiRegister;
139154
import com.alibaba.sdk.android.push.register.MiPushRegister;
155+
import com.alibaba.sdk.android.push.register.GcmRegister;
140156
// 添加结束
141157
...
142158
@Override
@@ -153,7 +169,6 @@ import com.alibaba.sdk.android.push.register.MiPushRegister;
153169
@Override
154170
public void onCreate() {
155171
super.onCreate();
156-
SoLoader.init(this, /* native exopackage */ false);
157172
158173
//下面是添加的代码
159174
this.initCloudChannel();
@@ -166,6 +181,9 @@ import com.alibaba.sdk.android.push.register.MiPushRegister;
166181
* @param applicationContext
167182
*/
168183
private void initCloudChannel() {
184+
185+
// 创建notificaiton channel
186+
this.createNotificationChannel();
169187
PushServiceFactory.init(this.getApplicationContext());
170188
CloudPushService pushService = PushServiceFactory.getCloudPushService();
171189
pushService.setNotificationSmallIcon(R.mipmap.ic_launcher_s);//设置通知栏小图标, 需要自行添加
@@ -184,6 +202,33 @@ import com.alibaba.sdk.android.push.register.MiPushRegister;
184202
MiPushRegister.register(this.getApplicationContext(), "小米AppID", "小米AppKey");
185203
// 注册方法会自动判断是否支持华为系统推送,如不支持会跳过注册。
186204
HuaWeiRegister.register(this.getApplicationContext());
205+
// 接入FCM/GCM初始化推送
206+
GcmRegister.register(applicationContext, "send_id", "application_id");
207+
}
208+
209+
210+
private void createNotificationChannel() {
211+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
212+
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
213+
// 通知渠道的id
214+
String id = "1";
215+
// 用户可以看到的通知渠道的名字.
216+
CharSequence name = "notification channel";
217+
// 用户可以看到的通知渠道的描述
218+
String description = "notification description";
219+
int importance = NotificationManager.IMPORTANCE_HIGH;
220+
NotificationChannel mChannel = new NotificationChannel(id, name, importance);
221+
// 配置通知渠道的属性
222+
mChannel.setDescription(description);
223+
// 设置通知出现时的闪灯(如果 android 设备支持的话)
224+
mChannel.enableLights(true);
225+
mChannel.setLightColor(Color.RED);
226+
// 设置通知出现时的震动(如果 android 设备支持的话)
227+
mChannel.enableVibration(true);
228+
mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
229+
//最后在notificationmanager中创建该通知渠道
230+
mNotificationManager.createNotificationChannel(mChannel);
231+
}
187232
}
188233
// 添加结束
189234

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-aliyun-push",
3-
"version": "1.0.13",
3+
"version": "1.0.14",
44
"description": "A react native wrapper for aliyun push SDK",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)