Retrofit IntegrationΒΆ

To use Retrofit with Neumob SDK, use Neumob.createRetrofit() method to create an instance of Retrofit.

  1. To create an instance with default settings and the service base URL, use
Retrofit retrofit = Neumob.createRetrofit("https://api.github.com/");

instead of calling Retrofit API as below:

Retrofit retrofit = new Retrofit.Builder()
    .baseUrl("https://api.github.com/")
    .build();
  1. If any cutom settings is required, a Builder object can be specified while creating the instance. To create the instance with Builder settings, use
Retrofit.Builder builder = new Retrofit.Builder()
    .baseUrl("https://api.github.com")
    .addConverterFactory(GsonConverterFactory.create());

Retrofit retrofit = Neumob.createRetrofit(builder);

instead of using Retrofit API as below:

Retrofit retrofit = new Retrofit.Builder()
    .baseUrl("https://api.github.com")
    .addConverterFactory(GsonConverterFactory.create())
    .build();

Note

For SDK 3.2.4 or lower: If you are using a custom OkHttpClient with the Retrofit, create an OkHttpClient using Neumob.createOkHttp3Client(builder) and set it as the client through the Retrofit.Builder API and call Retrofit.Builder.build() directly. See OkHttp 3 Integration for more details about creating OkHttpClient object.

For SDK 3.2.5 and above: The above step is not required and we recommend using Neumob.createRetrofit(builder) API in all situations.