2017-12-15 1 views
0

Firebase를 통해 알림을 수신 할 수있는 Android 앱이 있습니다. 이러한 알림은 웹 사이트에서의 사용자 작업에 의해 트리거됩니다. 그런 다음 API는 Firebase에 알림 요청을 보냅니다.Android 앱은 알림 수신을 계속합니다.

그러나 최근에 내 앱이 계속해서 알림을 수신하는 문제가 발생했습니다. 이는 직접 알림 및 주제 메시지 모두에서 발생하는 것으로 보입니다. 처음에는 API가 어떤 종류의 루프에 빠져 있다고 생각했지만, Firebase 콘솔에서 직접 전송하는 알림에서도 이와 같은 현상이 나타나지 않습니다. 제 이론은 Firebase가 알림이 대상 장치에 도착하지 않았으므로 다시 보내고 있다고 생각합니다.

참고로, 내 앱의 iOS 버전에는이 문제가없는 것 같습니다.

onMessageReceived() :

@Override 
public void onMessageReceived(RemoteMessage message) { 
    Log.d(getClass().getName(), "Received notification"); 
    Map data = message.getData(); 
    try { 
     String scope = (String) data.get("scope"); 
     if(scope == null){ 
      Log.w(getClass().getName(), "Received notification with no scope"); 
      return; 
     } 

     String senderName = (String) data.get("senderName"); 
     String notificationMessage = (String) data.get("message"); 
     SharedPreferences notificationPreferences = getSharedPreferences(Constants.PREF_NOTIFICATION_SETTINGS, 0); 

     switch(scope){ 
      case Constants.NOTIFICATION_SCOPE_PROTOCOL: 
       handleProtocolUpdateMessage(data); 
       return; // PROTOCOL notifications are not stored in DB 
      case Constants.NOTIFICATION_SCOPE_USERSETTINGS: 
       handleUserSettingsUpdateMessage(data); 
       return; // USERSETTINGS notifications are not stored in DB 
      case Constants.NOTIFICATION_SCOPE_DEVICE: 
       if(notificationPreferences.getBoolean(Constants.PREF_DEVICE_NOTIFICATION_FILTER, true)){ 
        updateUnreadNotificationCounter(); 
        createNotification(scope, senderName, notificationMessage); 
       } 
       break; 
      case Constants.NOTIFICATION_SCOPE_INVENTORY: 
       if(notificationPreferences.getBoolean(Constants.PREF_INVENTORY_NOTIFICATION_FILTER, true)){ 
        updateUnreadNotificationCounter(); 
        createNotification(scope, senderName, notificationMessage); 
       } 
       break; 
      case Constants.NOTIFICATION_SCOPE_JOURNAL: 
       if(Application.test(this)){ 
        return; 
       }else{ 
        if(notificationPreferences.getBoolean(Constants.PREF_JOURNAL_NOTIFICATION_FILTER, true)){ 
         updateUnreadNotificationCounter(); 
         createNotification(scope, senderName, notificationMessage); 
        } 
       } 
       break; 
      case Constants.NOTIFICATION_SCOPE_SUPPLY: 
       if(notificationPreferences.getBoolean(Constants.PREF_SUPPLIES_NOTIFICATION_FILTER, true)){ 
        updateUnreadNotificationCounter(); 
        createNotification(scope, senderName, notificationMessage); 
       } 
       break; 
      case Constants.NOTIFICATION_SCOPE_SYSTEM: 
       if(notificationPreferences.getBoolean(Constants.PREF_SYSTEM_NOTIFICATION_FILTER, true)){ 
        updateUnreadNotificationCounter(); 
        if (Application.test(this)) { 
         createNotification(scope, "A", notificationMessage); 
        } else { 
         createNotification(scope, "B", notificationMessage); 
        } 
        break; 
       } 
       break; 
      default: 
       //If scope doesn't match any known scopes then return 
       return; 
     } 

     saveNotification(data); 
    }catch(ClassCastException e){ 
     Log.e(getClass().getName(), "Error while parsing notification contents", e); 
    } 
} 
+0

더 나은 이해를 위해 코드를 게시하십시오. – Raj

+0

@Raj 관련 코드를 추가했습니다. – Anubis

+0

ok 또한 createNotification 메소드의 코드를 게시하고 고유 알림 ID가 notify 메소드를 전달했는지 확인하십시오. – Raj

답변

1

나는 최신 버전 11.6.1 더 이상이 발생하는 것 같습니다 문제에 11.0.1에서 중포 기지를 업데이트했습니다.

관련 문제