Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: Return error data on appRestoredResult on Android #1801

Closed
WIStudent opened this issue Jul 24, 2019 · 1 comment · Fixed by #2497
Closed

Improvement: Return error data on appRestoredResult on Android #1801

WIStudent opened this issue Jul 24, 2019 · 1 comment · Fixed by #2497

Comments

@WIStudent
Copy link
Contributor

Issue

Using the

App.addListener('appRestoredResult', data => console.log(JSON.stringify(data));

callback I noticed that it doesnt return any helpful information if a plugin returns an error using:

// PluginCall call;
call.error("Some error message")

Using the camera plugin for example, I can see in logcat the message

Sending plugin error: {"save":false,"callbackId":"-1","pluginId":"Camera","methodName":"getPhoto","success":false,"error":{"message":"User cancelled photos app"}}

when canceling the camera app. But the appRestoredResult callback only gets

{"pluginId":"Camera","methodName":"getPhoto","data":{}}

Improvement

One possible improvement would be to include the error object and success flag seen in the logcat message in the data object that is passed to the callback function. E.g.

interface AppRestoredResult {
  pluginId: string;
  methodName: string;
  data: any;
  success: boolean;
  error?: {
    message: string;
  }
}
// The error field might look differently depending on what kind of data can be added to an error

const data: AppRestoredResult = {
  pluginId: "Camera",
  methodName: "getPhoto",
  data: {}
  success: false,
  error: {
    message: "User cancelled photos app"
  }
}

How to reproduce

  1. Write an app using the camera plugin and the appRestoredResult callback
  2. In the developer settings on your device, enable "Don't keep activities". This will make sure that the capacitor activity is killed as soon as the device switches to the camera activity.
  3. Open your app and trigger the camera app.
  4. Don't actually take a picture but cancel in the camera app.
  5. appRestoredResult will now return the data as described above.
@WIStudent WIStudent changed the title Improvement: Return also error data on appRestoredResult on Android Improvement: Return error data on appRestoredResult on Android Jul 24, 2019
@jcesarmobile jcesarmobile added this to the 2.0.0 milestone Jan 27, 2020
@ionitron-bot
Copy link

ionitron-bot bot commented Nov 12, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants