Skip to content

Commit

Permalink
fix: rename autoUpdateUrl in updateUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Jul 1, 2022
1 parent 4a605c0 commit 169676c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

@CapacitorPlugin(name = "CapacitorUpdater")
public class CapacitorUpdaterPlugin extends Plugin implements Application.ActivityLifecycleCallbacks {
private static final String autoUpdateUrlDefault = "https://xvwzpoazmxkqosrdewyv.functions.supabase.co/updates";
private static final String updateUrlDefault = "https://xvwzpoazmxkqosrdewyv.functions.supabase.co/updates";
private static final String statsUrlDefault = "https://xvwzpoazmxkqosrdewyv.functions.supabase.co/stats";
private static final String DELAY_UPDATE = "delayUpdate";

Expand All @@ -44,7 +44,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
private Boolean autoDeleteFailed = true;
private Boolean autoDeletePrevious = true;
private Boolean autoUpdate = false;
private String autoUpdateUrl = "";
private String updateUrl = "";
private Version currentVersionNative;
private Boolean resetWhenUpdate = true;

Expand Down Expand Up @@ -87,7 +87,7 @@ public void notifyDownload(final String id, final int percent) {

this.autoDeleteFailed = this.getConfig().getBoolean("autoDeleteFailed", true);
this.autoDeletePrevious = this.getConfig().getBoolean("autoDeletePrevious", true);
this.autoUpdateUrl = this.getConfig().getString("updateUrl", autoUpdateUrlDefault);
this.updateUrl = this.getConfig().getString("updateUrl", updateUrlDefault);
this.autoUpdate = this.getConfig().getBoolean("autoUpdate", false);
this.appReadyTimeout = this.getConfig().getInt("appReadyTimeout", 10000);
this.resetWhenUpdate = this.getConfig().getBoolean("resetWhenUpdate", true);
Expand Down Expand Up @@ -301,7 +301,7 @@ public void getLatest(final PluginCall call) {
new Thread(new Runnable(){
@Override
public void run() {
CapacitorUpdaterPlugin.this.implementation.getLatest(CapacitorUpdaterPlugin.this.autoUpdateUrl, (res) -> {
CapacitorUpdaterPlugin.this.implementation.getLatest(CapacitorUpdaterPlugin.this.updateUrl, (res) -> {
call.resolve(res);
});
}
Expand Down Expand Up @@ -395,7 +395,7 @@ public void cancelDelay(final PluginCall call) {
}

private Boolean _isAutoUpdateEnabled() {
return CapacitorUpdaterPlugin.this.autoUpdate && !"".equals(CapacitorUpdaterPlugin.this.autoUpdateUrl);
return CapacitorUpdaterPlugin.this.autoUpdate && !"".equals(CapacitorUpdaterPlugin.this.updateUrl);
}

@PluginMethod
Expand Down Expand Up @@ -429,8 +429,8 @@ public void onActivityStarted(@NonNull final Activity activity) {
@Override
public void run() {

Log.i(CapacitorUpdater.TAG, "Check for update via: " + CapacitorUpdaterPlugin.this.autoUpdateUrl);
CapacitorUpdaterPlugin.this.implementation.getLatest(CapacitorUpdaterPlugin.this.autoUpdateUrl, (res) -> {
Log.i(CapacitorUpdater.TAG, "Check for update via: " + CapacitorUpdaterPlugin.this.updateUrl);
CapacitorUpdaterPlugin.this.implementation.getLatest(CapacitorUpdaterPlugin.this.updateUrl, (res) -> {
try {
if (res.has("message")) {
Log.i(CapacitorUpdater.TAG, "message: " + res.get("message"));
Expand Down
14 changes: 7 additions & 7 deletions ios/Plugin/CapacitorUpdaterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import Version
@objc(CapacitorUpdaterPlugin)
public class CapacitorUpdaterPlugin: CAPPlugin {
private var implementation = CapacitorUpdater()
static let autoUpdateUrlDefault = "https://xvwzpoazmxkqosrdewyv.functions.supabase.co/updates"
static let updateUrlDefault = "https://xvwzpoazmxkqosrdewyv.functions.supabase.co/updates"
static let statsUrlDefault = "https://xvwzpoazmxkqosrdewyv.functions.supabase.co/stats"
static let DELAY_UPDATE = "delayUpdate"
private var autoUpdateUrl = ""
private var updateUrl = ""
private var statsUrl = ""
private var currentVersionNative: Version = "0.0.0"
private var autoUpdate = false
Expand All @@ -30,7 +30,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
}
autoDeleteFailed = getConfigValue("autoDeleteFailed") as? Bool ?? false
autoDeletePrevious = getConfigValue("autoDeletePrevious") as? Bool ?? false
autoUpdateUrl = getConfigValue("updateUrl") as? String ?? CapacitorUpdaterPlugin.autoUpdateUrlDefault
updateUrl = getConfigValue("updateUrl") as? String ?? CapacitorUpdaterPlugin.updateUrlDefault
autoUpdate = getConfigValue("autoUpdate") as? Bool ?? false
appReadyTimeout = getConfigValue("appReadyTimeout") as? Int ?? 10000
resetWhenUpdate = getConfigValue("resetWhenUpdate") as? Bool ?? true
Expand Down Expand Up @@ -250,7 +250,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
}

private func _isAutoUpdateEnabled() -> Bool {
return self.autoUpdate && self.autoUpdateUrl != ""
return self.autoUpdate && self.updateUrl != ""
}

@objc func isAutoUpdateEnabled(_ call: CAPPluginCall) {
Expand Down Expand Up @@ -292,11 +292,11 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
@objc func appMovedToForeground() {
if (self._isAutoUpdateEnabled()) {
DispatchQueue.global(qos: .background).async {
print("\(self.implementation.TAG) Check for update via \(self.autoUpdateUrl)")
let url = URL(string: self.autoUpdateUrl)!
print("\(self.implementation.TAG) Check for update via \(self.updateUrl)")
let url = URL(string: self.updateUrl)!
let res = self.implementation.getLatest(url: url)
if (res == nil) {
print("\(self.implementation.TAG) No result found in \(self.autoUpdateUrl)")
print("\(self.implementation.TAG) No result found in \(self.updateUrl)")
return
}
if (res?.message) {
Expand Down
2 changes: 1 addition & 1 deletion src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ declare module '@capacitor/cli' {
* @default https://capgo.app/api/auto_update
* @example https://example.com/api/auto_update
*/
autoUpdateUrl?: string;
updateUrl?: string;

/**
* Automatically delete previous downloaded bundles when a newer native app version is installed to the device.
Expand Down

0 comments on commit 169676c

Please sign in to comment.