如何在Android中停止重复推送通知声音和振动

时间:2019-11-15 13:09:57

标签: android push-notification

如何停止设备中重复出现的const disorders=[]; const arr = [1,2,3,4,5]; function execute(callback) { d3.csv("https://gist.githubusercontent.com/victoirebeaufils/bdc33d6da0fb98eacf4b6c7d630c280b/raw", function(data){ const disorder = data.disorder; disorders.push(data.disorder); callback(disorders); }); } execute(function(result) { console.log(result) console.log(result.length) console.log(arr) }); 声音和振动。 我没有使用PushNotification,但是即使通知音出现多次振铃,即使出现通知,我也不知道为什么。

在许多android设备上都观察到了此行为,只有少数设备符合预期。即一则通知=一声响动/震动。

我在这里用Samsung galaxy J7进行了测试,然后再次用Samsung galaxy j2 pro进行了测试,在这里它不是很好,但有一个通知但声音/振动蜂鸣了3次。

private void showNotifcation(PendingIntentendingIntent){         尝试{             NotificationManager notificationManager =(NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);             NotificationCompat.Builder builder =新的NotificationCompat.Builder(this,CHANNEL_ID)                     .setSmallIcon(R.drawable.ic_flogo1_med)                     .setColor(getResources()。getColor(R.color.gray20))                     .setContentTitle(datajson.getString(“ name”))                     .setContentText(messageData.getJSONObject(“ data”)。getString(“ text”))                     .setPriority(Notification.PRIORITY_HIGH)                     .setContentIntent(pendingIntent)                     .setOnlyAlertOnce(true)                     .setStyle(new NotificationCompat.BigTextStyle()。bigText(messageData.getJSONObject(“ data”)。getString(“ text”))));;             builder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI);             Uri通知= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);             铃声r = RingtoneManager.getRingtone(getApplicationContext(),notification);             r.play();

FLAG_INSISTENT

0 个答案:

没有答案