Download for iOS v1 (#1300)
* handle iOS scenario again * fixed logic * fix steps * add message * fix escaping * fix download button
This commit is contained in:
		@@ -1,6 +1,10 @@
 | 
			
		||||
# Troubleshooting downloads with WebUSB
 | 
			
		||||
 | 
			
		||||
This is a troubleshooting to use [WebUSB](/usb/webusb).
 | 
			
		||||
### ~ avatar
 | 
			
		||||
 | 
			
		||||
Having issues pairing your @boardname@ with [WebUSB](/usb/webusb)? Let's try to figure out why!
 | 
			
		||||
 | 
			
		||||
### ~
 | 
			
		||||
 | 
			
		||||
## Step 1: Check your cable
 | 
			
		||||
 | 
			
		||||
@@ -35,10 +39,11 @@ If the version is **0250** or higher, **you have the right firmware**. You can c
 | 
			
		||||
 | 
			
		||||
1. Put your @boardname@ into **MAINTENANCE Mode**. To do this, unplug the USB cable from the @boardname@ and then re-connect the USB cable while you hold down the reset button. Once you insert the cable, you can release the reset button. You should now see a **MAINTENANCE** drive instead of the **MICROBIT** drive like before. Also, a yellow LED light will stay on next to the reset button.
 | 
			
		||||

 | 
			
		||||
2. **[Download the firmware .hex file](https://support.microbit.org/helpdesk/attachments/19008095092)**
 | 
			
		||||
3. Drag and drop that file onto the **MAINTENANCE** drive.
 | 
			
		||||
4. The yellow LED will flash while the `HEX` file is copying. When the copy finishes, the LED will go off and the @boardname@ resets. The **MAINTENANCE** drive now changes back to **MICROBIT**.
 | 
			
		||||
5. The upgrade is complete! You can open the **DETAILS.TXT** file to check and see that the firmware version changed to the match the version of the `HEX` file you copied.
 | 
			
		||||
2. **[Download the firmware ZIP file](https://github.com/ARMmbed/DAPLink/releases/download/v0250/0250_release_package_682d8303.zip)**
 | 
			
		||||
3. Find the **0250_kl26z_microbit_0x8000.hex** in the downloaded zip file **0250_release_package_682d8303.zip**
 | 
			
		||||
4. Drag and drop that file onto the **MAINTENANCE** drive.
 | 
			
		||||
5. The yellow LED will flash while the `HEX` file is copying. When the copy finishes, the LED will go off and the @boardname@ resets. The **MAINTENANCE** drive now changes back to **MICROBIT**.
 | 
			
		||||
6. The upgrade is complete! You can open the **DETAILS.TXT** file to check and see that the firmware version changed to the match the version of the `HEX` file you copied.
 | 
			
		||||
 | 
			
		||||
### ~hint
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -938,17 +938,22 @@ namespace pxt.editor {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function showUploadInstructionsAsync(fn: string, url: string, confirmAsync: (options: any) => Promise<number>) {
 | 
			
		||||
        const boardName = pxt.appTarget.appTheme.boardName || "???";
 | 
			
		||||
        const boardDriveName = pxt.appTarget.appTheme.driveDisplayName || pxt.appTarget.compile.driveName || "???";
 | 
			
		||||
        const boardName = Util.htmlEscape(pxt.appTarget.appTheme.boardName || "???");
 | 
			
		||||
        const boardDriveName = Util.htmlEscape(pxt.appTarget.appTheme.driveDisplayName || pxt.appTarget.compile.driveName || "???");
 | 
			
		||||
 | 
			
		||||
        // https://msdn.microsoft.com/en-us/library/cc848897.aspx
 | 
			
		||||
        // "For security reasons, data URIs are restricted to downloaded resources.
 | 
			
		||||
        // Data URIs cannot be used for navigation, for scripting, or to populate frame or iframe elements"
 | 
			
		||||
        const userDownload = pxt.BrowserUtils.isBrowserDownloadWithinUserContext();
 | 
			
		||||
        const downloadAgain = !pxt.BrowserUtils.isIE() && !pxt.BrowserUtils.isEdge();
 | 
			
		||||
        const docUrl = pxt.appTarget.appTheme.usbDocs;
 | 
			
		||||
 | 
			
		||||
        const htmlBody = `
 | 
			
		||||
        <div class="ui grid stackable">
 | 
			
		||||
        const body =
 | 
			
		||||
            userDownload
 | 
			
		||||
                ? lf("Click 'Download' to open the {0} app.", pxt.appTarget.appTheme.boardName || "")
 | 
			
		||||
                : undefined;
 | 
			
		||||
        const htmlBody = !userDownload ?
 | 
			
		||||
            `<div class="ui grid stackable">
 | 
			
		||||
            <div class="column sixteen wide">
 | 
			
		||||
                <div class="ui grid">
 | 
			
		||||
                    <div class="row">
 | 
			
		||||
@@ -989,15 +994,15 @@ namespace pxt.editor {
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>`;
 | 
			
		||||
        </div>` : undefined;
 | 
			
		||||
 | 
			
		||||
        const buttons: any[] = [];
 | 
			
		||||
 | 
			
		||||
        if (downloadAgain) {
 | 
			
		||||
            buttons.push({
 | 
			
		||||
                label: fn,
 | 
			
		||||
                label: userDownload ? lf("Download") : fn,
 | 
			
		||||
                icon: "download",
 | 
			
		||||
                className: "lightgrey focused",
 | 
			
		||||
                class: `${userDownload ? "primary" : "lightgrey"}`,
 | 
			
		||||
                url,
 | 
			
		||||
                fileName: fn
 | 
			
		||||
            });
 | 
			
		||||
@@ -1014,6 +1019,7 @@ namespace pxt.editor {
 | 
			
		||||
 | 
			
		||||
        return confirmAsync({
 | 
			
		||||
            header: lf("Download to your {0}", pxt.appTarget.appTheme.boardName),
 | 
			
		||||
            body,
 | 
			
		||||
            htmlBody,
 | 
			
		||||
            hasCloseIcon: true,
 | 
			
		||||
            hideCancel: true,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user