나는 smooch을 구현했습니다. https://smooch.io/ 그리고 내 문제는 내가 smooch에서 알림을 얻을 때입니다. 내가 배경에 있다면, 나는 내가 smooch 버튼에 대한 나의 주요 활동에서 사용하는 "읽지 않은 메시지"를 오래 설정했다. 문제는 내가 알림을 누를 때 ConversationActivity가 거기서 시작된다는 것입니다. ConversationActivity가 열리기 때문에 읽지 않은 메시지를 0으로 설정해야합니다. 어떻게되는지 언제 알 수 있습니까?Smooch ConversationActivity, 활동이 시작된 시점을 어떻게 알 수 있습니까?
smooch 라이브러리에서 ConversationActivity.class를 수정할 수 없습니다.
private static void generateNotificationSmooch(final Context context, String title, String message) {
if (title == null)
title = context.getString(R.string.passenger_name);
Intent notificationIntent = new Intent(context, ConversationActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
int iUniqueId = (int) (System.currentTimeMillis() & 0xfffffff);
PendingIntent intent = PendingIntent.getActivity(context, iUniqueId, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
mBuilder.setContentTitle(title).setContentText(message).setSmallIcon(R.drawable.notification_icon);
mBuilder.setContentIntent(intent);
Notification notification = mBuilder.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notification);
}
하지만 알림을 누를 때 0으로 읽지을 설정해야하고, 난을 만들 때 나는 통지 나 자신을, 그리고의 포옹이 코드를 사용하여이 하나 하나 만들어 변경에 대한 생각 공고. 보류중인 의도로 넣을 수는 없습니다.
예. 작동합니다. 대의원을 실천함으로써 가능했다. –