Use BackgroundTasks

This commit is contained in:
Peter
2019-10-20 19:33:39 +04:00
parent 2a94ab2b41
commit 75aa77faa8
12 changed files with 362 additions and 32 deletions

View File

@@ -3,6 +3,10 @@
#import <UIKit/UIKit.h>
#import <BuildConfig/BuildConfig.h>
#ifdef __IPHONE_13_0
#import <BackgroundTasks/BackgroundTasks.h>
#endif
#import "StoredAccountInfos.h"
#import "Attachments.h"
#import "Api.h"
@@ -64,10 +68,17 @@ static int64_t makePeerId(int32_t namespace, int32_t value) {
}
- (void)completeWithContent:(UNNotificationContent * _Nonnull)content {
/*NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:@"org.telegram.Telegram-iOS.background"];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
NSURLSessionDownloadTask *task = [session downloadTaskWithURL:[NSURL URLWithString:@"https://telegram.org"]];
[task resume];*/
#ifdef __IPHONE_13_0
if (_baseAppBundleId != nil) {
BGAppRefreshTaskRequest *request = [[BGAppRefreshTaskRequest alloc] initWithIdentifier:[_baseAppBundleId stringByAppendingString:@".refresh"]];
request.earliestBeginDate = nil;
NSError *error = nil;
[[BGTaskScheduler sharedScheduler] submitTaskRequest:request error:&error];
if (error != nil) {
NSLog(@"Error: %@", error);
}
}
#endif
if (_contentHandler) {
_contentHandler(content);

View File

@@ -3,7 +3,7 @@
@implementation Serialization
- (NSUInteger)currentLayer {
return 106;
return 107;
}
- (id _Nullable)parseMessage:(NSData * _Nullable)data {