How to init AmityCommunityModel

I’m using this code to display a feed controller

socialViewController = AmityFeedViewController.make(
            feedType: .communityFeed(communityId: "XXXXXX")
        )

but I need an AmityCommunityModel for it - how do I initialize the object?

From UIKit 2.0.4 onward you can init AmityCommunityModel using communityRepository.getcommunity. Please see example here:

Thank you so much for you help with the post @touchaponk! After using the code, I have more questions now:

  1. There is currently no post button in the screen (check the screenshot) - is there a way to activate this?
  2. The example code is kinda ugly, it only works if a user is only enrolled in one group. Is it not possible to create the AmityPostCreatorViewController based on the .communityFeed(communityId: "XXXXXX") / communityId similar to the AmityFeedViewController?? Seems a whole lot cleaner.

Thanks in advance!
Cheers
Markus

This issue is related to the presentation style, the presentation style must be overFullScreen:
modalPresentationStyle = .overFullScreen
Because the post button is a part of navigationItem, we need to present it full screen to be able to see the navigation bar with navigation Items

let postCreatorViewController = AmityPostCreatorViewController.make(postTarget: postTarget)
let navigationController = UINavigationController(rootViewController: postCreatorViewController)
navigationController.modalPresentationStyle = .overFullScreen
present(navigationController, animated: true, completion: nil)

It’s not possible to use communityId instead of community model to create AmityPostCreatorViewController for the current API .

To get community model for existing communityId we can use following:

let communityRepository = AmityCommunityRepository(client: AmityUIKitManagerInternal.shared.client)
var communityInfoToken: AmityNotificationToken?
var communityModel: AmityCommunityModel?

communityInfoToken = repository.getCommunity(withId: communityId).observe{ [weak self] (community, error) in
    guard let object = community.object else { return }
    communityModel = AmityCommunityModel(object: object)
    
    if community.dataStatus == .fresh {
           self?.communityInfoToken?.invalidate()
    }
}