Snippets

Dmitry Rusak BranchIO crew sharing

Created by Dmitry R.
fun createCrewShareLink(crew: Crew, listener: Branch.BranchLinkCreateListener) {
        createShareLink("open/crew/${crew.uid}",
                if (TextUtils.equals(CrewUtil.crewUid, crew.uid)) "Android_crew_own" else "Android_crew_others",
                "Crew ${crew.name} [RapFame on BattleMe]",
                crew.description,
                crew.icon,
                crew.uid,
                listener)
    }


    private fun createShareLink(deepLinkPath: String,
                        feature: String,
                        title: String?,
                        description: String?,
                        imageUrl: String?,
                        itemUid: String? = null,
                        listener: Branch.BranchLinkCreateListener) {

        val branchUniversalObject = BranchUniversalObject()
                .setCanonicalIdentifier(deepLinkPath)
                .setTitle(title ?: "RapFame on BattleMe")
                .setContentImageUrl(imageUrl ?: "https://bttl.me/img/og_icon.png")
                .setContentDescription(if (description.isNullOrEmpty()) {
                    "Battle Me is #1 rap app for Hip Hop fans and rappers. Over 1,500,000 rappers already use it. Rap recording studio and hip hop community that fits into your pocket. Hot new raps daily!"
                } else {
                    description
                })
                .addKeyWords(arrayListOf("rap fame", "battleme", "battle", "me", "hip hop", "battle me", "beats", "rap maker", "community"))
                .setContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC)
        itemUid?.let { branchUniversalObject.setContentMetadata(ContentMetadata().addCustomMetadata("item_uid", it)) }


        val linkProperties = LinkProperties()
                .setChannel("Android_application")
                .setFeature(feature)
                .addControlParameter(Branch.DEEPLINK_PATH, deepLinkPath)
                .addControlParameter(Keys.REFERRAL_ID, UserUtil.getUserId().toString())
        itemUid?.let { linkProperties.addControlParameter("item_uid", it) }

        branchUniversalObject.generateShortUrl(BattleMeApplication.getInstance(), linkProperties, listener)
    }

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.