Skip to content

Commit

Permalink
refactor: use getMessage instead of getLocalizedMessage on Android (
Browse files Browse the repository at this point in the history
  • Loading branch information
robingenz authored Apr 8, 2023
1 parent a79df0b commit fe89573
Show file tree
Hide file tree
Showing 22 changed files with 158 additions and 98 deletions.
12 changes: 12 additions & 0 deletions .changeset/dull-keys-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@capacitor-firebase/analytics": major
"@capacitor-firebase/app": major
"@capacitor-firebase/app-check": major
"@capacitor-firebase/authentication": major
"@capacitor-firebase/crashlytics": major
"@capacitor-firebase/messaging": major
"@capacitor-firebase/performance": major
"@capacitor-firebase/remote-config": major
---

refactor(android): use `getMessage` instead of `getLocalizedMessage`
6 changes: 6 additions & 0 deletions packages/analytics/BREAKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ If you want to use this plugin with Capacitor 4, please install version `1.4.0`:
npm i @capacitor-firebase/analytics@1.4.0
```

### Localized error messages

On Android, error messages were previously generated with `getLocalizedMessage`. They are no longer localized and are generated with `getMessage` instead.

You should therefore check your error handling.

## Version 1.x.x

### Capacitor 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void getAppInstanceId(@NonNull final GetAppInstanceIdCallback resultCallb
if (!task.isSuccessful()) {
Exception exception = task.getException();
Log.w(FirebaseAnalyticsPlugin.TAG, "Get AppInstanceId failed.", exception);
resultCallback.error(exception.getLocalizedMessage());
resultCallback.error(exception.getMessage());
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void error(String message) {
);
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
call.reject(exception.getMessage());
}
}

Expand All @@ -56,7 +56,7 @@ public void setUserId(PluginCall call) {
call.resolve();
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
call.reject(exception.getMessage());
}
}

Expand All @@ -73,7 +73,7 @@ public void setUserProperty(PluginCall call) {
call.resolve();
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
call.reject(exception.getMessage());
}
}

Expand All @@ -86,7 +86,7 @@ public void setCurrentScreen(PluginCall call) {
call.resolve();
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
call.reject(exception.getMessage());
}
}

Expand All @@ -103,7 +103,7 @@ public void logEvent(PluginCall call) {
call.resolve();
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
call.reject(exception.getMessage());
}
}

Expand All @@ -115,7 +115,7 @@ public void setSessionTimeoutDuration(PluginCall call) {
call.resolve();
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
call.reject(exception.getMessage());
}
}

Expand All @@ -131,7 +131,7 @@ public void setEnabled(PluginCall call) {
call.resolve();
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
call.reject(exception.getMessage());
}
}

Expand All @@ -147,7 +147,7 @@ public void resetAnalyticsData(PluginCall call) {
call.resolve();
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
call.reject(exception.getMessage());
}
}
}
6 changes: 6 additions & 0 deletions packages/app-check/BREAKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ If you want to use this plugin with Capacitor 4, please install version `1.4.0`:
```
npm i @capacitor-firebase/app-check@1.4.0
```

### Localized error messages

On Android, error messages were previously generated with `getLocalizedMessage`. They are no longer localized and are generated with `getMessage` instead.

You should therefore check your error handling.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void getToken(boolean forceRefresh, final GetTokenResultCallback resultCa
.addOnFailureListener(
exception -> {
Log.w(FirebaseAppCheckPlugin.TAG, "Get App Check token failed.", exception);
resultCallback.error(exception.getLocalizedMessage());
resultCallback.error(exception.getMessage());
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void error(String message) {
);
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
call.reject(exception.getMessage());
}
}

Expand All @@ -51,7 +51,7 @@ public void initialize(PluginCall call) {
call.resolve();
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
call.reject(exception.getMessage());
}
}

Expand All @@ -67,7 +67,7 @@ public void setTokenAutoRefreshEnabled(PluginCall call) {
call.resolve();
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
call.reject(exception.getMessage());
}
}
}
6 changes: 6 additions & 0 deletions packages/app/BREAKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ If you want to use this plugin with Capacitor 4, please install version `1.4.0`:
npm i @capacitor-firebase/app@1.4.0
```

### Localized error messages

On Android, error messages were previously generated with `getLocalizedMessage`. They are no longer localized and are generated with `getMessage` instead.

You should therefore check your error handling.

## Version 1.x.x

### Capacitor 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void getName(PluginCall call) {
call.resolve(ret);
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
call.reject(exception.getMessage());
}
}

Expand All @@ -45,7 +45,7 @@ public void getOptions(PluginCall call) {
call.resolve(ret);
} catch (Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
call.reject(exception.getLocalizedMessage());
call.reject(exception.getMessage());
}
}
}
6 changes: 6 additions & 0 deletions packages/authentication/BREAKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ If you want to use this plugin with Capacitor 4, please install version `1.4.0`:
npm i @capacitor-firebase/authentication@1.4.0
```

### Localized error messages

On Android, error messages were previously generated with `getLocalizedMessage`. They are no longer localized and are generated with `getMessage` instead.

You should therefore check your error handling.

## Version 1.x.x

### Capacitor 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void getIdToken(Boolean forceRefresh, final GetIdTokenResultCallback resu
String token = task.getResult().getToken();
resultCallback.success(token);
} else {
String message = task.getException().getLocalizedMessage();
String message = task.getException().getMessage();
resultCallback.error(message);
}
}
Expand Down Expand Up @@ -351,7 +351,7 @@ public void signInAnonymously(final PluginCall call) {
call.resolve(signInResult);
} else {
Logger.error(TAG, "signInAnonymously failed.", task.getException());
call.reject(task.getException().getLocalizedMessage());
call.reject(task.getException().getMessage());
}
}
);
Expand Down Expand Up @@ -649,7 +649,7 @@ public void handleSuccessfulSignIn(
public void handleFailedSignIn(final PluginCall call, String message, Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
if (message == null && exception != null) {
message = exception.getLocalizedMessage();
message = exception.getMessage();
}
call.reject(message, exception);
}
Expand Down Expand Up @@ -704,7 +704,7 @@ public void handleSuccessfulLink(
public void handleFailedLink(final PluginCall call, String message, Exception exception) {
Logger.error(TAG, exception.getMessage(), exception);
if (message == null && exception != null) {
message = exception.getLocalizedMessage();
message = exception.getMessage();
}
call.reject(message, exception);
}
Expand Down
Loading

0 comments on commit fe89573

Please sign in to comment.