GetStream / stream-swift

Swift client for Stream API
https://getstream.io
BSD 3-Clause "New" or "Revised" License
35 stars 26 forks source link

Not Getting Flat Feed #5

Closed umair-ali-confiz closed 5 years ago

umair-ali-confiz commented 5 years ago

Please wrap code blocks in backticks, like so:


        let jalalFeed = Client.shared.flatFeed(feedSlug: "timeline", userId: "Jalal_Hussain")

        jalalFeed.get(pagination: .limit(10)) { result in
            do {
                let response = try result.get()
                print(response.results)
            } catch let error {
                print(error.localizedDescription)
            }
        }

What did you do?

I have set the client configuration with api key, appid and token. I have tested the token with rest API of Feed fetch and it is working over there.

What did you expect to happen?

I want to get feed using Stream-swift SDK. But it did not call completion block of jalalFeed.get.

What happened instead?

It should call the completion block of jalalFeed.get.

GetStream Environment

GetStream version: 1.0 Xcode version: 10.1 Swift version: 4.2 Platform(s) running GetStream: pod macOS version running Xcode: 10.14

Additional context

Add any other context about the problem here.

buh commented 5 years ago

@umair-ali-confiz Please, be sure that your jalalFeed wasn't deallocated after request. If it's not a problem, could you enable logs in the Client config and show the output?

umair-ali-confiz commented 5 years ago

Thanks, @buh for the quick response. Yes the issue with the jalalFeed object, it was deallocated after the call. I just change the scope of the object and issue resolved.

ndyeager commented 5 years ago

@umair-ali-confiz I'm having the same issue and am pretty new to swift. How did you resolve this issue?

buh commented 5 years ago

Hi @ndyeager, In the above example, immediately after the last use of jalalFeed, it was automatically released, because it will no longer be used in the rest of the function, and no one knows about it outside the scope. At the same time, requests work asynchronously, so the request result will not be printed. Usually, you have to declare jalalFeed variable as an instance of some TimelineViewController.

ndyeager commented 5 years ago

@buh Thank for your reply and the clarification.