setup.mdx (setup - Network)
Summary: Restyle of page, including changes to spelling, grammar, links, and structure (where relevant). Reviewed By: lblasa Differential Revision: D36348417 fbshipit-source-id: 4e32ff6c2ce25ebcb403f203809dccb5d10ea01d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
280f5fda15
commit
1d552972db
@@ -1,13 +1,12 @@
|
|||||||
### Gradle Dependencies
|
### Gradle Dependencies
|
||||||
|
|
||||||
Ensure that you already have an explicit dependency in your application's
|
Ensure that you already have an explicit dependency in your application's `build.gradle` including the plugin dependency, as shown in the following example:
|
||||||
`build.gradle` including the plugin dependency, e.g.
|
|
||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "com.squareup.retrofit2:retrofit:2.9.0"
|
implementation "com.squareup.retrofit2:retrofit:2.9.0"
|
||||||
implementation "com.squareup.retrofit2:converter-protobuf:2.9.0"
|
implementation "com.squareup.retrofit2:converter-protobuf:2.9.0"
|
||||||
|
|
||||||
// update version below to match latest Flipper client app
|
// update version below to match latest Flipper client app
|
||||||
debugImplementation "com.facebook.flipper:flipper-retrofit2-protobuf-plugin:0.84.0"
|
debugImplementation "com.facebook.flipper:flipper-retrofit2-protobuf-plugin:0.84.0"
|
||||||
}
|
}
|
||||||
@@ -15,7 +14,7 @@ dependencies {
|
|||||||
|
|
||||||
### Sending Retrofit Service
|
### Sending Retrofit Service
|
||||||
|
|
||||||
Suppose you have a Retrofit service interface `PersonService` which has Protobuf body or return types. At the time you create your implementation, call the plugin with your `baseUrl` and service class:
|
If you have a Retrofit service interface `PersonService` which has Protobuf body or return types then at the time you create your implementation, call the plugin with your `baseURL` and service class, as follows:
|
||||||
|
|
||||||
```
|
```
|
||||||
import com.facebook.flipper.plugins.retrofit2protobuf.SendProtobufToFlipperFromRetrofit
|
import com.facebook.flipper.plugins.retrofit2protobuf.SendProtobufToFlipperFromRetrofit
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||||
|
import Link from '@docusaurus/Link';
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
import ProtobufRetrofitSetup from './_protobuf-retrofit.mdx';
|
import ProtobufRetrofitSetup from './_protobuf-retrofit.mdx';
|
||||||
|
|
||||||
To use the network plugin, you need to add the plugin to your Flipper client instance.
|
To use the <Link to={useBaseUrl("/docs/features/plugins/network")}>Network plugin</Link>, you need to add the plugin to your Flipper client instance.
|
||||||
|
|
||||||
## Android
|
## Android
|
||||||
|
|
||||||
The network plugin is shipped as a separate Maven artifact:
|
The network plugin is shipped as a separate Maven artifact, as follows:
|
||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -14,8 +16,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Once added to your dependencies, you can instantiate the plugin and add it to
|
Once added to your dependencies, you can instantiate the plugin and add it to the client:
|
||||||
the client:
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
|
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
|
||||||
@@ -32,7 +33,7 @@ client.addPlugin(networkFlipperPlugin);
|
|||||||
|
|
||||||
### OkHttp Integration
|
### OkHttp Integration
|
||||||
|
|
||||||
If you are using the popular OkHttp library, you can use the Interceptors system to automatically hook into your existing stack.
|
If you are using the popular OkHttp library, you can use the Interceptors system to automatically hook into your existing stack, as shown in the following snippet:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
|
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
|
||||||
@@ -54,7 +55,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Then call `SendProtobufToFlipperFromRetrofit` for each service class.
|
Then call `SendProtobufToFlipperFromRetrofit` for each service class:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
import com.facebook.flipper.plugins.retrofit2protobuf.SendProtobufToFlipperFromRetrofit
|
import com.facebook.flipper.plugins.retrofit2protobuf.SendProtobufToFlipperFromRetrofit
|
||||||
@@ -62,7 +63,6 @@ import com.facebook.flipper.plugins.retrofit2protobuf.SendProtobufToFlipperFromR
|
|||||||
SendProtobufToFlipperFromRetrofit("https://baseurl.com/", MyApiService::class.java)
|
SendProtobufToFlipperFromRetrofit("https://baseurl.com/", MyApiService::class.java)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## iOS
|
## iOS
|
||||||
|
|
||||||
To enable network inspection, add the following pod to your Podfile:
|
To enable network inspection, add the following pod to your Podfile:
|
||||||
@@ -71,7 +71,7 @@ To enable network inspection, add the following pod to your Podfile:
|
|||||||
pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version
|
pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version
|
||||||
```
|
```
|
||||||
|
|
||||||
Initialise the plugin in the following way by updating AppDelegate.m:
|
Initialize the plugin in the following way by updating AppDelegate.m:
|
||||||
|
|
||||||
<Tabs defaultValue="objc" values={[{ label: 'ObjC', value: 'objc'}, { label: 'Swift', value: 'swift'}]}>
|
<Tabs defaultValue="objc" values={[{ label: 'ObjC', value: 'objc'}, { label: 'Swift', value: 'swift'}]}>
|
||||||
<TabItem value="objc">
|
<TabItem value="objc">
|
||||||
@@ -80,7 +80,6 @@ Initialise the plugin in the following way by updating AppDelegate.m:
|
|||||||
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
|
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
|
||||||
|
|
||||||
[[FlipperClient sharedClient] addPlugin: [[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
|
[[FlipperClient sharedClient] addPlugin: [[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
@@ -90,7 +89,6 @@ Initialise the plugin in the following way by updating AppDelegate.m:
|
|||||||
import FlipperKit
|
import FlipperKit
|
||||||
|
|
||||||
client?.add(FlipperKitNetworkPlugin(networkAdapter: SKIOSNetworkAdapter()))
|
client?.add(FlipperKitNetworkPlugin(networkAdapter: SKIOSNetworkAdapter()))
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|||||||
Reference in New Issue
Block a user