Search in sources :

Example 1 with PushNotificationReceiveJob

use of org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob in project Signal-Android by WhisperSystems.

the class ApplicationContext method initializePendingMessages.

private void initializePendingMessages() {
    if (TextSecurePreferences.getNeedsMessagePull(this)) {
        Log.i(TAG, "Scheduling a message fetch.");
        if (Build.VERSION.SDK_INT >= 26) {
            FcmJobService.schedule(this);
        } else {
            ApplicationDependencies.getJobManager().add(new PushNotificationReceiveJob());
        }
        TextSecurePreferences.setNeedsMessagePull(this, false);
    }
}
Also used : PushNotificationReceiveJob(org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob)

Example 2 with PushNotificationReceiveJob

use of org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob in project Signal-Android by signalapp.

the class FcmFetchService method retrieveMessages.

static void retrieveMessages(@NonNull Context context) {
    BackgroundMessageRetriever retriever = ApplicationDependencies.getBackgroundMessageRetriever();
    boolean success = retriever.retrieveMessages(context, new RestStrategy(), new RestStrategy());
    if (success) {
        Log.i(TAG, "Successfully retrieved messages.");
    } else {
        if (Build.VERSION.SDK_INT >= 26) {
            Log.w(TAG, "Failed to retrieve messages. Scheduling on the system JobScheduler (API " + Build.VERSION.SDK_INT + ").");
            FcmJobService.schedule(context);
        } else {
            Log.w(TAG, "Failed to retrieve messages. Scheduling on JobManager (API " + Build.VERSION.SDK_INT + ").");
            ApplicationDependencies.getJobManager().add(new PushNotificationReceiveJob());
        }
    }
}
Also used : PushNotificationReceiveJob(org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob) BackgroundMessageRetriever(org.thoughtcrime.securesms.messages.BackgroundMessageRetriever) RestStrategy(org.thoughtcrime.securesms.messages.RestStrategy)

Example 3 with PushNotificationReceiveJob

use of org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob in project Signal-Android by WhisperSystems.

the class FcmFetchService method retrieveMessages.

static void retrieveMessages(@NonNull Context context) {
    BackgroundMessageRetriever retriever = ApplicationDependencies.getBackgroundMessageRetriever();
    boolean success = retriever.retrieveMessages(context, new RestStrategy(), new RestStrategy());
    if (success) {
        Log.i(TAG, "Successfully retrieved messages.");
    } else {
        if (Build.VERSION.SDK_INT >= 26) {
            Log.w(TAG, "Failed to retrieve messages. Scheduling on the system JobScheduler (API " + Build.VERSION.SDK_INT + ").");
            FcmJobService.schedule(context);
        } else {
            Log.w(TAG, "Failed to retrieve messages. Scheduling on JobManager (API " + Build.VERSION.SDK_INT + ").");
            ApplicationDependencies.getJobManager().add(new PushNotificationReceiveJob());
        }
    }
}
Also used : PushNotificationReceiveJob(org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob) BackgroundMessageRetriever(org.thoughtcrime.securesms.messages.BackgroundMessageRetriever) RestStrategy(org.thoughtcrime.securesms.messages.RestStrategy)

Example 4 with PushNotificationReceiveJob

use of org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob in project Signal-Android by signalapp.

the class ApplicationContext method initializePendingMessages.

private void initializePendingMessages() {
    if (TextSecurePreferences.getNeedsMessagePull(this)) {
        Log.i(TAG, "Scheduling a message fetch.");
        if (Build.VERSION.SDK_INT >= 26) {
            FcmJobService.schedule(this);
        } else {
            ApplicationDependencies.getJobManager().add(new PushNotificationReceiveJob());
        }
        TextSecurePreferences.setNeedsMessagePull(this, false);
    }
}
Also used : PushNotificationReceiveJob(org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob)

Aggregations

PushNotificationReceiveJob (org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob)4 BackgroundMessageRetriever (org.thoughtcrime.securesms.messages.BackgroundMessageRetriever)2 RestStrategy (org.thoughtcrime.securesms.messages.RestStrategy)2