Add the Viafoura Android SDK to your app
Using Gradle
- Open your application level 'build.gradle'
- Add the 'Viafoura' gradle dependency
implementation 'com.viafoura:android:2.1.19'- Sync your project
Using Maven
<dependency>
<groupId>com.viafoura</groupId>
<artifactId>android</artifactId>
<version>2.1.19</version>
</dependency>Using Jetpack Compose (Optional)
If your screens are built with Jetpack Compose, also add the android-compose artifact. It provides VFPreviewComments, VFNewComment, VFProfile and the other SDK screens as Composables. It depends on the core SDK, so adding it alone pulls in com.viafoura:android.
implementation 'com.viafoura:android-compose:2.1.19'<dependency>
<groupId>com.viafoura</groupId>
<artifactId>android-compose</artifactId>
<version>2.1.19</version>
</dependency>
The Composables attach a Fragment to the nearestFragmentManager, so the hosting Activity must be aFragmentActivityorAppCompatActivity, or the content must be inside a Fragment.
See Add a conversation to your app for Compose usage.
Initialize the SDK
- Create an
Applicationclass for your app. - Initialize the SDK in the
onCreate(). Make sure to replace SITE_UUID and SITE_DOMAIN with the values corresponding to your domain.
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
ViafouraSDK.initialize(getApplicationContext(), "SITE_UUID", "SITE_DOMAIN");
}
}class MyApplication: Application() {
override fun onCreate() {
super.onCreate()
ViafouraSDK.initialize(getApplicationContext(), "SITE_UUID", "SITE_DOMAIN")
}
}(Optional) Provide advertising ID
You can provide the sdk with the user advertising ID, which uniquely identifies a particular user for advertising use cases, such as ad personalization. More information
ViafouraSDK.advertisingIdentifier = "38400000-8cf0-11bd-b23e-10b96e40000d";ViafouraSDK.advertisingIdentifier = "38400000-8cf0-11bd-b23e-10b96e40000d"Updated about 17 hours ago
What’s Next
Did this page help you?
