Giter VIP home page Giter VIP logo

stream-swift's Introduction

Stream Swift Client

Build Status Code Coverage Language: Swift 4.2 Documentation CocoaPods compatible Carthage compatible Swift Package Manager compatible

stream-swift is a Swift client for Stream.

You can sign up for a Stream account at https://getstream.io/get_started.

API Docs

API Examples

⚠️ Client-side SDK no longer actively maintained by Stream

A Feeds integration includes a combination of server-side and client-side code and the interface can vary widely which is why we are no longer focussing on supporting this SDK. If you are starting from scratch we recommend you only use the server-side SDKs.

This is by no means a reflection of our commitment to maintaining and improving the Feeds API which will always be a product that we support.

We continue to welcome pull requests from community members in case you want to improve this SDK.

Installation

CocoaPods

For Stream, use the following entry in your Podfile:

for Swift 5:

pod 'GetStream', '~> 2.0'

for Swift 4.2:

pod 'GetStream', '~> 1.0'

Then run pod install.

In any file you'd like to use Stream in, don't forget to import the framework with import GetStream.

Swift Package Manager

To integrate using Apple's Swift package manager, add the following as a dependency to your Package.swift:

.package(url: "https://github.com/GetStream/stream-swift.git", .upToNextMajor(from: "1.0.0"))

Carthage

Make the following entry in your Cartfile:

github "GetStream/stream-swift"

Then run carthage update.

Quick start

// Setup a shared Stream client.
Client.config = .init(apiKey: "<#ApiKey#>", appId: "<#AppId#>", token: "<#Token#>")

// Setup a Stream current user with the userId from the Token.
Client.shared.createCurrentUser() { _ in 
    // Do all your requests from here. Reload feeds and etc.
}

// Create a user feed.
let userFeed = Client.shared.flatFeed(feedSlug: "user")

// Create an Activity. You can make own Activity class or struct with custom properties.
let activity = Activity(actor: User.current!, verb: "add", object: "picture:10", foreignId: "picture:10")

userFeed?.add(activity) { result in
    // A result of the adding of the activity.
    print(result)
}

// Create a following relationship between "timeline" feed and "user" feed:
let timelineFeed = Client.shared.flatFeed(feedSlug: "timeline")

timelineFeed?.follow(toTarget: userFeed!.feedId, activityCopyLimit: 1) { result in
    print(result)
}

// Read timeline and user's post appears in the feed:
timelineFeed?.get(pagination: .limit(10)) { result in
    let response = try! result.get()
    print(response.results)
}

// Remove an activity by referencing it's foreignId
userFeed?.remove(foreignId: "picture:10") { result in
    print(result)
}

More API examples here

Copyright and License Information

Copyright (c) 2016-2018 Stream.io Inc, and individual contributors. All rights reserved.

See the file "LICENSE" for information on the history of this software, terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.

stream-swift's People

Contributors

b-onc avatar buh avatar cardoso avatar ceciliadev avatar luisgereda avatar mohamadrezakoohkan avatar nuno-vieira avatar robderstadt avatar tbarbugli avatar tschellenbach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stream-swift's Issues

Closures / Callbacks of GetStream methods are not called

What did you do?

Integrated GetStream to Xcode Project

  pod 'Alamofire'
  pod 'GetStream', '~> 2.2.2'

Initialized GetStream on AppDelegate :

Client.config = .init(apiKey: "XXXXX", appId: "XXXX", logsEnabled: true)
Client.shared.setupUser(token: "XXXXX") { (result) in
      // THIS IS SUCCESSFUL
}

On the ViewController, trying to fetch the activities from a feed (which have activities inside)

let userFeed = Client.shared.flatFeed(feedSlug: "FLAT_FEED_ID", userId: "LOGGED_USER_ID")

let activity = Activity(actor: User.current!, verb: "pin", object: "Place:72482734")

userFeed.add(activity) { result in
    if let activity = try? result.get() {
          print(activity.id)
     } else {
          print("FAILED")
     }
}

userFeed.get() { result in
        print(result)
}

What did you expect to happen?

userFeed.add(activity) { result in
   print("Callback called") // ----> This should get called?
   if let activity = try? result.get() {
        print(activity.id) // ----> This should get called?
   } else {
       print("FAILED") // ----> This should get called?
    }
}

userFeed.get() { result in
        print(result) // ----------> This should print out a result?
}

What happened instead?

userFeed.add(activity) { result in
   print("Callback called") // ----> Never called
   if let activity = try? result.get() {
         print(activity.id) // ----> Never called
   } else {
         print("FAILED") // ----> Never called
   }
}

userFeed.get() { result in
        print(result) // ---->  Never called
}

However, since I have the logsEnabled to true, I'm able to see the raw JSON values in the Xcode Console with all my activities from that feed. The activities are successfully posted to the feed but the closures are just not called.

GetStream Environment

GetStream version: 2.2.2
Xcode version: 11.5
Swift version: 5
Platform(s) running GetStream: iOS 13.5
macOS version running Xcode: macOS 10.15.4

Additional context

I've also tried removing all the pods and installing GetStream using pod 'GetStream' instead of version 2.2.2, but I have the same issue even on a fresh install.

JSON decoding error

I am trying to fetch the activity feed with the below code:

               self.timeline = Client.shared.flatFeed(feedSlug: "timeline")
                
                if let timeline = self.timeline {
                    print(timeline)
                    timeline.get(typeOf: FeedItem.self, enrich: false, pagination: .limit(50)) { r in
                        print("WHY!")
                        print(try! r.get().results)
                    }
                }

My FeedItem class looks like:

import GetStream

struct Data: Codable {
    var source: String
    var externalId: String
    var title: String
    var excerpt: String
    var image: String?
    var url: String
    var published: String
}

final public class FeedItem : EnrichedActivity<User, String, DefaultReaction> { 

    private enum CodingKeys: String, CodingKey {
        case data
    }
    
    var data: Data

    
    required init(from decoder: Decoder) throws {
        
        print("Decoding")
        let container = try decoder.container(keyedBy: CodingKeys.self)
        data = try container.decode(Data.self, forKey: .data)
        print(data)

        print("DONE")
        try super.init(from: decoder)
        print("Finished")
    }
    
    required init(actor: ActorType, verb: Verb, object: ObjectType, foreignId: String? = nil, time: Date? = nil, feedIds: FeedIds? = nil, originFeedId: FeedId? = nil) {
        fatalError("init(actor:verb:object:foreignId:time:feedIds:originFeedId:) has not been implemented")
    }
    
    
    override public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(data, forKey: .data)

        try super.encode(to: encoder)
    }
}

The error I am getting:

Fatal error: 'try!' expression unexpectedly raised an error: JSON decoding error: The data couldn’t be read because it isn’t in the correct format.. Data: 39648 bytes: file

GetStream version: 2.2.3
Xcode version: 11.6
Swift version: 5

❌ flatfeed.add completion block never executed!

What did you do?

I am calling flatbed.add by passing the activity which I would like to add.

What did you expect to happen?

The completion block is executed and it goes into the .success case.

What happened instead?

The code goes out of guard when checking for self object. Due to that fact, the completion block is never executed.

GetStream Environment

GetStream version: 2.2.5
Xcode version: 13.4.1
**Swift version:5
Platform(s) running GetStream:
**macOS version running Xcode:Monterey 12.6

Additional context

However, that's happening only in code. When I check the get stream.io platform I can see that my activity is added successfully to the chosen feed id.

Not Getting Flat Feed

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.

Docs are out of date

What did you do?

I followed the documentation exactly, in multiple places it is mentioned to initialize the Stream Swift client like this:

Client.config = .init(apiKey: "<#ApiKey#>", appId: "<#AppId#>", token: "<#Token#>")

It mentions this:

  • Here, in this repository's own README
  • Here in the main Stream Swift docs

What did you expect to happen?

I expected the documentation to be useful and accurate

What happened instead?

It turns out the API interface has changed, as depicted here, so my application broke with a bunch of compile-time errors, despite using the latest version of the package and following the documentation exactly

GetStream Environment

GetStream version: Latest
Xcode version: Latest
Swift version: Latest
Platform(s) running GetStream: iOS / Web
macOS version running Xcode: Latest

403 when adding activities to feed

What did you do?

let client = Client(apiKey: apiKey, appId: appId, token: tokenForUser)
self.feed = client.flatFeed(feedSlug: "user")
let activity = PostActivity(actor: "user", verb: "post", object: UUID().uuidString, message: "message")
feed!.add(activity) {result in
    print(result)
}
=> failure(NotAllowedException[17] Status Code: 403, You don't have the permission to do this)

What did you expect to happen?

Activity is posted to feed

What happened instead?

I get a 404

Additional context

Is this caused because I'm using a string actor? The token is generated for the same user id (in this case "user") that the activity uses. When I use the User object, it works fine.

Weird issue in getting data using timeline.get feedslug

What did you do?

Running the app without breakpoints

What did you expect to happen?

It should respond be in closure

What happened instead?

It's not even coming in closure

GetStream Environment

GetStream version:
Xcode version:
Swift version:
Platform(s) running GetStream:
macOS version running Xcode:

Additional context

I am getting a weird issue, if I run by adding breakpoint and print the slug and continue running the project it works fine, but if I am running project without breakpoints, getstream is not responding in their callback or doing anything, I tried implementing delays but no use

code:

Client.config = .init(apiKey: GET_STREAM_API_KEY, appId: GET_STREAM_APP_ID, token: timelineToken)
let timeline = Client.shared.flatFeed(feedSlug: "timeline", userId: userId)
timeline.get(typeOf: ReviewActivity.self) { [weak self] (response) in
    print(response)
}

Example code does not compile

What did you do?

Copied example code from: https://getstream.github.io/stream-swift/Protocols/CollectionObjectProtocol.html

    final class Food: CollectionObject {
        private enum CodingKeys: String, CodingKey {
            case name
        }

        var name: String

        init(name: String, id: String? = nil) {
            self.name = name
            super.init(collectionName: "food", id: id)
        }

        required init(from decoder: Decoder) throws {
            let dataContainer = try decoder.container(keyedBy: DataCodingKeys.self)
            let container = try dataContainer.nestedContainer(keyedBy: CodingKeys.self, forKey: .data)
            name = try container.decode(String.self, forKey: .name)
            try super.init(from: decoder)
        }

        override func encode(to encoder: Encoder) throws {
            var dataContainer = encoder.container(keyedBy: DataCodingKeys.self)
            var container = dataContainer.nestedContainer(keyedBy: CodingKeys.self, forKey: .data)
            try container.encode(name, forKey: .name)
            try super.encode(to: encoder)
        }
    }

What did you expect to happen?

Expected the code to compile at least.

What happened instead?

Got an error: 'required' initializer 'init(collectionName:id:)' must be provided by subclass of 'CollectionObject'

GetStream Environment

GetStream version:

2.2.4

Xcode version:

12.4

Swift version:

5

Platform(s) running GetStream:

iOS

macOS version running Xcode:

Big Sur

getting Activities is not working, FlatFeed's call back dose not fired.

While getting activities the call back does not fired because self equals nil in result clouser in FlatFeed.swift
if let self = self {. // self all ways equal nil result.parse(self.callbackQueue, completion) }

GetStream version:

  • GetStream (2.2.3):
    • GetStream/Core (= 2.2.3)
    • GetStream/Faye (= 2.2.3)
      Xcode version: 12.2
      Swift version: 5

gz#8070

Upgrade GetStream Library to use Moya 14

What did you do?

Tried to build my app with the GetStream library

What did you expect to happen?

I could run pod install and everything worked correctly.

What happened instead?

I received an error because my app uses Alamofire 5

I did some searching in the Moya project. The latest version works with Alamofire 5

GetStream Environment

GetStream version:
2.2.2

Custom Activity Issue

Hi there!

I'm attempting to add a custom activity type, by subclassing Activity, but there seems to be inconsistencies between the guides and the repo.

The guides say that actor should be a string, and the example subclass in Custom Fields, takes in string as an actor, as seen by the super.init call. However the repo seems to force actor to be a User. This causes issues with our backend as we have our actors as strings, and not objects.

How can I specify the actor to be a String and not a User.

Thanks!

While fetching single activity without feed code, I can't reach own reactions and latest reactions.

What did you do?

I am trying to retrieve single activity with id but I can't reach latest reactions and own reactions. I ve tried to fetched with channel code but at some point I don't have that information. We should have parameter such as includeReactions for get method over FlatFeed. Here is my code piece to fetch single activity without channel code (there is no parameter to specify if should fetch reactions etc for current get method).

        Client.shared.get(typeOf: T.self, activityIds: [id]) { (result) in
            switch result {
            case .success(let response):
                success(response.results.first)
            case .failure(let error):
                failure?(error)
            }
        }

What did you expect to happen?

Expected to have reactions while fetching single activity without channel code.

What happened instead?

We couldn't access latest & own reactions while fetching single activity.

GetStream Environment

GetStream version: 2.2.3
Xcode version: 12.4
Swift version: 5.0
Platform(s) running GetStream: iOS
macOS version running Xcode: BigSur 11.0.1

Additional context

Subscribe to new updates

I have a project in that we have page called community when all user can post so I need to subscribe to get updates

let userFeed = Client.shared.flatFeed(feedSlug: "community", userId: community_id_here)

userFeed.subscribe(typeOf: GetStreamActivity.self, subscription: { result in
switch result {
case .success(let activities):
// Handle received activities
print("Received activities: (activities)")
case .failure(let error):
// Handle subscription error
print("Failed to subscribe: (error)")
}
})

        This never print  Received activities or Failed to subscribe
        
        Please help me

Basic get doesn't work

Adding custom activities in a feed causes a parsing error unless the entire feed contains the same activities

final class GossipActivity: EnrichedActivity<GetStream.User, String, DefaultReaction> {
    private enum CodingKeys: String, CodingKey {
        case user
    }
    
    var user: AvatarLead

    init(verb: Verb, object: String, user: AvatarLead, startDate: Date = Date()) {
        self.user = user
        super.init(actor: .init(id: user.id), verb: verb, object: object)
    }
    
    required init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        user = try container.decode(AvatarLead.self, forKey: .user)
        try super.init(from: decoder)
    }
    
    override public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(user, forKey: .user)
        try super.encode(to: encoder)
    }
}
self.userFeed?.get(typeOf: GossipActivity.self, completion: { result in
            switch result {
                case .success(let activiti):
                    self.gossip = activiti.results
                case .failure(let e):
                    print(e)
            }
        })

This is dangerous because if one activity does not confirm to GossipActivity then the entire feed disappears.

Error adding like reaction

            client.add(reactionTo: activity.id, kindOf: "like", completion: { (_) in
                completion()
            })

What did you do?

Add a 'Like' reaction to an activity

What did you expect to happen?

Add the like reaction

What happened instead?

Fails with error:

{"detail":"Errors for fields 'user_id'","status_code":400,"code":4,"exception":"InputException","exception_fields":{"user_id":["user_id is a required field"]},"duration":"0.17ms"}

GetStream Environment

GetStream version: 1.1.8
Xcode version: 10.2
Swift version: 4.2
Platform(s) running GetStream: iOS
macOS version running Xcode: Mojave 10.14.4

Additional context

Usage example for subscribing to feed for realtime updates? Any low level socket reference docs?

Looks like there may have been some drift, as signatures and return types have changed and the following snippet won't compile.

https://github.com/GetStream/stream-swift/wiki/Realtime-updates

Do you have any recent usage snippets? I've poked around the source but I might be missing something. Is it possible to just get these message payloads without needing to conform to an activity type? Also, are there any low level connection reference documentation (so I can avoid digging through the sdks) for real time? Since my scope is very narrow i'd prefer to establish these sockets myself in exchange for the users jwt token.

I'll dig into the sdks, but if you have any hints would be great. It might even make more sense for me to create a new channel between my own client/server socket and just push out those messages myself when I get them upstream from my firehose.

Unusable via SPM

What did you do?

I tried to add the package via Swift Package Manager, but I get the error described in #37

What did you expect to happen?

I expected it to work with Swift Package Manager

What happened instead?

It didn't work with Swift Package Manager

Expected to decode Dictionary<String, Any> but found a string/data instead.

What did you do?

while activity fetching

self.timelineFeed?.get(enrich: true, pagination: .limit(limit) + .offset(offset), ranking: nil, includeReactions: .all, completion: { feedsResults in do{ self.timelinePosts = try feedsResults.get().results } catch { } })

What did you expect to happen?

What happened instead?

getting
JSON decoding error: The data couldn’t be read because it isn’t in the correct format.. Data: 5901 bytes
▿ jsonDecode : 3 elements
- .0 : "The data couldn’t be read because it isn’t in the correct format."
▿ .1 : Optional
▿ some : DecodingError
▿ typeMismatch : 2 elements
- .0 : Swift.Dictionary<Swift.String, Any>
▿ .1 : Context
▿ codingPath : 3 elements
- 0 : CodingKeys(stringValue: "results", intValue: nil)
▿ 1 : _JSONKey(stringValue: "Index 0", intValue: 0)
- stringValue : "Index 0"
▿ intValue : Optional
- some : 0
- 2 : CodingKeys(stringValue: "actor", intValue: nil)
- debugDescription : "Expected to decode Dictionary<String, Any> but found a string/data instead."
- underlyingError : nil
▿ .2 : 5901 bytes
- count : 5901
▿ pointer : 0x00007ff0e1127200
- pointerValue : 140672544961024

GetStream Environment

GetStream version:2.2.1
Xcode version:11
Swift version:5
Platform(s) running GetStream:iOS
macOS version running Xcode:10.15

Additional context

the error happening inside
func parse<T: Decodable>(_ callbackQueue: DispatchQueue, _ completion: @escaping CompletionObjects<T>) { parse(block: { let moyaResponse = try get() var response = try JSONDecoder.default.decode(Response<T>.self, from: moyaResponse.data) if let next = response.next, case .none = next { response.next = nil } callbackQueue.async { completion(.success(response)) } }, catch: { error in callbackQueue.async { completion(.failure(error)) } }) }

"Package Resolution Failed" while using Swift Package Manager

What did you do?

Added the package using swift package manager

What did you expect to happen?

The package to be added

What happened instead?

There was an error while adding the package: "Package Resolution Failed"
Zrzut ekranu 2022-01-3 o 11 27 56

GetStream Environment

GetStream version: 2.2.2
Xcode version: 13.0
Swift version: 5
Platform(s) running GetStream: iOS
macOS version running Xcode: 12.0.1

Additional context

Reaction with extraData can't be added

What did you do?

Call

Client.shared.add(reactionTo: activityId, kindOf: "comment", extraData: Comment(text: "awesome post!"), userTypeOf: User.self) { result in /* ... */ }

as shown in docs

What did you expect to happen?

Work

What happened instead?

Compiler gives error Error: Extra argument 'extraData' in call

Additional context

Comment(text:) initializer needs to be made public for this to work!

Getting parsing error when trying to fetch a single activity

When I m trying to fetch a activity , parsing getting failed.
Below is the error :
GetStream.ClientError.jsonDecode("The data couldn’t be read because it isn’t in the correct format.", Optional(Swift.DecodingError.typeMismatch(Swift.Dictionary, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "results", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "actor", intValue: nil)], debugDescription: "Expected to decode Dictionary but found a string/data instead.", underlyingError: nil)))

Crash on AuthorizationMoyaPlugin.prepare

What did you do?

We have an app with several thousand sessions per day and using the GetStream sdk for an activity feed. We have seen that most of our crash reports (around 90% of them, a total of 0.1% of our total sessions are affected, with our current numbers is about 200 crashes/week) are coming from GetStream Moya plugin.
Here is the crash report:

Crashed: org.alamofire.session.rootQueue.requestQueue
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x000000098c54bc20
Crashed: org.alamofire.session.rootQueue.requestQueue
0  libobjc.A.dylib                0x3970 objc_retain + 16
1  libswiftCore.dylib             0x3db6fc swift_bridgeObjectRetain + 48
2  libswiftFoundation.dylib       0x2f4cc8 URLRequest.addValue(_:forHTTPHeaderField:) + 48
3  GetStream                      0x13ad0 AuthorizationMoyaPlugin.prepare(_:target:) + 180 (<compiler-generated>:180)
4  GetStream                      0x13b50 protocol witness for PluginType.prepare(_:target:) in conformance AuthorizationMoyaPlugin + 20 (<compiler-generated>:20)
5  Moya                           0x11554 closure #1 in MoyaProvider.interceptor(target:) + 169 (MoyaProvider+Internal.swift:169)
6  Moya                           0xbcec specialized MoyaRequestInterceptor.adapt(_:for:completion:) + 133 (Moya+Alamofire.swift:133)
7  Moya                           0xb894 protocol witness for RequestAdapter.adapt(_:for:completion:) in conformance MoyaRequestInterceptor + 28 (<compiler-generated>:28)
8  Alamofire                      0xb7388 specialized Session.performSetupOperations(for:convertible:shouldCreateTask:) + 1078 (Session.swift:1078)
9  Alamofire                      0xb61f4 closure #1 in closure #1 in Session.perform(_:) + 1015 (Session.swift:1015)
10 Alamofire                      0x3ea20 thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:28)
11 libdispatch.dylib              0x1e68 _dispatch_call_block_and_release + 32
12 libdispatch.dylib              0x3a2c _dispatch_client_callout + 20
13 libdispatch.dylib              0xb124 _dispatch_lane_serial_drain + 668
14 libdispatch.dylib              0xbcb4 _dispatch_lane_invoke + 444
15 libdispatch.dylib              0xb000 _dispatch_lane_serial_drain + 376
16 libdispatch.dylib              0xbcb4 _dispatch_lane_invoke + 444
17 libdispatch.dylib              0xb000 _dispatch_lane_serial_drain + 376
18 libdispatch.dylib              0xbc80 _dispatch_lane_invoke + 392
19 libdispatch.dylib              0x16500 _dispatch_workloop_worker_thread + 648
20 libsystem_pthread.dylib        0x10bc _pthread_wqthread + 288
21 libsystem_pthread.dylib        0xe5c start_wqthread + 8

I have tried using the tentative fix contained in cd5dffc but did not help either.

I am not sure what to do next, because it seems like there is some kind of race condition, maybe due to the memory management in the background thread.

Apart from that, in general third party SDKs should minimize dependencies to external libraries to slim them as much as possible, so I wonder why do you need Moya at all instead of implementing the calls yourselves.

What did you expect to happen?

No crash an no big dependencies like Moya or Alamofire included in the SDK

What happened instead?

Crash 0.1% of the sessions (90% of our total crashes)

GetStream Environment

GetStream version: 2.2.2 (and cd5dffc commit too)
Xcode version: 13.2.1 (others too)
Swift version: 5
Platform(s) running GetStream: iOS and Android
macOS version running Xcode: 12.3 (others too)

Additional context

  • Affecting all iOS versions in expected proportion compared to our userbase:

Screenshot 2022-05-27 at 15 57 34

  • Affecting to all iPhone devices in expected proportion compared to our userbase:

Screenshot 2022-05-27 at 15 58 46

  • I do not see any pattern on user behavior. Many happening after a fresh app start, but some exceptions exist too.

Cannot build with Carthage

What did you do?

Tried to integrate the framework using Carthage

What did you expect to happen?

The carthage update command to successfully finish.

What happened instead?

Received an error:

64453409-7c53c200-d0b6-11e9-9543-b75d193a1b63

Seems to be because a sub dependency added by stream-swift doesn't have a swift supported version specified.

GetStream cocoapod dependency issue

On our project we use both GetStream and StreamChat via CocoaPods. We can't update StreamChat to the latest version because both SDKs' uses different versions of Starscream and it creates dependency conflict.

This is the error log from cocoapod

[!] CocoaPods could not find compatible versions for pod "Starscream":
  In Podfile:
    GetStream (~> 2.2.3) was resolved to 2.2.3, which depends on
      GetStream/Faye (= 2.2.3) was resolved to 2.2.3, which depends on
        Faye was resolved to 1.1.3, which depends on
          Starscream (~> 3.0)

    StreamChat (~> 2.6.0) was resolved to 2.6.0, which depends on
      StreamChatCore (= 2.6.0) was resolved to 2.6.0, which depends on
        StreamChatClient (= 2.6.0) was resolved to 2.6.0, which depends on
          Starscream (~> 4.0)

gz#8856

The current user id is empty

Hi,

What did you do?

We integrated stream-swift using SPM, and our iOS app runs well using the tutorial test credentials (appKey, appId, token, user)

Now we are trying to generate the token on our server side:
"$client->users()->add('1068811', ['name' => 'Marc Team']);" (PHP)

On the iOS client side we initialize the Stream Client:
"Client.config = .init(apiKey: "xxxxxx", appId: "xxxxxx", logsEnabled: true)"

Using the token retrieved from the server we try the setup:
"Client.shared.setupUser(User(..), token: streamToken).."

What did you expect to happen?

"Client.shared.setupUser" should return "success"

What happened instead?

we get the error:
"Client.shared.create failed with : Client setup: The current user id is empty"

Debugging inside the GetStream package, seems like when retrieving the user_id from the token it comes as an Integer and it fails because it expects a String:

"
/// A user id from the Token.
public var userId: String? {
return payload?["user_id"] as? String // -> this returns nill
}
"

when, using a breakpoint on the previous line ^, and capturing this in the console:
"
payload?[“user_id”] as? Int // returns the correct user_id
"

GetStream Environment

**GetStream version: 2.2.3
**Xcode version: 12.2
**Swift version: 5
**Platform(s) running GetStream: iOS
**macOS version running Xcode: Catalina 10.15.7

Additional context

When requesting a user from the server side we get a correct user id as a String:
"
[
"created_at" => "2020-12-11T18:34:36.883063Z"
"updated_at" => "2020-12-11T18:34:36.883063Z"
"id" => "1068811"
"data" => array:1 [
"name" => "Marc Team"
]
"duration" => "3.97ms"
]
"

Thank you

gz#8026

The Stream Feed Client didn't setup properly. You are trying to use it before setup the API Key.

What did you do?

// Setup a shared Stream Client.
Client.config = .init(apiKey: "<#ApiKey#>", appId: "<#AppId#>")

// Setup a Stream user, when your user was logged in.
Client.shared.setupUser(token: token) { _ in
// Do all your requests from here. Reload feeds and etc.
}

What did you expect to happen?

The thing to actually work

What happened instead?

The Stream Feed Client didn't setup properly. You are trying to use it before setup the API Key.

GetStream Environment

GetStream version: pod 'GetStream', '2.2.2'
Xcode version: Xcode 12.3
Swift version: 5
Platform(s) running GetStream: iOS
macOS version running Xcode: Big Sur

Additional context

I think that your documentation is completely out of date, can't make this thing to work.

I also tried this:

// import GetStream
// Setup Stream client (server side)
let client = Client(apiKey: "YOUR_API_SECRET", appId: "APP_ID", token: "FEED_TOKEN")

You get:
'Client' initializer is inaccessible due to 'private' protection level

gz#8273

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.