FastComments.com

अपने Android ऐप में टिप्पणियाँ जोड़ें

यह FastComments के लिए आधिकारिक Android लाइब्रेरी है।

अपने Android ऐप में लाइव कमेंटिंग, चैट और रिव्यू विजेट एम्बेड करें।

रिपॉज़िटरी

GitHub पर देखें

AI कोडिंग एजेंट Internal Link

skills.sh

अपने कोडिंग एजेंट को FastComments का वह संदर्भ दें जिसकी उसे आवश्यकता है - विजेट्स, कॉन्फ़िगरेशन, Secure SSO, REST API, और SDKs:

npx skills add fastcomments/skills

यह Claude Code, Codex, Cursor, Copilot, Gemini, और skills CLI द्वारा समर्थित हर अन्य एजेंट के साथ काम करता है।

विशेषताएँ Internal Link

  • 🔄 रियल-टाइम अपडेट के साथ लाइव कमेंटिंग
  • 📱 नेटिव Android UI कंपोनेंट्स
  • 🧵 उत्तरों के साथ थ्रेडेड चर्चाएँ
  • 👤 सुरक्षित SSO प्रमाणीकरण
  • 👍 अनुकूलन योग्य स्टाइल के साथ वोटिंग सिस्टम
  • 📊 लाइव परिणामों के साथ कमेंट्स में पोल
  • 🔔 यूज़र नोटिफिकेशन और प्रेज़ेंस
  • 🔍 कमेंट मॉडरेशन क्षमताएँ
  • 📱 सोशल फ़ीड इंटीग्रेशन
  • ♾️ इनफिनिट स्क्रॉल पेजिनेशन
  • 🎨 व्यापक थीमिंग

आवश्यकताएँ Internal Link

  • Android SDK 26+ (Android 8.0 Oreo या बाद का)
  • Java 8+

इंस्टॉलेशन Internal Link

अपने ऐप की build.gradle.kts फ़ाइल में FastComments SDK जोड़ें:

dependencies {
    implementation("com.fastcomments:android-sdk:2.1.0")
}

सुनिश्चित करें कि आपके प्रोजेक्ट की settings.gradle.kts में Repsy रिपॉज़िटरी मौजूद है:

dependencyResolutionManagement {
    repositories {
        maven {
            url = uri("https://repo.repsy.io/mvn/winrid/fastcomments")
        }
        // अन्य रिपॉज़िटरी...
    }
}

मूल उपयोग Internal Link

1. अपने लेआउट में FastCommentsView जोड़ें

<com.fastcomments.sdk.FastCommentsView
    android:id="@+id/commentsView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

2. SDK को इनिशियलाइज़ और कॉन्फ़िगर करें

// SDK कॉन्फ़िगर करें
val config = CommentWidgetConfig(
    "your-tenant-id", 
    "page-url-id", 
    "Page Title", 
    "yourdomain.com", 
    "Site Name"
)

// अतिरिक्त कॉन्फ़िगरेशन विकल्प
config.voteStyle = VoteStyle.UpDown // या VoteStyle.Heart
config.enableInfiniteScrolling = true
config.hasDarkBackground = true // डार्क मोड सपोर्ट के लिए

// SDK को इनिशियलाइज़ करें
val sdk = FastCommentsSDK(config)

// अपने लेआउट में कमेंट्स व्यू खोजें
val commentsView = findViewById<FastCommentsView>(R.id.commentsView)

// व्यू के लिए SDK इंस्टेंस सेट करें
commentsView.setSDK(sdk)

// कमेंट्स लोड करें
commentsView.load()

सुरक्षित SSO प्रमाणीकरण Internal Link

अपने उपयोगकर्ताओं के लिए सुरक्षित प्रमाणीकरण लागू करें:

// Create user data (ideally on your server)
val userData = SecureSSOUserData(
    "user-id",
    "user@example.com",
    "User Name",
    "https://path-to-avatar.jpg"
)

// Generate SSO token (should be done server-side!)
val sso = FastCommentsSSO.createSecure("YOUR_API_KEY", userData)
val token = sso.prepareToSend()

// Add to config
config.sso = token

फ़ीड एकीकरण Internal Link

टिप्पणियों के साथ सोशल मीडिया शैली का फ़ीड प्रदर्शित करें:

// SDK कॉन्फ़िगर करें
CommentWidgetConfig config = new CommentWidgetConfig();
config.tenantId = "your-tenant-id";
config.urlId = "page-url-id";

// Feed SDK प्रारंभ करें
FastCommentsFeedSDK feedSDK = new FastCommentsFeedSDK(config);

// फ़ीड व्यू सेट अप करें
FastCommentsFeedView feedView = findViewById(R.id.feedView);
feedView.setSDK(feedSDK);

// इंटरैक्शन लिसनर सेट करें
feedView.setFeedViewInteractionListener(new FastCommentsFeedView.OnFeedViewInteractionListener() {
    @Override
    public void onFeedLoaded(List<FeedPost> posts) {
        // फ़ीड सफलतापूर्वक लोड हुआ
    }

    @Override
    public void onFeedError(String errorMessage) {
        // त्रुटियों को संभालें
    }

    @Override
    public void onPostSelected(FeedPost post) {
        // उपयोगकर्ता ने एक पोस्ट चुनी
    }

    @Override
    public void onCommentsRequested(FeedPost post) {
        // पोस्ट के लिए टिप्पणियाँ दिखाएँ
        CommentsDialog dialog = new CommentsDialog(context, post, feedSDK);
        dialog.show();
    }
});

// फ़ीड लोड करें
feedView.load();

लाइव चैट एकीकरण Internal Link

अपने ऐप में एक रीयल-टाइम चैट इंटरफ़ेस जोड़ें:

// अपने लेआउट XML में LiveChatView जोड़ें
// <com.fastcomments.sdk.LiveChatView
//     android:id="@+id/liveChatView"
//     android:layout_width="match_parent"
//     android:layout_height="match_parent" />

// SDK के लिए एक कॉन्फ़िगरेशन बनाएं
val config = CommentWidgetConfig().apply {
    tenantId = "your-tenant-id"
    urlId = "chat-room-identifier" 
    pageTitle = "Chat Room Name"
}
LiveChatView.setupLiveChatConfig(config)

// वैकल्पिक: यूज़र ऑथेंटिकेशन जोड़ें
val userData = SimpleSSOUserData(
    "User Name",
    "user@example.com",
    "https://path-to-avatar.jpg"
)
val sso = FastCommentsSSO(userData)
config.sso = sso.prepareToSend()

// SDK को इनिशियलाइज़ करें
val sdk = FastCommentsSDK().configure(config)

// लाइव चैट व्यू सेट अप करें
val liveChatView = findViewById<LiveChatView>(R.id.liveChatView)
liveChatView.setSDK(sdk)
liveChatView.load()

// लाइफ़साइकिल हैंडलिंग करना न भूलें
override fun onResume() {
    super.onResume()
    sdk.refreshLiveEvents()
}

override fun onDestroy() {
    super.onDestroy()
    sdk.cleanup()
}

उदाहरण प्रोजेक्ट Internal Link

इन डेमो इम्प्लीमेंटेशन को देखें:

कॉन्फ़िगरेशन विकल्प Internal Link

SDK CommentWidgetConfig क्लास के माध्यम से कई कॉन्फ़िगरेशन विकल्प प्रदान करता है:

विकल्पविवरण
tenantIdआपकी FastComments खाता ID
urlIdवर्तमान पृष्ठ का प्रतिनिधित्व करने वाली ID
ssoप्रमाणीकरण के लिए SSO टोकन
allowAnonगुमनाम टिप्पणी की अनुमति दें
voteStyleUpDown या Heart वोटिंग शैली
hideAvatarsउपयोगकर्ता अवतार छिपाएँ
hasDarkBackgroundडार्क मोड दर्शाता है
customCSSकस्टम CSS स्टाइल
enableInfiniteScrollingअनंत स्क्रॉल पेजिनेशन सक्षम करें
readonlyटिप्पणी अक्षम करें लेकिन टिप्पणियाँ दिखाएँ
disableVotingवोटिंग कार्यक्षमता अक्षम करें
disableLiveCommentingरीयल-टाइम अपडेट अक्षम करें
pollCreationकौन टिप्पणी से पोल जोड़ सकता है: NUMBER_0 अक्षम, NUMBER_1 एडमिन और मॉडरेटर, NUMBER_2 सभी
pollVotingकौन पोल पर वोट कर सकता है: NUMBER_0 लॉग इन उपयोगकर्ता, NUMBER_1 कोई भी

पोल Internal Link

पोल वेब विजेट की तरह ही काम करते हैं, और आपके FastComments डैशबोर्ड में उसी विजेट सेटिंग्स से चालू होते हैं (या ऊपर दिए गए pollCreation / pollVoting से)।

  • पोल वाले कमेंट्स उनके टेक्स्ट के नीचे उसे दिखाते हैं। पाठक किसी विकल्प पर टैप करके वोट करते हैं, वोट करने से पहले परिणाम दिखा या छिपा सकते हैं, और अपना वोट बदल सकते हैं। जैसे ही अन्य लोग वोट करते हैं, गिनती लाइव अपडेट होती है।
  • पोल किसी तारीख पर बंद हो सकते हैं, वोट करने तक परिणाम छिपा सकते हैं, और वोटर्स को एडमिन्स या सभी को दिखा सकते हैं ("See who voted")।
  • जब दर्शक पोल बना सकता हो, तो FastCommentsView के कमेंट इनपुट में एक पोल बटन दिखता है जो पोल बिल्डर खोलता है। इसके लिए टूलबार पंक्ति तब भी दिखती है जब आपने कभी टूलबार चालू न किया हो; sdk.setCommentToolbarEnabled(false) इसे छिपा देता है, पोल बटन समेत, और इनपुट पर setPollCreationEnabled(false) केवल पोल बटन हटाता है। FastCommentsView बनाने से पहले setCommentToolbarEnabled कॉल करें, क्योंकि इनपुट SDK प्राप्त करते समय इसे पढ़ता है; पहले से स्क्रीन पर मौजूद व्यू के लिए, इसके बजाय getBottomCommentInput().setToolbarVisible(false) कॉल करें। लाइव चैट इनपुट इसे छोड़ देता है, जैसे वेब लाइव चैट।

अपने अपने UI से पोल पोस्ट करने के लिए, postComment को एक CommentPollInput पास करें:

CommentPollInput poll = new CommentPollInput()
        .question("Where should we eat?")
        .options(Arrays.asList("Tacos", "Ramen"))
        // वैकल्पिक: एक ISO 8601 बंद होने की तारीख, PollPrivacy मान, और वोट करने तक छिपे परिणाम।
        .closesAt(Instant.now().plus(1, ChronoUnit.DAYS).toString())
        .privacy(PollPrivacy.NUMBER_2.getValue())
        .requireVoteToSeeResults(true);
sdk.postComment("Lunch vote", null, null, poll, callback);

sdk.votePoll(commentId, optionId, callback) और sdk.getPollVoters(commentId, page, search, callback) वोटिंग और वोटर सूची को कवर करते हैं। पोल के रंग THEMING.md में सूचीबद्ध हैं।

व्यापक थीम अनुकूलन Internal Link

FastComments SDK में सभी बटन और UI तत्व थीमयोग्य हैं। अपने ऐप की ब्रांडिंग पर पूर्ण नियंत्रण के लिए FastCommentsTheme.Builder का उपयोग करें।

प्रोग्रामेटिक थीमिंग (अनुशंसित)

val theme = FastCommentsTheme.Builder()
    // एक्शन बटन: Send, vote, menu, like/share बटन
    .setActionButtonColor(Color.parseColor("#FF1976D2"))
    
    // रिप्लाई बटन: कमेंट रिप्लाई बटन  
    .setReplyButtonColor(Color.parseColor("#FF4CAF50"))
    
    // टॉगल बटन: Show/hide replies बटन
    .setToggleRepliesButtonColor(Color.parseColor("#FFFF5722"))
    
    // Load more बटन: पेजिनेशन बटन
    .setLoadMoreButtonTextColor(Color.parseColor("#FF9C27B0"))
    
    .setPrimaryColor(Color.parseColor("#FF6200EE"))
    .setLinkColor(Color.parseColor("#FF1976D2"))
    .setDialogHeaderBackgroundColor(Color.parseColor("#FF333333"))
    .build()

// थीम लागू करें
sdk.setTheme(theme)

त्वरित रंग ओवरराइड

सरल ब्रांडिंग के लिए अपने colors.xml में रंग संसाधनों को ओवरराइड करें:

<!-- अपने ऐप के res/values/colors.xml में -->
<resources>
    <!-- सभी प्राथमिक UI तत्व बदलें -->
    <color name="primary">#FF1976D2</color>
    
    <!-- या विशिष्ट बटन प्रकार अनुकूलित करें -->
    <color name="fastcomments_action_button_color">#FF1976D2</color>
    <color name="fastcomments_reply_button_color">#FF4CAF50</color>
    <color name="fastcomments_toggle_replies_button_color">#FFFF5722</color>
    <color name="fastcomments_load_more_button_text_color">#FF9C27B0</color>
</resources>

थीम वाले बटन कवरेज

SDK में हर बटन थीमिंग का समर्थन करता है:

  • Send बटन, vote बटन, menu बटन, reply बटन
  • Show/hide replies बटन, load more बटन
  • फ़ीड एक्शन बटन (like, comment, share)
  • डायलॉग बटन (submit, cancel, save)
  • फ़ीड पोस्ट में डायनामिक टास्क बटन

विस्तृत थीमिंग दस्तावेज़ीकरण के लिए, THEMING.md देखें।

मेमोरी प्रबंधन Internal Link

मेमोरी लीक को रोकना

Activities या Fragments में FastComments views का उपयोग करते समय मेमोरी लीक को रोकने के लिए, जब view की अब आवश्यकता न हो तो हमेशा cleanup() कॉल करें:

Activities में:

@Override
protected void onDestroy() {
    super.onDestroy();
    // मेमोरी लीक को रोकने के लिए FastComments views को क्लीन अप करें
    if (feedView != null) {
        feedView.cleanup();
    }
    if (commentsView != null) {
        commentsView.cleanup();
    }
}

Fragments में:

@Override
public void onDestroyView() {
    super.onDestroyView();
    // fragment view नष्ट होने पर FastComments views को क्लीन अप करें
    if (feedView != null) {
        feedView.cleanup();
        feedView = null;
    }
}

@Override
public void onDestroy() {
    super.onDestroy();
    // fragment नष्ट होने पर अतिरिक्त क्लीनअप
    if (feedSDK != null) {
        feedSDK.cleanup();
        feedSDK = null;
    }
}

Fragments बदलते समय:

// FastComments views वाले fragment को बदलने या हटाने से पहले
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.container);
if (currentFragment instanceof YourFragmentWithFeedView) {
    ((YourFragmentWithFeedView) currentFragment).cleanupFeedView();
}

// फिर fragment transaction के साथ आगे बढ़ें
getSupportFragmentManager().beginTransaction()
    .replace(R.id.container, newFragment)
    .commit();

महत्वपूर्ण: मेमोरी लीक को रोकने के लिए हमेशा cleanup() मेथड्स कॉल करें, विशेष रूप से जब:

  • Activities नष्ट हो जाएं
  • Fragment views नष्ट हो जाएं
  • Fragments के बीच स्विच किया जा रहा हो
  • FastComments components वाली screens से दूर नेविगेट किया जा रहा हो

सहायता चाहिए?

यदि आपको Android Library के बारे में कोई समस्या आती है या कोई प्रश्न है, तो कृपया:

योगदान दें

योगदान का स्वागत है! कृपया योगदान दिशानिर्देशों के लिए GitHub रिपॉजिटरी देखें।