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.
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"
Note: Carousel Container height must be fixed or match_parent. It can not be wrap_content else carousel embed will not appear.
Copy
//This is Optionalval params = HashMap<String, Any>()params["name"] = "John Doe"params["email"] = "john.doe@begenuin.com"params["nickname"] = "john"params["mobile"] = "1XXXXXXXXXX"//This is Optionalval contextualParams = HashMap<String, Any>()contextualParams["page_context"] = pageContextval geoJson = JSONObject()geoJson.put("lat", XXXX.XXX)geoJson.put("long", XXXX.XXX)contextualParams["geo"] = geoJson.toString()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) // User specific params setAspectRatio(CarouselTileAspectRatio.RATIO_4_5) setInterTileSpacing(24) // values should be in pixels setInsets( left = 24, // values should be in pixels top = 24, // values should be in pixels right = 24, // values should be in pixels bottom = 24, // values should be in pixels ) setTileCornerRadius(24) // values should be in pixels setContextualParams(contextualParams) // Contextual params load() }
Note: Carousel Container height must be fixed or match_parent. It can not be wrap_content else carousel embed will not appear.
Copy
val carouselEmbedView = CarouselEmbedView(context)llCarouselContainer.addView(carouselEmbedView)//This is Optionalval params = HashMap<String, Any>()params["name"] = "John Doe"params["email"] = "john.doe@begenuin.com"params["nickname"] = "john"params["mobile"] = "1XXXXXXXXXX"//This is Optionalval contextualParams = HashMap<String, Any>()contextualParams["page_context"] = pageContextval geoJson = JSONObject()geoJson.put("lat", XXXX.XXX)geoJson.put("long", XXXX.XXX)contextualParams["geo"] = geoJson.toString()carouselEmbedView.apply { setEmbedParams( embedId = "YOUR_EMBED_ID", uniqueId="UNIQUE_ID", interactionDeepLink = "YOUR_DEEPLINK", isDirectDeepLinkEnabled = false, isShowProfileEnabled = false ) setActivity(activityContext) setAspectRatio(CarouselTileAspectRatio.RATIO_4_5) setInterTileSpacing(24) // values should be in pixels setInsets( left = 24, // values should be in pixels top = 24, // values should be in pixels right = 24, // values should be in pixels bottom = 24, // values should be in pixels ) setTileCornerRadius(24) // values should be in pixels setSSOToken("YOUR_SSO_TOKEN") setParams(params) // User specific params setContextualParams(contextualParams) // Contextual 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.
embedId = The Embed Id that you want to load.
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.
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.
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.
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 parameters (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.
Add contextual parameters (Optional)
a. page_context - This is an optional string parameter. Pass this parameter for ‘context’, so that feed could load based on that context.
b. lat - This is an optional float parameter. Pass this parameter in geo so that the feed could load based on the latitude and context.
c. long - This is an optional float parameter. Pass this parameter in geo so that the feed could load based on the longitude and context.
Add design configurations (Optional)
a. interTileSpacing - spacing between the carousel’s view items. It’s default value is 8dp
b. carouselInset - edge insets for carousel’s view. It’s default value is top: 8dp, left: 16dp, bottom: 0dp, right: 16dp
c. scrollDirection - direction of carousel scroll. It’s default value is CarouselScrollDirection.HORIZONTAL
d. aspectRatio - define aspect ratio of carousel’s view items. It’s default value is CarouselTileAspectRatio.RATIO_9_16
e. tileCornerRadius - cornerRadius for the carousel’s view items. It’s default value is 8dp
3. Manage carousel videos auto-play
Copy
override fun onResume() { super.onResume() carouselEmbedView.resumeVideoAutoPlay()}override fun onPause() { carouselEmbedView.pauseVideoAutoPlay() super.onPause()}
We need to pass below arguments in order to cofigure FullScreenEmbed.
embedId = The Embed Id that you want to load.
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.
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.
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.
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.
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.
Add user specific parameters (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.
Add contextual parameters (Optional)
a. page_context - This is an optional string parameter. Pass this parameter for ‘context’, so that feed could load based on that context.
b. lat - This is an optional float parameter. Pass this parameter in geo so that the feed could load based on the latitude and context.
c. long - This is an optional float parameter. Pass this parameter in geo so that the feed could load based on the longitude and context.
We need to pass below arguments in order to cofigure StandardWallEmbed.
embedId = The Embed Id that you want to load.
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.
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.
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.
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.
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.
Add user specific parameters (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.
Add contextual parameters (Optional)
a. page_context - This is an optional string parameter. Pass this parameter for ‘context’, so that feed could load based on that context.
b. lat - This is an optional float parameter. Pass this parameter in geo so that the feed could load based on the latitude and context.
c. long - This is an optional float parameter. Pass this parameter in geo so that the feed could load based on the longitude and context.
If you want to handle login process as per your requirement then follow the below steps:
Copy
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. */ }})
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.
Download the google-services.json file and add it into your app.
Integrate firebase into your app by following these steps
Get firebase token and register it with Genuin SDK
Copy
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)
Copy
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.
Copy
YourLauncherActivity.kt
Copy
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.