Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
fixed autoupdate for ios
Browse files Browse the repository at this point in the history
  • Loading branch information
gerwinbrunner committed May 31, 2016
1 parent dd2d615 commit 29f725e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/ios/AssetBundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ final class AssetBundle {
}
}

/* Patch for AutoupdateServer */
var autoupdateServerURL: NSURL? {
if let autoupdateServerURLString = JSON["PUBLIC_SETTINGS"]!["AutoupdateServer"] as? String {
return NSURL(string: autoupdateServerURLString)
} else {
return nil
}
}
/* Patch for AutoupdateServer - End */

var autoupdateVersionCordova: String? {
return JSON["autoupdateVersionCordova"] as? String
}
Expand All @@ -137,6 +147,12 @@ final class AssetBundle {
var rootURL: NSURL? {
return runtimeConfig?.rootURL
}

/* Patch for AutoupdateServer */
var autoupdateServerURL: NSURL? {
return runtimeConfig?.autoupdateServerURL
}
/* Patch for AutoupdateServer - End */

func didMoveToDirectoryAtURL(directoryURL: NSURL) {
self.directoryURL = directoryURL
Expand Down
20 changes: 20 additions & 0 deletions src/ios/WebAppConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@ final class WebAppConfiguration {
}
}
}

/* Patch for AutoupdateServer */
var autoupdateServerURL: NSURL? {
get {
return userDefaults.URLForKey("MeteorWebAppAutoupdateServerURL")
}
set {
let oldValue = autoupdateServerURL
if newValue != oldValue && newValue != nil {
if oldValue != nil {
NSLog("AutoupdateServerURL seems to have changed, new: \(newValue!), old: \(oldValue!)")
}

userDefaults.setURL(newValue, forKey: "MeteorWebAppAutoupdateServerURL")
userDefaults.synchronize()
}
}
}
/* Patch for AutoupdateServer - End */


/// The Cordova compatibility version as specified in the asset manifest
var cordovaCompatibilityVersion: String? {
Expand Down
11 changes: 10 additions & 1 deletion src/ios/WebAppLocalServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public class WebAppLocalServer: METPlugin, AssetBundleManagerDelegate {
configuration.cordovaCompatibilityVersion = currentAssetBundle.cordovaCompatibilityVersion

NSLog("Serving asset bundle version: \(currentAssetBundle.version)")

/* Patch for AutoupdateServer */
configuration.autoupdateServerURL = currentAssetBundle.autoupdateServerURL
NSLog("Serving asset bundle autoupdateServerURL: \(currentAssetBundle.autoupdateServerURL)")
/* Patch for AutoupdateServer - End */

}
}
}
Expand Down Expand Up @@ -229,7 +235,10 @@ public class WebAppLocalServer: METPlugin, AssetBundleManagerDelegate {
}

public func checkForUpdates(command: CDVInvokedUrlCommand) {
guard let rootURL = configuration.rootURL else {
/* Patch for AutoupdateServer */
guard let rootURL = configuration.autoupdateServerURL else {
//guard let rootURL = configuration.rootURL else {
/* Patch for AutoupdateServer - End */
let errorMessage = "checkForUpdates requires a rootURL to be configured"
let result = CDVPluginResult(status: CDVCommandStatus_ERROR, messageAsString: errorMessage)
commandDelegate?.sendPluginResult(result, callbackId: command.callbackId)
Expand Down

0 comments on commit 29f725e

Please sign in to comment.