Skip to content

Commit

Permalink
feat: disable autoupdate in livereload mode + warning
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Apr 13, 2023
1 parent 7746388 commit d3c2838
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,20 @@ private void _checkCancelDelay(Boolean killed) {
}

private Boolean _isAutoUpdateEnabled() {
final CapConfig config = CapConfig.loadDefault(this.getActivity());
String serverUrl = config.getServerUrl();
if (serverUrl != null && !"".equals(serverUrl)) {
// log warning autoupdate disabled when serverUrl is set
Log.w(
CapacitorUpdater.TAG,
"AutoUpdate is automatic disabled when serverUrl is set."
);
}
return (
CapacitorUpdaterPlugin.this.autoUpdate &&
!"".equals(CapacitorUpdaterPlugin.this.updateUrl)
!"".equals(CapacitorUpdaterPlugin.this.updateUrl) &&
serverUrl != null &&
!"".equals(serverUrl)
);
}

Expand Down
8 changes: 7 additions & 1 deletion ios/Plugin/CapacitorUpdaterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,11 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
}

private func _isAutoUpdateEnabled() -> Bool {
return self.autoUpdate && self.updateUrl != ""
let instanceDescriptor = (self.bridge?.viewController as? CAPBridgeViewController)?.instanceDescriptor()
if instanceDescriptor?.serverURL != nil {
print("⚠️ \(self.implementation.TAG) AutoUpdate is automatic disabled when serverUrl is set.")
}
return self.autoUpdate && self.updateUrl != "" && instanceDescriptor?.serverURL == nil
}

@objc func isAutoUpdateEnabled(_ call: CAPPluginCall) {
Expand Down Expand Up @@ -632,6 +636,8 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
}
if self._isAutoUpdateEnabled() {
self.backgroundDownload()
} else {
print("\(self.implementation.TAG) Auto update is disabled")
}
self.checkAppReady()
}
Expand Down

0 comments on commit d3c2838

Please sign in to comment.