简体   繁体   English

初始化 react-native-twitter-signin 时出现异常

[英]Exception when initializing react-native-twitter-signin

Ive been stuck on this for about 3 days now.我已经坚持了大约 3 天了。 I followed the instructions exactly like the docs - link here .我完全按照文档 -链接here的说明进行操作。 I have Added the callback url and all the other solutions on the internet.我在互联网上添加了回调 url 和所有其他解决方案。 This error is on Android but ios doesn't do anything when i click the button.这个错误是在 Android 上,但当我点击按钮时 ios 没有做任何事情。 Also shows no errors or warning when debugging.调试时也不显示错误或警告。 Im using the react-native-twitter-signin package.我使用 react-native-twitter-signin 包。 Please help.请帮忙。 c C

I found the solution thanks to Rahul Mishra above for providing his code.感谢上面的 Rahul Mishra 提供了他的代码,我找到了解决方案。 I made aa mistake of calling RNTwitterSignIn.init(Constants.TWITTER_COMSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET inside an async function. This worked for android but for ios nothing happened. But after i changed my code with his this worked and made me realise my mistake. Thanks again我犯了一个错误RNTwitterSignIn.init(Constants.TWITTER_COMSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET在异步函数中调用RNTwitterSignIn.init(Constants.TWITTER_COMSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET 。这对 android 有效,但对 ios 没有任何反应。但是在我用他的代码更改了代码之后,这使我意识到了我的错误。谢谢再次

Here is my full code for react-native-twitter-signin which is working on iOS and android both: Top of the class I called below code:这是我的 react-native-twitter-signin 的完整代码,它适用于 iOS 和 android:我在下面的代码中调用的类的顶部:

const { RNTwitterSignIn } = NativeModules
const Constants = {
  //Dev Parse keys
  TWITTER_COMSUMER_KEY: "************************",
  TWITTER_CONSUMER_SECRET: "********************************************************"
}

This is my view file button:这是我的查看文件按钮:

<TouchableOpacity onPress={() => this.twitterSignIn()}>
            <Image style={styles.socialBtn} source={require('../images/twitter.png')}/>
          </TouchableOpacity>

I am calling twitterSignIn function here:我在这里调用 twitterSignIn 函数:

twitterSignIn = () => {
  const fcmSocialToken = this.state.tokenFcm;
  RNTwitterSignIn.init(Constants.TWITTER_COMSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET)
  RNTwitterSignIn.logIn()
    .then(loginData => {
      const { authToken, authTokenSecret } = loginData
      if (authToken && authTokenSecret) {
        // You can use this data here and move next

      }
    })
    .catch(error => {
      console.log(error)
    }
  )
}

For iOS you need to update info.plist:对于 iOS,您需要更新 info.plist:

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>twitterkit-YCZNs*********</string>
                <string>fb**********</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>com.googleusercontent.apps.************</string>
            </array>
        </dict>
    </array>

Please let me know if any issue.如果有任何问题,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 仅 iOS 中 react-native-twitter-signin 中的 Twitter 登录错误 - Twitter signin error in react-native-twitter-signin in iOS only email 无法获取 react-native-twitter-signin 库中的错误 - email COULD NOT FETCH error in react-native-twitter-signin library react-native-twitter-signin:ios架构x86_64的未定义符号,编辑:尝试在没有有效的twitter kit url方案的情况下登录 - React-native-twitter-signin: ios Undefined symbols for architecture x86_64,Edit: attempt made to log in without a valid twitter kit url scheme 响应本机Twitter登录版本发布问题 - React native Twitter Signin release build issue 当 iOS 登录模式打开时出现异常“评估 textInputRef.isFocuded”,在应用程序购买中反应本机 - Exception "evaluating textInputRef.isFocuded" when iOS SignIn modal is open, react native in app purchases 当我将构建发布 apk 时,React 本机 Google 登录失败 - React native Google Signin Fail When i will build release apk 放大反应原生自定义登录 - Amplify react native custom SignIn React Native没有初始化ReactCoundownClock - React native not initializing ReactCoundownClock 初始化 react-native 项目时无法安装 cocoapods - failure to install cocoapods when initializing a react-native project 无法解析模块。/SignIn In React Native 应用程序 - Unable to resolve module ./SignIn In React Native app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM