I'm trying to use the client side functionality of getstream.io (specifically the feed pull and live updates) to build a stream on a native app built with react-native. When I try to initialize a client in the javascript code using a token passed from my server, I get the error:
[Error: Missing app id, which is needed to subscribe, use var client = stream.connect(key, secret, appId);]
However, when I add the secret and appId (for testing purposes, I would be very wary of deploying like this) I get the error:
[Error: You are publicly sharing your private key. Dont use the private key while in the browser.]
Is there a way to get a client version running using Expo (the Create React Native App default) without ejecting from Create React Native App?
For security reasons you can't generate tokens client side with the JS client as that would require sharing your Api Key Secret.
The way to go is for your backend to create feed specific tokens and to send them to your client-side application.
Server side (Ruby):
require 'stream'
client = Stream::Client.new('YOUR_API_KEY', 'API_KEY_SECRET')
feed = client.feed('user', '1')
token = feed.token
Client side (JS):
client = stream.connect('YOUR_API_KEY', null, 'SITE_ID');
user1 = client.feed('user', '1', token);