SDK Integration
Follow the below steps to integrate the Real-time CDP SDK in the Android app:
-
Add the following codes in your application’s build.gradle.
-
Append the following dependencies:
Copydependencies {
implementation 'com.android.support:cardviewv7:27.1.1alpha1'
implementation 'com.github.bumptech.glide:glide:3.6.1'
implementation 'com.google.code.gson:gson:2.4'
implementation 'com.android.support:recyclerviewv7:27.1.1'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.android.support:supportv4:27.1.1'
} -
Append the following code.
Copyandroid {
defaultConfig {
multiDexEnabled true
}
} -
Append the following code.
Copyapply plugin: 'com.google.gms.googleservices'
-
-
Add the FCM generated googleservices.json file to your project.
Note: This is required to enable Push Notifications in the app.
-
Append the following classpath in build.gradle.
Copybuildscript {
dependencies {
classpath ‘com.google.gms:googleservices:4.3.3’
}
} -
Append the following code in the manifest.xml file under <application> tag.
Copy<service android:name=“com.manthan.targetone.service.MyFirebaseMessagingService">
<intentfilter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intentfilter>
</service> -
Add the following permissions in the .manifest file.
Copy<usespermission android:name="android.permission.INTERNET" />
<usespermission android:name="android.permission.ACCESS_FINE_LOCATION" />
<usespermission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<usespermission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<usespermission android:name="android.permission.CHANGE_WIFI_STATE"/> -
To enable the In-App Banner Notification feature in your mobile application, add the following code in your manifest file under <application> tag.
Note: Do not add this code if your app does not use this feature.
notification_icon – It should be a transparent icon and available in all the Drawables.
Copy<application>
<metadata android:name="IN_APP_NOTIFICATION" android:value=“enable"/>
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
</application>