Upload a Firebase Token to Hurree

Open MyFirebaseInstanceIDService and add following lines of code, substituting the appropriate placeholder strings with the real keys and values for your application.

public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {

    private static final String TAG = MyFirebaseInstanceIDService.class.getSimpleName();
    private MyFirebaseInstanceIDService myFirebaseInstanceIDService = this;

    @Override
    public void onTokenRefresh() {

        super.onTokenRefresh();
        String refreshedToken = FirebaseInstanceId.getInstance().getToken();

        // Sending Reg ID to your server
        sendRegistrationToServer(refreshedToken);
    }

    private void sendRegistrationToServer(final String token){
        Analytics.getInstance(this).deportKeyValues(
                // Your android app key - get this from your Hurree App Group - Android App Settings
                "YOUR APP KEY",
                // Your hurree app group key - get this from your Hurree app group settings
                "YOUR APP GROUP KEY",
                // This is a unique identifier for the user.
                "850",
                // The token passed to this method
                token,
                // The timer value in minutes
                5
        );

        // This is an implicit login call example - this can be moved to explicit login functionality elsewhere
        // See an example of this in the provided sample application.
        Analytics.getInstance(this).deportUserLoginValues(
                "FIRST_NAME",
                "LAST_NAME",
                "PHONE_NUMBER",
                "EMAIL",
                "IMAGE URL",
                "GENDER",
                "DOB"
        );
        Analytics.getInstance(this).sendLoginDetails(new CallBack() {
             @Override
             public void onSuccess(String response) {
                 // Action on Success
             }

             @Override
             public void onFailure(String error) {
                // Action on Fail
             }
         }

        );
    }
}

Create a MyFirebaseMessagingService service to handle FCM messages sent from the Hurree server.

  1. From Android Studio, open your project.
  2. Go to File > New > Service > Service. FCM message received service

results matching ""

    No results matching ""