app/src/main/java/fr/neamar/lolgamedata/service/NotificationService.java
/**
     * Called when message is received.
     */
Called when message is received.
Called when message is received .
@Override
    public void onMessageReceived(RemoteMessage message) {
        Map<String, String> data = message.getData();
        Log.i(TAG, "Received notification from " + message.getFrom());
        if (data.containsKey("gameId")) {
            long gameId = Long.parseLong(data.get("gameId"));
            String summonerName = data.get("summonerName");
            String region = data.get("region");
            int mapId = Integer.parseInt(data.get("mapId"));
            Account account = new Account(summonerName, region, "");
            displayNotification(account, gameId, mapId);
        } else if (data.containsKey("removeGameId")) {
            long gameId = Long.parseLong(data.get("removeGameId"));
            Log.i(TAG, "End of game, hiding notification.");
            getNotificationManager().cancel(Long.toString(gameId).hashCode());
        } else if (data.containsKey("mp_message")) {
            String title = data.containsKey("mp_title") ? data.get("mp_title") : getString(R.string.app_name);
            String content = data.get("mp_message");
            String url = data.containsKey("mp_url") ? data.get("mp_url") : "";
            displayCustomNotification(title, content, url);
        } else {
            Log.i(TAG, "Received unknown notification:" + data.toString());
        }
    }
@ Override public void onMessageReceived ( RemoteMessage message ) { Map < String , String > data = message . getData ( ) ; Log . i ( TAG , "Received notification from " + message . getFrom ( ) ) ; if ( data . containsKey ( "gameId" ) ) { long gameId = Long . parseLong ( data . get ( "gameId" ) ) ; String summonerName = data . get ( "summonerName" ) ; String region = data . get ( "region" ) ; int mapId = Integer . parseInt ( data . get ( "mapId" ) ) ; Account account = new Account ( summonerName , region , "" ) ; displayNotification ( account , gameId , mapId ) ; } else if ( data . containsKey ( "removeGameId" ) ) { long gameId = Long . parseLong ( data . get ( "removeGameId" ) ) ; Log . i ( TAG , "End of game, hiding notification." ) ; getNotificationManager ( ) . cancel ( Long . toString ( gameId ) . hashCode ( ) ) ; } else if ( data . containsKey ( "mp_message" ) ) { String title = data . containsKey ( "mp_title" ) ? data . get ( "mp_title" ) : getString ( R . string . app_name ) ; String content = data . get ( "mp_message" ) ; String url = data . containsKey ( "mp_url" ) ? data . get ( "mp_url" ) : "" ; displayCustomNotification ( title , content , url ) ; } else { Log . i ( TAG , "Received unknown notification:" + data . toString ( ) ) ; } }
Called when message is received.
Called when message is received .