Topics

Create Topics

You can create and manage topics from the Dashboard and HTTP API. To create topics from the dashboard navigate to the Topics page and click on the New Topic button.

Create Topic - GetSocial Dashboard

Topic creation needs the following information:

  1. Topic id: this is a unique id that you provide to identify the topic
  2. Name and Description: Name of the topic and description that you can make visible to your users. You can also enable users to search and discover topics by topic name. These can also be localized to 36+ supported languages.
  3. Icon: Topic icon is optional. Icon can be displayed with name and description in the app
  4. Permissions: with topic permissions you can define which users can post activity and interact with the topic. Interaction includes comments and reactions. You can enable everyone to post and interact, or only followers or a combination of one or more.
  5. Properties: additional metadata that you can add to the topic e.g custom data that might define UI elements for topic like topic color.

Get Topics

You can get a paginated list of all topics in your application:

1
2
3
4
5
6
7
8
val query = TopicsQuery.all()
val pagingQuery = PagingQuery(query)
Communities.getTopics(pagingQuery, { result: PagingResult<Topic> ->
    val topics = result.entries
    Log.d("Communities", "Topics: $topics")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to get list of topics: $error")
})
1
2
3
4
5
6
7
let query = TopicsQuery.all()
let pagingQuery = TopicsPagingQuery(query)
Communities.topics(pagingQuery, success: { result in
    print("Topics: \(result.topics)")
}, failure: { error in
    print("Failed to get list of topics: \(error)")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
var query = TopicsQuery.All();
var pagingQuery = new PagingQuery<TopicsQuery>(query);

Communities.GetTopics(pagingQuery,
    (result) => {
        Debug.Log("Topics: " + result.Entries);
    },
    (error) => {
        Debug.Log("Failed to get list of topics, error: " + error);
    });

This method uses the PagingQuery concept that is used across our SDK. Read more about this.

Find Topics

You can also search topics by a query. Method returns all topics that contains the provided query as a substring in ID or Title. It is also case-insensitive.

1
2
3
4
5
6
7
8
9
val searchString = "cat"
val query = TopicsQuery.find(searchString)
val pagingQuery = PagingQuery(query)
Communities.getTopics(pagingQuery, { result: PagingResult<Topic> ->
    val topics = result.entries
    Log.d("Communities", "Topics contains $searchString: $topics")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to get list of topics: $error")
})
1
2
3
4
5
6
7
8
let searchString = "cat"
let query = TopicsQuery.find(searchString)
let pagingQuery = TopicsPagingQuery(query)
Communities.topics(pagingQuery, success: { result in
    print("Topics containing \(searchString): \(result.topics)")
}, failure: { error in
    print("Failed to get list of topics: \(error)")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
var query = TopicsQuery.Find("cats");
var pagingQuery = new PagingQuery<TopicsQuery>(query);

Communities.GetTopics(pagingQuery,
    (result) => {
        Debug.Log("Topics including `cats`: " + result.Entries);
    },
    (error) => {
        Debug.Log("Failed to search for topics, error: " + error);
    });

This method uses the PagingQuery concept that is used across our SDK. Read more about this.

Get Topics Count

Use the same query as you’re using to Get or Search topics.

1
2
3
4
5
6
7
val searchString = "cat"
val query = TopicsQuery.find(searchString)
Communities.getTopicsCount(query, { result: Int ->
    Log.d("Communities", "Topics count contains $searchString: $result")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to get number of topics: $error")
})
1
2
3
4
5
6
7
let searchString = "cat"
let query = TopicsQuery.find(searchString)
Communities.topicsCount(query, success: { topicsCount in
    print("Topics count containing \(searchString): \(topicsCount)")
}, failure: { error in
    print("Failed to get number of topics: \(error)")
})
1
2
3
4
5
6
7
8
9
var query = TopicsQuery.Find("cats");

Communities.GetTopicsCount(query,
    (result) => {
        Debug.Log("Number of topics including `cats`: " + result);
    },
    (error) => {
        Debug.Log("Failed to get number of topics, error: " + error);
    });

Get Topic By ID

If you have just an ID of topic, you can get the topic object:

1
2
3
4
5
6
7
val topicId = "topic-id"

Communities.getTopic(topicId, { topic ->
    Log.d("Communities", "Topic with id $topicId: $topic")
}, { error ->
    Log.d("Communities", "Failed to get a topic: $error")
})
1
2
3
4
5
6
let topicId = "topic-id"
Communities.topic(topicId, success: { topic in
    print("Topic with id '\(topicId): \(topic)")
}, failure: { error in
    print("Failed to get topic: \(error)")
})
1
2
3
4
5
6
7
8
9
var topicId = "topic-id";

Communities.GetTopic(topicId,
    (result) => {
        Debug.Log("Topic: " + result);
    },
    (error) => {
        Debug.Log("Failed to get topic, error: " + error);
    });

Work With Topic Object

Learn what can you do with topic object in Android and iOS.

Give us your feedback! Was this article helpful?

😀 🙁