Skip to content

Commit 206c01e

Browse files
author
Wonday
committed
fix sample codes
1 parent b4d7a11 commit 206c01e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ v1.0.14
1010
1. 修正ios未启动app点击通知提示不在主线程执行
1111
2. 升级ShortcutBadger v1.1.22
1212
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)
13+
4. 支持android8.0推送通道设置(MainApplication中加入代码有更新,注意查看readme.MD历史确认代码变更点),[阿里云文档](https://help.aliyun.com/knowledge_detail/67398.html)
1414

1515

1616
v1.0.13
@@ -171,7 +171,7 @@ import com.alibaba.sdk.android.push.register.GcmRegister;
171171
super.onCreate();
172172
173173
//下面是添加的代码
174-
this.initCloudChannel();
174+
this.initCloudChannel(this);
175175
//添加结束
176176
}
177177
@@ -180,14 +180,14 @@ import com.alibaba.sdk.android.push.register.GcmRegister;
180180
* 初始化阿里云推送通道
181181
* @param applicationContext
182182
*/
183-
private void initCloudChannel() {
183+
private void initCloudChannel(final Context applicationContext) {
184184
185185
// 创建notificaiton channel
186186
this.createNotificationChannel();
187-
PushServiceFactory.init(this.getApplicationContext());
187+
PushServiceFactory.init(applicationContext);
188188
CloudPushService pushService = PushServiceFactory.getCloudPushService();
189189
pushService.setNotificationSmallIcon(R.mipmap.ic_launcher_s);//设置通知栏小图标, 需要自行添加
190-
pushService.register(this.getApplicationContext(), "阿里云appKey", "阿里云appSecret", new CommonCallback() {
190+
pushService.register(applicationContext, "阿里云appKey", "阿里云appSecret", new CommonCallback() {
191191
@Override
192192
public void onSuccess(String responnse) {
193193
// success
@@ -199,9 +199,9 @@ import com.alibaba.sdk.android.push.register.GcmRegister;
199199
});
200200
201201
// 注册方法会自动判断是否支持小米系统推送,如不支持会跳过注册。
202-
MiPushRegister.register(this.getApplicationContext(), "小米AppID", "小米AppKey");
202+
MiPushRegister.register(applicationContext, "小米AppID", "小米AppKey");
203203
// 注册方法会自动判断是否支持华为系统推送,如不支持会跳过注册。
204-
HuaWeiRegister.register(this.getApplicationContext());
204+
HuaWeiRegister.register(applicationContext);
205205
// 接入FCM/GCM初始化推送
206206
GcmRegister.register(applicationContext, "send_id", "application_id");
207207
}

0 commit comments

Comments
 (0)