Posts

Showing posts from November, 2017

Retrofit Integration in Android - Kotlin

Image
Retrofit is a Networking library, which is faster to use and easier to develop. Let’s see how to integrate Retrofit in Android with Kotlin. If you'd like to integrate RxJava as well, you can check here . 1. Configure: Include the following in app-level build.gradle. build.gradle compile "com.squareup.retrofit2:retrofit:2.3.0" compile "com.squareup.retrofit2:converter-gson:2.3.0" Include internet permission in Manifest file. AndroidManifest.xml <uses-permission android:name="android.permission.INTERNET" /> 2. Preparing Helper classes: ApiInterface.kt interface ApiInterface {    @POST("get_users_detail") // Your url    fun getUser(@Body requestBody: RequestBody): Call<UserResponse> } Model classes:                      Response from Retrofit will be stored in POJO classes directly. UserResponse.kt data class UserResponse(var httpCode: String, var user: Array

FCM Integration in Android - Kotlin

Image
                                               Firebase Cloud Messaging inherits GCM’s core infrastructure but simplifies the client development. It works for all platforms (Android, IOS and Web). Let's see how to integrate FCM in Android with Kotlin. FCM Messages:         Two types of FCM messages are there.      Notification messages,  which are handled by the FCM SDK automatically.      Data messages, which are handled by the client app. It can have custom fields, which have to be sent by our server. 1. Configure FCM in Firebase Console (a) Go to https://console.firebase.google.com/ (b) Then click Add Project , a dialog will be prompted. Enter project name and choose country in it and click on Create Project . (c) Click on Add Firebase to your Android App, another dialog will be prompted. In that, enter package name (SHA-1 and App Nickname are optional for FCM) and click Register App . (d) Then download g