May I understand your use-case of the screen please?
It seems like you’re trying to query reviewing posts in a particular community. If you’d like to see all of the published posts in a community, you may consider using feedType(AmityFeedType. PUBLISHED) instead.
I have already checked feedType as AmityFeedType.PUBLISHED, but same result. Not getting anything. Then I changed this to AmityFeedType.REVIEWING. Still the same.
Thank you for reaching out to us, and please apologize for my delayed response.
Based on your query, there could be several reasons why the user is not able to fetch posts available for a particular community. Let’s go through them step by step:
SDK Initialization and Authentication: Make sure that the SDK is properly initialized and set up with an API key at the application level. You can refer to this guide for assistance. Further, ensure that the login procedure is completed before initiating any other actions in your application. For more information on this, you can check out this resource.
Regarding the authentication token, we strongly recommend using authToken for authentication in a production environment. The option to proceed without an authToken should only be utilized during the development stage.
Invalid Post Types: In the types query option, you might not need to specify if you wish to query all the posts in a community. It’s possible that the existing posts in a community do not match the specified query option.
Posts Availability: It’s possible that the targeted community doesn’t have any posts yet. Please confirm if there is at least one post created in the community you are trying to access. To learn more about creating posts, please visit this link.
Please check these potential issues and see if the situation improves. If you are still facing difficulties, don’t hesitate to let us know. We’re here to help!
Hi @Trust, thank you for your response. I have checked your steps, below are the findings:
SDK Initialization and Authentication: I have set up sdk before making any call to fetch posts.
Currently for dev I am not using auth token, will implement that in produciton.
I have removed post type from query. Still not getting posts. (I am able to post any content to
community which I can see on Amity protal).
There are couple of posts available for the community i am trying to fetch.
In main.dart, I have added below code:
///Set up Amity social cloud
await AmityCoreClient.setup(
option: AmityCoreClientOption(
apiKey: amityApiKey,
httpEndpoint: AmityRegionalHttpEndpoint.SG,
showLogs: true,
),
sycInitialization: true,
);
Then I am checking if user is logged in or not using AmityCoreClient.isUserLoggedIn(). Unfortunately user is logged out every time I restart the app. So. I am logging user again using this code:
AmityCoreClient.login(userId).displayName(name).submit();
I have created a provider to fetch and create posts:
Inside my provider, to fetch posts:
void initPagingController(String communityId) {
_controller = PagingController(
pageFuture: (token) {
return AmitySocialClient.newPostRepository()
.getPosts()
.targetCommunity(communityId)
// supported data types are IMAGE, VIDEO, and FILE
// .types(
// [AmityDataType.IMAGE, AmityDataType.VIDEO, AmityDataType.TEXT])
//feedType could be AmityFeedType.PUBLISHED, AmityFeedType.REVIEWING, AmityFeedType.DECLINED
// .feedType(AmityFeedType.PUBLISHED)
// .sortBy(AmityPostSortOption.LAST_CREATED)
.includeDeleted(false)
.getPagingData(token: token, limit: 20);
},
pageSize: 20,
);