0

나는 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으로 읽지을 설정해야하고, 난을 만들 때 나는 통지 나 자신을, 그리고의 포옹이 코드를 사용하여이 하나 하나 만들어 변경에 대한 생각 공고. 보류중인 의도로 넣을 수는 없습니다.

답변

1

몇 가지 옵션이 있습니다.

  1. onSmoochShown 대리자 콜백을 사용하십시오.

    대화가 표시되면이 콜백이 트리거되어 읽지 않은 개수를 업데이트 할 수 있습니다.

  2. onUnreadCountChanged 대리자 콜백을 사용하십시오.

    현재 사용자의 읽지 않은 횟수가 변경 될 때마다이 대리인이 호출됩니다. 이 콜백을 사용하여 길게 업데이트 할 수 있습니다.

당신이 통지가 도청 될 때 이러한 위임 콜백을 듣고 될 필요가 있기 때문에, 당신의 포옹을 초기화 한 후, 응용 프로그램의 onCreate에 대리자를 설정하는 것이 가장 좋습니다.

+0

예. 작동합니다. 대의원을 실천함으로써 가능했다. –