Install a programmatically downloaded ipa on an iOS device

纵饮孤独 提交于 2020-01-24 00:54:10

问题


I am programmatically downloading an ipa file (enterprise version of my app) and prompting the user to install it.

The problem is similar to Download and install an ipa from url on iOS, but the difference is that the ipa is already downloaded in my case.

I tried the following variation for the above problem's solution:

  • Modify the plist to contain URL to the local downloaded ipa.

```

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>items</key>
    <array>
        <dict>
            <key>assets</key>
            <array>
                <dict>
                    <key>kind</key>
                    <string>software-package</string>
                    <key>url</key>
                    <string>file://{path-to-local-ipa}</string>
                </dict>
            </array>
            <key>metadata</key>
            <dict>
                <key>bundle-identifier</key>
                <string>com.yourCompany.productName</string>
                <key>bundle-version</key>
                <string>1</string>
                <key>kind</key>
                <string>software</string>
                <key>title</key>
                <string>productName</string>
            </dict>
        </dict>
    </array>
</dict>
</plist>

```

  • Update itms link to point to the locally updated plist file - itms-services://?action=download-manifest&url=file://{path-to-local-plist}

But, when opening the itms link using [[UIApplication sharedApplication] openURL:itmsLink] it doesn't work and gives me an error saying Cannot install applications because the certificate for (null) is not valid

This is with reference to how Facebook distributes its internal app for dogfooding. Want to do something similar so that the user is prompted to install the app after the app is downloaded, thus increasing the turnaround rate for its installation.


回答1:


You should check your certificates and bundle ID first. The error message gives enough info, you see there is a 'null' which means your app does not have a bundle id? Check your app's bundle ID, certificate settings, provisioning file settings, to make sure they are matched with each other.

One thing you could try to validate your app is, open Xcode-Window-Devices, choose your iPhone device which is connected to your macbook, and drag the ipa you just archived into the apps area, to see if it can be installed. If it can be, check your URL's bundle identifier to be the same one as your app. You should be good to go.

We do similar things like yours. We also distribute our app via in-house distribution.

We will check if there is a version, we will pop up a UIAlertView and ask user to update. User can click OK button, and it will start downloading and installing automatically.

The OK Button's code is like this:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (alertView == updateAlert){
        if (buttonIndex == 1 || _forceUpdate) {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:Download_URL]];
        }
    }
}

Where Download_URL can be itms-services://?action=download-manifest&url=file://{path-to-local-plist} in your case.



来源:https://stackoverflow.com/questions/34502651/install-a-programmatically-downloaded-ipa-on-an-ios-device

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!