Fetch messages & ping friends when application becomes active

This commit is contained in:
Niels Andriesse 2019-05-08 11:42:31 +10:00
parent cc1f41c11b
commit 3c7b769d20

View file

@ -718,6 +718,12 @@ static NSTimeInterval launchStartedAt;
[Environment.shared.contactsManager fetchSystemContactsOnceIfAlreadyAuthorized];
[[AppEnvironment.shared.messageFetcherJob run] retainUntilComplete];
[LokiAPI getMessages:^(id response, NSError *error) {
// TODO: Use the response
}];
// TODO: Ping friends to let them know we're online
if (![UIApplication sharedApplication].isRegisteredForRemoteNotifications) {
OWSLogInfo(@"Retrying to register for remote notifications since user hasn't registered yet.");
// Push tokens don't normally change while the app is launched, so checking once during launch is
@ -1152,6 +1158,7 @@ static NSTimeInterval launchStartedAt;
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
[LokiAPI getMessages:^(id response, NSError *error) {
if (response != nil) {
// TODO: Use the response
completionHandler(UIBackgroundFetchResultNewData);
} else {
completionHandler(UIBackgroundFetchResultFailed);