[英]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.