После обновления приложение не получает перезапущенную цель какао c - PullRequest
0 голосов
/ 08 февраля 2019

Я пытаюсь обновить приложение Mac, которое распространяется за пределами магазина приложений, поэтому следовал процессу, как предложено здесь После загрузки файла .pkg я открываю с помощью [[NSWorkspace sharedWorkspace] openFile:filePath.path];, но после успешно установленного приложенияне открывается, так что мне нужно сделать, чтобы после обновления приложения я захотел перезапустить приложение


    NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
    AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];

    NSURL *URL = [NSURL URLWithString:@"http://macappsupdate/localapp.pkg"];
    NSURLRequest *request = [NSURLRequest requestWithURL:URL];

    NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {

        NSLog(@"downloading in progress %@",downloadProgress);

    } destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {

        NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
        NSLog(@"documentsDirectoryURL %@",documentsDirectoryURL);
        return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];

    } completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {

        NSLog(@"File downloaded to: %@", filePath);
        NSAlert *alert = [NSAlert new];
        alert.messageText = @"You are currently using an old version of the app.\nTo enjoy the latest features please Upgrade!";
        [alert addButtonWithTitle:@"Update"];

        NSModalResponse response1 = [alert runModal];
        if(response1 == NSAlertFirstButtonReturn) {
            [[NSWorkspace sharedWorkspace] openFile:filePath.path];
            [NSApp terminate:nil];

        }


    }];
    [downloadTask resume];

Есть предложения?

Заранее спасибо !!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...