-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Pass custom plugins to BridgeFragment #3280
Conversation
Thanks for contributing. You are right, we do need a way to pass plugins into Our current train of thought was letting people set the plugins from Example of use:
or
|
My usage pattern is slightly different to your snippets because I do not use <fragment android:id="@+id/my_fragment_id"
tools:layout="@layout/my_fragment"/> Therefore, the intended usage of this PR is to override the import android.os.Bundle
import com.getcapacitor.BridgeFragment
class MyFragment : BridgeFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
super.addPlugin(MyCapacitorPlugin::class.java)
}
}
This suggestions only supports the FragmentManager use case but not the XML use case.
I think that the |
@carlpoole I have now rewritten this PR to implement your second proposal instead of my initial proposal. |
This is great feedback, thank you!
This should be fine. I think the
I agree we should be careful around the potential for the re-creation of fragments in the system. Further changes are likely as 3.x matures and discovery of bugs around the embedded use case crop up. |
The purpose of
BridgeFragment
is to integrate Capacitor into existing Android apps in cases whereBridgeActivity
would not fit into the existing native UI.This is nice because it enables a gradual transition from a native codebase to Capacitor.
However, it is unclear how custom plugins should be passed to
BridgeFragment
.Therefore, this PR introduces a new method to mimic the usage pattern of
BridgeActivity
.