Search in sources :

Example 1 with Session

use of com.keylesspalace.tusky.entity.Session in project Tusky by Vavassor.

the class BaseActivity method enablePushNotifications.

protected void enablePushNotifications() {
    Callback<ResponseBody> callback = new Callback<ResponseBody>() {

        @Override
        public void onResponse(Call<ResponseBody> call, retrofit2.Response<ResponseBody> response) {
            if (response.isSuccessful()) {
                pushNotificationClient.subscribeToTopic(getPushNotificationTopic());
                pushNotificationClient.connect(BaseActivity.this);
            } else {
                onEnablePushNotificationsFailure(response.message());
            }
        }

        @Override
        public void onFailure(Call<ResponseBody> call, Throwable t) {
            onEnablePushNotificationsFailure(t.getMessage());
        }
    };
    String deviceToken = pushNotificationClient.getDeviceToken();
    Session session = new Session(getDomain(), getAccessToken(), deviceToken);
    tuskyApi.register(session).enqueue(callback);
}
Also used : Response(okhttp3.Response) Call(retrofit2.Call) Callback(retrofit2.Callback) ResponseBody(okhttp3.ResponseBody) Session(com.keylesspalace.tusky.entity.Session)

Example 2 with Session

use of com.keylesspalace.tusky.entity.Session in project Tusky by Vavassor.

the class BaseActivity method disablePushNotifications.

protected void disablePushNotifications() {
    Callback<ResponseBody> callback = new Callback<ResponseBody>() {

        @Override
        public void onResponse(Call<ResponseBody> call, retrofit2.Response<ResponseBody> response) {
            if (response.isSuccessful()) {
                pushNotificationClient.unsubscribeToTopic(getPushNotificationTopic());
            } else {
                onDisablePushNotificationsFailure();
            }
        }

        @Override
        public void onFailure(Call<ResponseBody> call, Throwable t) {
            onDisablePushNotificationsFailure();
        }
    };
    String deviceToken = pushNotificationClient.getDeviceToken();
    Session session = new Session(getDomain(), getAccessToken(), deviceToken);
    tuskyApi.unregister(session).enqueue(callback);
}
Also used : Response(okhttp3.Response) Call(retrofit2.Call) Callback(retrofit2.Callback) ResponseBody(okhttp3.ResponseBody) Session(com.keylesspalace.tusky.entity.Session)

Aggregations

Session (com.keylesspalace.tusky.entity.Session)2 Response (okhttp3.Response)2 ResponseBody (okhttp3.ResponseBody)2 Call (retrofit2.Call)2 Callback (retrofit2.Callback)2