I'm new with the Android Notification Channel. I followed the tutorials from Google Dev docs about it, but I'm having some trouble when pushing notifications. My problem is, if I get a notification and swipe-cancel it or just don't click on it, the following notifications come with older swipe-cancelled or untouched notifications. Notifications are increasing cumulatively.
My code is below:
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
String channelId = "some_channel_id";
CharSequence channelName = "Some Channel";
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel notificationChannel = new NotificationChannel(channelId, channelName, importance);
notificationChannel.enableLights(true);
notificationChannel.setLightColor(Color.RED);
notificationChannel.enableVibration(true);
notificationChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
notificationManager.createNotificationChannel(notificationChannel);
int num = (int) System.currentTimeMillis();
Notification notification = new Notification.Builder(this)
.setContentTitle("Some Message")
.setContentText("You've received new messages!")
.setAutoCancel(true)
.setSmallIcon(R.drawable.fav_ico)
.setChannelId(channelId)
.build();
notificationManager.notify(num, notification);
Module Gradle :
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.support:design:26.1.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
compile "com.android.support:appcompat-v7:26.0.+"
compile 'com.google.firebase:firebase-core:12.0.1'
compile 'com.google.firebase:firebase-messaging:12.0.1'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'id.zelory:compressor:2.1.0'
compile 'net.gotev:uploadservice:3.0'
compile 'dev.dworks.libs:volleyplus:+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
Where am I making this mistake?