Search in sources :

Example 1 with ModelsMobileApiMessagesRegistrationRequest

use of com.appspot.tbatv_prod_hrd.model.ModelsMobileApiMessagesRegistrationRequest in project the-blue-alliance-android by the-blue-alliance.

the class MyTbaDatafeed method unregister.

@WorkerThread
public boolean unregister() {
    TbaLogger.d("Unregistering for GCM");
    if (!ConnectionDetector.isConnectedToInternet(mApplicationContext)) {
        return false;
    }
    String authHeader = mAuthController.getAuthHeader();
    ModelsMobileApiMessagesRegistrationRequest request = new ModelsMobileApiMessagesRegistrationRequest();
    request.mobile_id = mGcmController.getRegistrationId();
    request.operating_system = GcmController.OS_ANDROID;
    request.device_uuid = Utilities.getDeviceUUID(mApplicationContext);
    Response<ModelsMobileApiMessagesBaseResponse> response = null;
    try {
        response = mTbaMobile.unregister(authHeader, request).execute();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return (response != null && (response.code() == 200 || response.code() == 304));
}
Also used : ModelsMobileApiMessagesBaseResponse(com.appspot.tbatv_prod_hrd.model.ModelsMobileApiMessagesBaseResponse) ModelsMobileApiMessagesRegistrationRequest(com.appspot.tbatv_prod_hrd.model.ModelsMobileApiMessagesRegistrationRequest) IOException(java.io.IOException) WorkerThread(androidx.annotation.WorkerThread)

Example 2 with ModelsMobileApiMessagesRegistrationRequest

use of com.appspot.tbatv_prod_hrd.model.ModelsMobileApiMessagesRegistrationRequest in project the-blue-alliance-android by the-blue-alliance.

the class MyTbaDatafeed method register.

@WorkerThread
public boolean register(String regId) {
    TbaLogger.d("Registering for GCM");
    if (!ConnectionDetector.isConnectedToInternet(mApplicationContext)) {
        return false;
    }
    String authHeader = mAuthController.getAuthHeader();
    ModelsMobileApiMessagesRegistrationRequest request = new ModelsMobileApiMessagesRegistrationRequest();
    request.mobile_id = regId;
    request.operating_system = GcmController.OS_ANDROID;
    request.device_uuid = Utilities.getDeviceUUID(mApplicationContext);
    if (BuildConfig.DEBUG) {
        request.name = android.os.Build.MODEL + " (Debug)";
    } else {
        request.name = android.os.Build.MODEL;
    }
    Response<ModelsMobileApiMessagesBaseResponse> response = null;
    try {
        response = mTbaMobile.register(authHeader, request).execute();
        TbaLogger.d("MyTBA Registration response: " + response);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return (response != null && (response.code() == 200 || response.code() == 304));
}
Also used : ModelsMobileApiMessagesBaseResponse(com.appspot.tbatv_prod_hrd.model.ModelsMobileApiMessagesBaseResponse) ModelsMobileApiMessagesRegistrationRequest(com.appspot.tbatv_prod_hrd.model.ModelsMobileApiMessagesRegistrationRequest) IOException(java.io.IOException) WorkerThread(androidx.annotation.WorkerThread)

Aggregations

WorkerThread (androidx.annotation.WorkerThread)2 ModelsMobileApiMessagesBaseResponse (com.appspot.tbatv_prod_hrd.model.ModelsMobileApiMessagesBaseResponse)2 ModelsMobileApiMessagesRegistrationRequest (com.appspot.tbatv_prod_hrd.model.ModelsMobileApiMessagesRegistrationRequest)2 IOException (java.io.IOException)2