|
|
@@ -15,6 +15,7 @@ import android.util.Log;
|
|
|
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.view.activity.MiddleAct;
|
|
|
+import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
|
|
|
import org.json.JSONException;
|
|
|
@@ -25,8 +26,6 @@ import java.util.Random;
|
|
|
|
|
|
import cn.jpush.android.api.JPushInterface;
|
|
|
|
|
|
-import static android.content.Context.NOTIFICATION_SERVICE;
|
|
|
-
|
|
|
/**
|
|
|
* Created by realicing on 2018/5/9.
|
|
|
* realicing@sina.com
|
|
|
@@ -163,16 +162,31 @@ public class SheepJpushReceiver extends BroadcastReceiver {
|
|
|
// .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.icon))
|
|
|
// .setSmallIcon(R.mipmap.remenyx)//系统状态栏显示的小图标 remenyx
|
|
|
.setSmallIcon(R.drawable.icon)
|
|
|
+ .setTicker(title)
|
|
|
+ .setDefaults(Notification.DEFAULT_VIBRATE)
|
|
|
.setWhen(System.currentTimeMillis())
|
|
|
.setTicker(title)//Ticker是状态栏显示的提示
|
|
|
.setDefaults(NotificationCompat.DEFAULT_ALL);
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
- notificationBuilder.setContentTitle(appName)//第一行内容 通常作为通知栏标题
|
|
|
+ notificationBuilder.setContentTitle(title)//第一行内容 通常作为通知栏标题
|
|
|
.setOngoing(true)//禁止滑动删除
|
|
|
- .setContentText(title);//第二行内容 通常是通知正文
|
|
|
- NotificationChannel mChannel = new NotificationChannel(String.valueOf(msgId), appName, NotificationManager.IMPORTANCE_HIGH);
|
|
|
- mNotificationManager.createNotificationChannel(mChannel);
|
|
|
- } else {
|
|
|
+ .setContentText(msg);//第二行内容 通常是通知正文
|
|
|
+ NotificationChannel channel = new NotificationChannel(String.valueOf(msgId), appName, NotificationManager.IMPORTANCE_HIGH);
|
|
|
+ channel.canBypassDnd();//是否可以绕过请勿打扰模式
|
|
|
+ channel.canShowBadge();//是否可以显示icon角标
|
|
|
+ channel.enableLights(true);//是否显示通知闪灯
|
|
|
+ channel.enableVibration(true);//收到小时时震动提示
|
|
|
+ channel.setBypassDnd(true);//设置绕过免打扰
|
|
|
+ channel.setLockscreenVisibility(NotificationCompat.VISIBILITY_SECRET);
|
|
|
+ channel.setLightColor(context.getColor(R.color.theme_app_main));//设置闪光灯颜色
|
|
|
+ channel.getAudioAttributes();//获取设置铃声设置
|
|
|
+ channel.setVibrationPattern(new long[]{100, 200, 100});//设置震动模式
|
|
|
+ channel.shouldShowLights();//是否会闪光
|
|
|
+ mNotificationManager.createNotificationChannel(channel);
|
|
|
+ } else if(BuildConfig.DEBUG) {
|
|
|
+ notificationBuilder.setContentTitle(title)//第一行内容 通常作为通知栏标题
|
|
|
+ .setContentText(msg);//第二行内容 通常是通知正文
|
|
|
+ } else {//下面部分为测试部分
|
|
|
notificationBuilder.setContentTitle(appName)//第一行内容 通常作为通知栏标题
|
|
|
.setContentText(title);//第二行内容 通常是通知正文
|
|
|
if (!TextUtils.isEmpty(msg)) {
|