Requirements

PlatformMinimum SDK VersionLanguageSupported OrientationsSupported Destinations
Android24Java/KotlinPortraitMobile

Installation

Note: Currently minimum SDK version is 24 but if you want to use our SDK in version below 24, use the below code snippet in the App level manifest file.

<uses-sdk
    tools:overrideLibrary="com.begenuin.sdk, com.google.mediapipe.tasks.vision, com.google.mediapipe.tasks.core, com.arthenica.ffmpegkit"/>

Warning: If you use the above code then possible it may lead to the functionality failure in some cases.

1. Add repo details in project level gradle

dependencyResolutionManagement {
  repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  repositories {
    google()
    mavenCentral()
    jcenter()
    maven {
      setUrl("https://jitpack.io")
    } 
  }
}

2. Add dependency in app level gradle

implementation("org.bitbucket.genuindev:genuin_android_sdk:1.1.12@aar"){
        isTransitive=true
    }

3. Add permissions to AndroidManifest.xml

Mandatory Permissions


<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Following permissions are optional and can be added in AndroidManifest.xml file as per feature requirements:

  • To allow user to Create Video Content, Camera and Mic permissions are needed:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-feature
    android:name="android.hardware.camera"
    android:required="false" />

  • To allow user to Upload Content from their gallery

//API level > 32
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />

//API level <= 32
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" 
        android:maxSdkVersion="32"/>

  • To allow user to add their Contacts as Members in Communities and Groups:

<uses-permission android:name="android.permission.READ_CONTACTS" />

  • To allow user to receive Push Notifications:

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

  • To allow creation of AI Powered Communities based on the User Location:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

  • To enhance the Ad experience of the user:

<uses-permission android:name="com.google.android.gms.permission.AD_ID" />

4. Initialize SDK


class YourApplication : Application() {
  override fun onCreate() {
    GenuinSDK.initSDK(this, "YOUR_API_KEY")
  }
}

5. Load SDK in seperate activity


GenuinSDK.loadSDK(context)

6. Load SDK in your custom activity

Put below code in activity_custom.xml file


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>

Put below code in CustomActivity.kt file


import com.begenuin.begenuin.FeedFragment

class CustomActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_custom)

        val genuinFeedFragment = FeedFragment()
        supportFragmentManager.beginTransaction()
            .add(R.id.frameLayout, genuinFeedFragment)
            .addToBackStack("feedFragment").commit()
    }
}


Note: In your custom activity, set soft input mode to adjustPan for better performance
android:windowSoftInputMode="adjustPan"

7. Load SDK with bottom navigation and fragment

Add below code in res/navigation/mobile_navigation.xml


<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/mobile_navigation"

    <fragment
        android:id="@+id/navigation_community"
        android:name="com.begenuin.begenuin.FeedFragment"
        android:label="@string/title_communities" />

</navigation>

Add below code in your activity

override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)
  setSupportActionBar(Toolbar(this))
  initViewPager()
  val navView: BottomNavigationView = binding.navView
  navView.setOnItemSelectedListener { item ->
    when (item.itemId) {
      R.id.navigation_community -> {
        binding.viewPager.setCurrentItem(1, false)
        true
      }

      else -> false
    }
  }
}
private fun initViewPager() {
  val myPagerAdapter = MyPagerAdapter(this)
  binding.viewPager.adapter = myPagerAdapter
}

class MyPagerAdapter(fragmentActivity: FragmentActivity) :
  FragmentStateAdapter(fragmentActivity) {
  override fun createFragment(position: Int): Fragment {
    return when (position) {
      0 -> FeedFragment()
      else -> FeedFragment()
    }
  }
  override fun getItemCount(): Int {
    return NUM_PAGES
  }
  companion object {
    private const val NUM_PAGES = 1
  }
}

8. Want to override our default loader.

We are using lottie animation for our loader. You can put your custom lottie animation loader with the name loader_mix.json in the res/raw folder. Make sure you use the same name as provided.

Note: In AndroidManifest.xml, in the <application> tag, set android:allowBackup="false"

Embed

Note: Make sure you have followed the First 3 installation steps in order to implement the Carousel Embed
Refer to Carousel View in mobile.

1. Load Carousel Embed with XML


<LinearLayout
      android:id="@+id/llCarouselContainer"
      android:layout_width="match_parent"
      android:layout_height="300dp">

      <com.begenuin.sdk.ui.customview.embed.CarouselEmbedView
      android:id="@+id/carouselEmbedView"
      android:layout_width="match_parent"
      android:layout_height="match_parent"/>
</LinearLayout>

Note: Carousel Container height must be fixed or match_parent. It can not be wrap_content else carousel embed will not appear.

//This is Optional
val params = HashMap<String, Any>()
params["name"] = "John Doe"
params["email"] = "john.doe@begenuin.com"
params["nickname"] = "john"
params["mobile"] = "1XXXXXXXXXX"

carouselEmbedView.apply {
            setEmbedParams(
               embedId = "YOUR_EMBED_ID", 
               uniqueId="UNIQUE_ID",
               interactionDeepLink = "YOUR_DEEPLINK",
               isDirectDeepLinkEnabled = false,
               isShowProfileEnabled = false
            )
            setActivity(activityContext)
            setSSOToken("YOUR_SSO_TOKEN")
            setParams(params)
            load()
        }

2. Load Carousel Embed Programmatically


<LinearLayout
     android:id="@+id/llCarouselContainer"
     android:layout_width="match_parent"
     android:layout_height="300dp">           
</LinearLayout>
Note: Carousel Container height must be fixed or match_parent. It can not be wrap_content else carousel embed will not appear.
val carouselEmbedView = CarouselEmbedView(context)
llCarouselContainer.addView(carouselEmbedView)

//This is Optional
val params = HashMap<String, Any>()
params["name"] = "John Doe"
params["email"] = "john.doe@begenuin.com"
params["nickname"] = "john"
params["mobile"] = "1XXXXXXXXXX"

carouselEmbedView.apply {
            setEmbedParams(
               embedId = "YOUR_EMBED_ID", 
               uniqueId="UNIQUE_ID",
               interactionDeepLink = "YOUR_DEEPLINK",
               isDirectDeepLinkEnabled = false,
               isShowProfileEnabled = false
            )
            setActivity(activityContext)
            setSSOToken("YOUR_SSO_TOKEN")
            setParams(params)
            load()
        }
Note: To initialise the Embed you need to add your activity context (setActivity(activityContext)) in which you want the embed. To auto login in the SDK, you shall pass “YOUR_SSO_TOKEN”(setSSOToken("YOUR_SSO_TOKEN")) in order to implement Embed with SSO in your app.

To configure the EmbedParams based on your need you can pass the below values.

  1. embedId = The Embed Id that you want to load.

  2. uniqueId = This is an optional parameter. This uniqueId is used when we need to display same embed in multiple/same screen. We need to provide uniqueId for the same embedId in multiple/same screen.

  3. interactionDeepLink = This is an optional parameter. You can pass a deeplink URL in this parameter. If a deeplink URL is given then all the interaction/clicks in the full screen view will redirect to the deeplink URL given. If not passed then the regular flow will work. It should be a correct URL else user will not be redirected.

  4. isDirectDeepLinkEnabled = This is an optional boolean parameter. Default value is false. If this parameter is true then all the interaction/clicks in the full screen view will redirect to the specific video in white labelled app associated with video and also value of this parameter “interactionDeepLink” will be ignored. If not passed then the regular flow will work.

Note: For using isDirectDeepLinkEnabled parameter, you must have white labelled your domain first and also integrated the Handling deep link part in your main app in which you want to redirect this video to.
  1. isShowProfileEnabled = This is an optional boolean parameter. Default value is false. If this parameter is true and also if user is logged in than Profile picture will be visible in full screen view (right side top corner). On clicking the profile picture user will see the account settings and logout options.

Add user specific params while performing sso login (Optional)

a. name - This is an optional string parameter. Pass this parameter for signup/login.

b. mobile - This is an optional string parameter. Pass this parameter for signup/login.

c. email - This is an optional string parameter. Pass this parameter for signup/login.

d. nickname - This is an optional string parameter. If nickname is available in genuin ecosystem it will be used, else genuin will generate of its own.

e. profile_image: This is an optional string parameter. Pass the profile_image parameter if you want to show the profile image in the SDK.

3. Manage carousel videos auto-play


override fun onResume() {
    super.onResume()
    carouselEmbedView.resumeVideoAutoPlay()
}

override fun onPause() {
    carouselEmbedView.pauseVideoAutoPlay()
    super.onPause()
}

Full Screen Embed

Put below code in activity_full_embed.xml file


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>

Put below code in FullEmbedActivity.kt file


import com.begenuin.sdk.ui.fragment.FeedEmbedFragment

class FullEmbedActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_full_embed)

        //This is Optional
        val params = HashMap<String, Any>()
        params["name"] = "John Doe"
        params["email"] = "john.doe@begenuin.com"
        params["nickname"] = "john"
        params["mobile"] = "1XXXXXXXXXX"

        val feedEmbedFragment = FeedEmbedFragment.newInstance(
               embedId = "YOUR_EMBED_ID", 
               uniqueId="UNIQUE_ID",
               interactionDeepLink = "YOUR_DEEPLINK",
               isDirectDeepLinkEnabled = false,
               isShowProfileEnabled = false,
               ssoToken = "YOUR_SSO_TOKEN",
               params = params
            )
        feedEmbedFragment.let {
            supportFragmentManager.beginTransaction()
                .add(R.id.frameLayout, it)
                .addToBackStack("EmbedFullFeed").commit()
        }
    }
}


We need to pass below arguments in order to cofigure FullScreenEmbed.

  1. embedId = The Embed Id that you want to load.

  2. uniqueId = This is an optional parameter. This uniqueId is used when we need to display same embed in multiple/same screen. We need to provide uniqueId for the same embedId in multiple/same screen.

  3. interactionDeepLink = This is an optional parameter. You can pass a deeplink URL in this parameter. If a deeplink URL is given then all the interaction/clicks in the full screen view will redirect to the deeplink URL given. If not passed then the regular flow will work. It should be a correct URL else user will not be redirected.

  4. isDirectDeepLinkEnabled = This is an optional boolean parameter. Default value is false. If this parameter is true then all the interaction/clicks in the full screen view will redirect to the specific video in white labelled app associated with video and also value of this parameter “interactionDeepLink” will be ignored. If not passed then the regular flow will work.

Note: For using isDirectDeepLinkEnabled parameter, you must have white labelled your domain first and also integrated the Handling deep link part in your main app in which you want to redirect this video to.
  1. isShowProfileEnabled = This is an optional boolean parameter. Default value is false. If this parameter is true and also if user is logged in than Profile picture will be visible in full screen view (right side top corner). On clicking the profile picture user will see the account settings and logout options.

  2. ssoToken: This is an optional parameter. To auto login in the SDK, you shall pass “YOUR_SSO_TOKEN” in order to implement Embed with SSO in your app.

  3. Add user specific params while performing sso login (Optional)

a.name - This is an optional string parameter. Pass this parameter for signup/login.

b.mobile - This is an optional string parameter. Pass this parameter for signup/login.

c.email - This is an optional string parameter. Pass this parameter for signup/login.

d. nickname - This is an optional string parameter. If nickname is available in genuin ecosystem it will be used, else genuin will generate of its own.

e. profile_image: This is an optional string parameter. Pass the profile_image parameter if you want to show the profile image in the SDK.

Standard Wall Embed

Put below code in activity_standard_wall_embed.xml file


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>

Put below code in StandardWallEmbedActivity.kt file


import com.begenuin.sdk.ui.fragment.FeedEmbedFragment

class StandardWallEmbedActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_standard_wall_embed)

        //This is Optional
        val params = HashMap<String, Any>()
        params["name"] = "John Doe"
        params["email"] = "john.doe@begenuin.com"
        params["nickname"] = "john"
        params["mobile"] = "1XXXXXXXXXX"

        val feedEmbedFragment = FeedEmbedFragment.newInstance(
               embedId = "YOUR_EMBED_ID", 
               uniqueId="UNIQUE_ID",
               interactionDeepLink = "YOUR_DEEPLINK",
               isDirectDeepLinkEnabled = false,
               isShowProfileEnabled = false,
               ssoToken = "YOUR_SSO_TOKEN",
               params = params
            )

        feedEmbedFragment.let {
            supportFragmentManager.beginTransaction()
                .add(R.id.frameLayout, it)
                .addToBackStack("EmbedStandardWallFeed").commit()
        }
    }
}


We need to pass below arguments in order to cofigure StandardWallEmbed.

  1. embedId = The Embed Id that you want to load.

  2. uniqueId = This is an optional parameter. This uniqueId is used when we need to display same embed in multiple/same screen. We need to provide uniqueId for the same embedId in multiple/same screen.

  3. isShowProfileEnabled = This is an optional boolean parameter. Default value is false. If this parameter is true and also if user is logged in than Profile picture will be visible in full screen view (right side top corner). On clicking the profile picture user will see the account settings and logout options.

  4. isDirectDeepLinkEnabled = This is an optional boolean parameter. Default value is false. If this parameter is true then all the interaction/clicks in the full screen view will redirect to the specific video in white labelled app associated with video and also value of this parameter “interactionDeepLink” will be ignored. If not passed then the regular flow will work.

Note: For using isDirectDeepLinkEnabled parameter, you must have white labelled your domain first and also integrated the Handling deep link part in your main app in which you want to redirect this video to.
  1. isShowProfileEnabled = This is an optional boolean parameter. Default value is false. If this parameter is true and also if user is logged in than Profile picture will be visible in full screen view (right side top corner). On clicking the profile picture user will see the account settings and logout options.

  2. ssoToken: This is an optional parameter. To auto login in the SDK, you shall pass “YOUR_SSO_TOKEN” in order to implement Embed with SSO in your app.

  3. Add user specific params while performing sso login (Optional)

a.name - This is an optional string parameter. Pass this parameter for signup/login.

b.mobile - This is an optional string parameter. Pass this parameter for signup/login.

c.email - This is an optional string parameter. Pass this parameter for signup/login.

d. nickname - This is an optional string parameter. If nickname is available in genuin ecosystem it will be used, else genuin will generate of its own.

e. profile_image: This is an optional string parameter. Pass the profile_image parameter if you want to show the profile image in the SDK.

Handle SSO Login Explicitly in SDK

To Auto Login in the SDK, You need to call below method, whenever user is log in to your application.

Note: You don’t need to call the below method if you have implemented the Embed With SSO already.
GenuinSDK.ssoLogin(context = “YOUR_CONTEXT”, ssoToken = “YOUR_SSO_TOKEN”)

Optional Parameters

Below are the optional parameters you can add with the function:


val params = HashMap<String, Any>()

params["name"] = "John Doe"
params["email"] = "john.doe@begenuin.com"
params["nickname"] = "john"
params["mobile"] = "1XXXXXXXXXX"

GenuinSDK.ssoLogin(
    context = "YOUR_CONTEXT", 
    ssoToken = "YOUR_SSO_TOKEN",
    params = params //This is optional
)

Add user specific params while performing sso login (Optional)

  1. name - This is an optional string parameter. Pass this parameter for ‘signup/login’.
  2. mobile - This is an optional string parameter. Pass this parameter for signup/login.
  3. email - This is an optional string parameter. Pass this parameter for signup/login.
  4. nickname - This is an optional string parameter. If nickname is available in genuin ecosystem it will be used, else genuin will generate of its own.
  5. profile_image: This is an optional string parameter. Pass the profile_image parameter if you want to show the profile image in the SDK.

Custom Login

If you want to handle login process as per your requirement then follow the below steps:


GenuinSDK.registerInterface(object : GenuinInterface {
            override fun onLogin(context: Activity) {
                /*
                    This callback will be triggered when user attempts to login
                    within one of the Genuin embeds. Application login process
                    should be initiated here.

                    When your application's auth process is successfully completed,
                    call GenuinSDK.ssoLogin(context, "ssoToken") to automatically
                    manage SDK login.
                */
            }
})

Handle SSO Logout in SDK

Whenever user logs out from your application call the below method.

GenuinSDK.ssoLogout(context = “YOUR_CONTEXT”)
Note: Make sure you have followed the First 3 installation steps in order to handle the deep link.

Prerequisite:

  1. Make sure you have white labelled your community by following these steps.

  2. Follow the steps given in the below URL to integrate deeplink in your app https://developer.android.com/studio/write/app-link-indexing

Note : Here host will be your “YOUR_WHITE-LABELLED_DOMAIN”
  1. After completing deeplink setup, your assetlinks.json file should look like below

[{"target":{"package_name":"YOUR_PACKAGE_NAME","sha256_cert_fingerprints":["YOUR_KEYSTORE'S_SHA256_FINGERPRINTS"],"namespace":"android_app"},"relation":["delegate_permission/common.handle_all_urls"]}]

  1. Host assetlinks.json file on the white labeled domain at https://YOUR_WHITE-LABELLED_DOMAIN/.well-known/assetlinks.json

To Handle Our Deep Link In Your App

You can call the below method immediately after receiving deeplink or you can wait until your app’s home screen is loaded.


GenuinSDK.handleDeepLink(context = "YOUR_CONTEXT", intent = "YOUR_DEEPLINK_ACTIVITY_INTNET")

Note: Need to call this function everytime your app receives any deeplink. This method will handle deeplink if it is our’s otherwise it will ignore that.

Handling Push Notifications

Note: Make sure you have followed the First 3 installation steps in order to handle the push notifications.

Prerequisite:

  1. Create an app in your firebase using these steps

  2. Download the google-services.json file and add it into your app.

  3. Integrate firebase into your app by following these steps

Get firebase token and register it with Genuin SDK


private fun getFirebaseToken(){
        FirebaseMessaging.getInstance().token
            .addOnCompleteListener { task: Task<String> ->
                if (!task.isSuccessful) {
                    return@addOnCompleteListener
                }
                // Get new FCM registration token
                val token = task.result
                // Register token with Genuin SDK
                GenuinSDK.registerFCMToken("YOUR_CONTEXT", token)
            }
    }

Handle foreground notifications (When your app is in foreground)


class MyFirebaseMessagingService : FirebaseMessagingService() {
    override fun onMessageReceived(remoteMessage: RemoteMessage) {
        super.onMessageReceived(remoteMessage)
        val data: Map<String, String> = remoteMessage.getData()
        if (GenuinSDK.willHandleForegroundNotification(data)) {
            val message = remoteMessage.notification?.body ?: ""
            GenuinSDK.handleForegroundNotifications(
                context = this,
                data = data,
                message = message,
                smallNotificationIcon = R.drawable.ic_small_notifications // Your app's notification small icon
            )
        } else {
            // Handle other push notifications for your app
        }
    }

    /**
     * There are two scenarios when onNewToken is called:
     * 1) When a new token is generated on initial app startup
     * 2) Whenever an existing token is changed
     * Under #2, there are three scenarios when the existing token is changed:
     * A) App is restored to a new device
     * B) User uninstalls/reinstall the app
     * C) User clears app data
     */
    override fun onNewToken(s: String) {
        super.onNewToken(s)
        GenuinSDK.registerFCMToken(this, s)
    }

}

Note: GenuinSDK.willHandleForegroundNotification(data: Map<String, String>) function will check whether GenuinSDK will handle the given notification or not when app is in foreground.

Handle notifications while app is running in background or closed

  • Whenever user clicks on notifications, you will get the notification payload in your launcher activity.
YourLauncherActivity.kt

if (GenuinSDK.willHandleNotification(intent)) {
     GenuinSDK.handleBackgroundNotifications(context = "YOUR_CONTEXT", intent)
}

Note: GenuinSDK.willHandleNotification(intent: Intent) function will check whether GenuinSDK will handle the given notification or not.

What’s next?

Support

If you need any assistance or have any questions, feel free to email us at support@begenuin.com.