version="1.0" encoding="UTF-8"? copy-paste Created with Sketch. copied! import React from 'react'; import { SafeAreaProvider } from 'react-native-safe-area-context'; import SafeAreaView from 'react-native-safe-area-view'; import { StreamApp } from 'expo-activity-feed'; const App = () => { return ( <SafeAreaProvider> <SafeAreaView style={{flex: 1}} forceInset={{ top: 'always' }}> <StreamApp apiKey="5rqsbgqvqphs" appId="40273" token="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiOTM0YWQ5NWYtZmFlZi00OGI4LWE5ZTYtMDhkMDZiNTk4ODgzIn0.HEhj4MJwbUY1a3snyI_eKgSn9uUz9mX27fagm5PnmT4" /> </SafeAreaView> </SafeAreaProvider> ); }; export default App;

Your application is now configured with the API credentials for the demo application. StreamApp is going to be the parent element for all other components and manages current user's session ( token ) and your Stream application API credentials ( apiKey and appId ).

Because this is a tutorial, we do not have a real signup flow and we will use a pre-generated user session token, on a real-world application, your authentication backend would generate such token at log-in / signup and hand it over to the mobile app.

This is how you would generate the token server side (no need to do this for this tutorial):

JS/Node

Python

Ruby

PHP // npm install getstream --save let stream = require('getstream'); let client = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET'); let userToken = client.createUserSessionToken(userId); # pip install stream-python import stream client = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET', location='us-east') user_token = client.create_user_token(user_id) # gem install "stream-ruby" # or add this to your Gemfile and then run bundler # gem "stream-ruby" require 'stream' client = Stream::Client.new('YOUR_API_KEY', 'API_KEY_SECRET', :location => 'us-east') user_token = client.create_user_session_token(userId) # composer require get-stream/stream $client = new GetStream\Stream\Client('YOUR_API_KEY', 'API_KEY_SECRET'); $userToken = client->createUserSessionToken($userId);

To preview the application, you will need to install the Expo app on your phone and connect to WiFi so that you are on the same network as your computer. If you have Android Studio or Xcode you can also preview the application using the built-in emulator.

version="1.0" encoding="UTF-8"? copy-paste Created with Sketch. copied! yarn start

This will start the React Native development server, you can leave it running, it will live reload your news feed application when you make code changes.