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

feat(android): activity result use new API and updated permission result callbacks to match #4127

Merged
merged 16 commits into from
Feb 8, 2021

Conversation

carlpoole
Copy link
Member

@carlpoole carlpoole commented Jan 28, 2021

  • Removes the need to define request codes on plugins. requestCodes element removed from @CapacitorPlugin annotation (breaking change for plugins with activity results on Capacitor 3 beta)
  • Activity result callbacks are registered by adding the @ActivityCallback annotation to a method with the parameters (PluginCall, ActivityResult).
  • Permission result callbacks are registered by adding the @PermissionCallback annotation to a method with the parameter (PluginCall)
  • The permissionCallback element is removed from the @PluginMethod annotation (breaking change for plugins with permission requests on Capacitor 3 beta)
  • Activities are launched using the new method startActivityForResult(PluginCal call, Intent intent, String callbackName); and link to the registered callback by providing the name of the callback method.
  • Existing permission request methods were modified to add the callback method name parameter, for example requestPermissionForAlias(String alias, PluginCall call, String callbackName);

Resolves #4050

Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been doing some testing on the sample app and on camera page the app crash on the second time I click the "Request all permissions" button (or with the photo permissions too) because of null savedCall on triggerPermissionCallback method.
I tried to put a null check and that only avoids the crash, then one of each call works and the following doesn't because it's null, then the following works again and so on, so loos like the bridge.getPermissionCall(handle.getId()); is not working properly or it's not getting stored properly

@carlpoole
Copy link
Member Author

I've been doing some testing on the sample app and on camera page the app crash on the second time I click the "Request all permissions" button (or with the photo permissions too) because of null savedCall on triggerPermissionCallback method.

Nice catch. Thanks for testing, the call was being saved twice so subsequent permissions checks on the same plugin were trying to find an old call and fetching null instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AndroidX Activity Result API Update
3 participants