package it.polito.mad.countonme.messaging;

import com.google.firebase.messaging.FirebaseMessaging;
import com.google.firebase.messaging.RemoteMessage;

import it.polito.mad.countonme.exceptions.InvalidDataException;

/**
 * Created by francescobruno on 20/05/17.
 */

public class MessagingManager {

    private FirebaseMessaging mMessaging;

    private static final MessagingManager sInstance = new MessagingManager();

    private MessagingManager() { mMessaging = FirebaseMessaging.getInstance(); }

    public static MessagingManager getInstance() { return sInstance; }

    public void  subscribeToSharingActivity( String shactKey ) throws InvalidDataException {
        if( shactKey != null && shactKey.length() > 0 )
            mMessaging.subscribeToTopic( shactKey );
        else
            throw new InvalidDataException( "subscribeToSharingActivity: Invalid topic" );
    }


    public void unsubscribeFromSharingActivity( String shactKey ) throws InvalidDataException {
        if( shactKey != null && shactKey.length() >0 )
            mMessaging.unsubscribeFromTopic( shactKey );
        else
            throw new InvalidDataException( "unsubscribeFromSharingActivity: Invalid topic" );
    }

    public void sendNewExpenseNotification( String shactKey, String expKey ) throws InvalidDataException {
        if( shactKey != null && expKey != null) {
            //RemoteMessage.Builder messBuilder = new RemoteMessage.Builder( getRegistrationToken() );
            //mMessaging.send();
        } else
            throw new InvalidDataException( "sendNewExpenseNotification: Invalid parameters" );
     }
}

@@ -884,17 +884,16 @@
 %0A    %7D%0A%0A
-%0A
     publ
@@ -1211,417 +1211,6 @@
  %7D%0A%0A
-    public void sendNewExpenseNotification( String shactKey, String expKey ) throws InvalidDataException %7B%0A        if( shactKey != null && expKey != null) %7B%0A            //RemoteMessage.Builder messBuilder = new RemoteMessage.Builder( getRegistrationToken() );%0A            //mMessaging.send();%0A        %7D else%0A            throw new InvalidDataException( %22sendNewExpenseNotification: Invalid parameters%22 );%0A     %7D%0A
 %7D%0A

remove useless method