Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to load messages retrieved from web service to this controller #1

Open
deeps2904 opened this issue Nov 2, 2017 · 5 comments
Open

Comments

@deeps2904
Copy link

Respected Sir,

If I m using anywebservice to retrieve msg then how would I pass that array so that msgs retrieved from service are shown on ui of chatasync controller?

@mukyasa
Copy link
Owner

mukyasa commented Nov 2, 2017

You have to create an array of Message objects and pass that to chat controller. If you see the demo I have created static array of Message objects.

@deeps2904
Copy link
Author

sir I m inherting myviewcontroller from chatasynchviewcontroller. Executing web service in my view controller.... and I m getting my data... I need to pass my data to your viewcontrroler array... I m not getting how to access that array .

Please provide ur contact details I need to talk with you

please

@deeps2904
Copy link
Author

please, help me buddy... I m getting in big issue... please help

@mukyasa
Copy link
Owner

mukyasa commented Nov 3, 2017

Bro, I can only guide you. As I accept this library is just simulation so you have work more to change it according to your requirement

Now check ChatAsyncViewController in that fetchMessages which will show you how the Message array is created variable name is messages the array which is used by example

If you want you can comment fetchMessages and write your own function for populating the Chats with your web service.

//MARK: - Fetch Messages
open func fetchMessages(){

    //Loading Earlier message i have repeated the same you can add your through webservice
    if(showEarlierMessage == true){
        
        var paths = [IndexPath]()
        var temp = [Message]()
        for i in 0 ..< messages.count{
            
            temp.append(messages[i])
            paths.append(IndexPath(item: i, section: 0))
        }
        
        messages = temp + messages
        self.collectionView?.performBatchUpdates({
            
            self.collectionView?.insertItems(at: paths)
            
            
        }, completion: { (bool) in

        })

    }else{

     //Fresh messages bottom
        messages.append(Message(msg: "Hello all"))
        messages.append(Message(msg: "This is quick demo"))
        messages.append(Message(msg: "Texture’s basic unit is the node. ASDisplayNode is an abstraction over UIView, which in turn is an abstraction over CALayer. Unlike views, which can only be used on the main thread, nodes are thread-safe: you can instantiate and configure entire hierarchies of them in parallel on background threads."))
        messages.append(Message(image: "https://s-media-cache-ak0.pinimg.com/736x/43/bd/ef/43bdef2a0af4f55238f1df4913b3188b--super-hero-shirts-ironman.jpg"))
        messages.append(Message(msg: "Texture lets you move image decoding, text sizing and rendering, and other expensive UI operations off the main thread, to keep the main thread available to respond to user interaction. Texture has other tricks up its sleeve too… but we’ll get to that later"))
        messages.append(Message(image: "https://media3.giphy.com/media/kEKcOWl8RMLde/giphy.gif", caption: "demo caption"))
        messages.append(Message(msg: "Understanding of performance issue, especially some common uses like tableview pre rendering, helps"))
        messages.append(Message(videourl: "https://www.w3schools.com/html/mov_bbb.mp4"))
        

    }


}

@rajahimanath
Copy link

I created a new VC and wanted to simulate ChatAsyncViewController behavior but started getting ChatDelegate not found error. Can you please check on your end again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants