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

TypeError: null is not an object (evaluating 'react_native_1.NativeModules.RNSpotifyRemoteAuth.authorize') #206

Open
DrBuzzzz opened this issue Aug 4, 2022 · 2 comments

Comments

@DrBuzzzz
Copy link

DrBuzzzz commented Aug 4, 2022

Hello,
I tried to install and use this package as it seems to be perfect for my usecase. I did everything described in the docs and I also tried the manual linking steps for android but I still get this error. It's probably important to know that I use expo but a bare workflow. I saw this issue, but he used an expo managed workflow. My React Native version is 0.69.3. My code looks exactly the same as described in the docs:

import React, { useContext, useEffect } from "react";

import { Button, Text, View, StyleSheet } from "react-native";

import { ThemeContext } from "../context/context";
import { lightTheme, darkTheme } from "../styles/themes";

import {
  auth as SpotifyAuth,
  remote as SpotifyRemote,
  ApiScope,
} from "react-native-spotify-remote";

// Api Config object, replace with your own applications client id and urls
const spotifyConfig = {
  clientID: "0f080...",
  redirectURL: "exp://192.168.10.35:19000/--/callback",
  tokenRefreshURL: "SPOTIFY_TOKEN_REFRESH_URL",
  tokenSwapURL: "SPOTIFY_TOKEN_SWAP_URL",
  scopes: [ApiScope.AppRemoteControlScope, ApiScope.UserFollowReadScope],
};

export default function MusicScreen({ navigation }) {
  const { getTheme } = useContext(ThemeContext);
  const theme = getTheme();

  async function playEpicSong() {
    try {
      const session = await SpotifyAuth.authorize(spotifyConfig);
      await SpotifyRemote.connect(session.accessToken);
      await SpotifyRemote.playUri("spotify:track:6IA8E2Q5ttcpbuahIejO74");
      await SpotifyRemote.seek(58000);
    } catch (err) {
      console.error("Couldn't authorize with or connect to Spotify", err);
    }
  }

  return (
    <View
      style={[
        styles.container,
        theme === "light" ? lightTheme.container : darkTheme.container,
      ]}
    >
      <Button title="Play Epic Song" onPress={() => playEpicSong()} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

I hope you can help me!

@JoeToeniskoetter
Copy link

Did you run pod install in your iOS directory?

@DrBuzzzz
Copy link
Author

Oh sorry, I forgot to mention that I'm building for Android.

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

2 participants