Summary: There is no support of navigation plugin outside of Meta and it is not planned, so it's better to state directly in open-source docs instead of saying "Coming soon". Reviewed By: lblasa Differential Revision: D42370752 fbshipit-source-id: 23d6400ab7374877a0b13ae3b9c79fcb584763db
77 lines
2.9 KiB
Plaintext
77 lines
2.9 KiB
Plaintext
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
import Link from '@docusaurus/Link';
|
|
|
|
## Android
|
|
|
|
First, add the <Link to={useBaseUrl("/docs/features/plugins/navigation")}>Navigation plugin</Link> to your Flipper client instance:
|
|
|
|
```java
|
|
import com.facebook.flipper.android.AndroidFlipperClient;
|
|
import com.facebook.flipper.plugins.navigation.NavigationFlipperPlugin;
|
|
|
|
final FlipperClient client = AndroidFlipperClient.getInstance(this);
|
|
client.addPlugin(NavigationFlipperPlugin.getInstance());
|
|
```
|
|
|
|
Navigation events in the app can then be recorded by calling `sendNavigationEvent` method of the `NavigationFlipperPlugin` instance from anywhere in the app.
|
|
This enables the Navigation Plugin to be integrated into existing navigation frameworks.
|
|
|
|
### Using Android deep links
|
|
|
|
The Navigation Plugin can be used with built-in [Deep Links for Android](https://developer.android.com/training/app-links/deep-linking).
|
|
|
|
To deep link to an activity, edit the AndroidManifest.xml and add the intent filter for the given activity, as follows:
|
|
|
|
```xml
|
|
<intent-filter>
|
|
<action android:name="android.intent.action.VIEW" />
|
|
<category android:name="android.intent.category.DEFAULT" />
|
|
<category android:name="android.intent.category.BROWSABLE" />
|
|
<data android:scheme="flipper" android:host="deep_link_activity" />
|
|
</intent-filter>
|
|
```
|
|
|
|
This enables the user to jump to `flipper://deep_link_activity` within Flipper.
|
|
|
|
To log that navigation event in flipper, you can send the navigation event in the Activity's `onCreate` method, as follows:
|
|
|
|
```java
|
|
public class DeepLinkActivity extends AppCompatActivity {
|
|
@Override
|
|
protected void onCreate(final Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
NavigationFlipperPlugin.getInstance().sendNavigationEvent("flipper://deep_link_activity/");
|
|
...
|
|
```
|
|
|
|
### Third party solutions
|
|
|
|
The Navigation Plugin can easily be integrated into a third-party navigation framework.
|
|
|
|
#### AirBnB deep link dispatch
|
|
|
|
[DeepLinkDispatch](https://github.com/airbnb/DeepLinkDispatch) will work out of the box with Flipper for navigating to links, including support for url parameters.
|
|
|
|
To add logging, simply add a BroadcastReceiver to your app that is called on any incoming deep links:
|
|
|
|
```java
|
|
public class DeepLinkReceiver extends BroadcastReceiver {
|
|
private static final String TAG = "DeepLinkReceiver";
|
|
|
|
@Override public void onReceive(Context context, Intent intent) {
|
|
String deepLinkUri = intent.getStringExtra(DeepLinkHandler.EXTRA_URI);
|
|
if (intent.getBooleanExtra(DeepLinkHandler.EXTRA_SUCCESSFUL, false)) {
|
|
NavigationFlipperPlugin.getInstance().sendNavigationEvent(deepLinkUri);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class DeepLinkApplication extends Application {
|
|
@Override public void onCreate() {
|
|
super.onCreate();
|
|
IntentFilter intentFilter = new IntentFilter(DeepLinkHandler.ACTION);
|
|
LocalBroadcastManager.getInstance(this).registerReceiver(new DeepLinkReceiver(), intentFilter);
|
|
}
|
|
}
|
|
```
|