我使用React Native和Ruby on Rails后端开发应用程序。
以下流程正在运作:
问题:
console.log("NOT BEING HIT")
未被点击。这意味着没有事件。我做错了什么?
export function instagramOauth (callback) {
var state = Math.random() + ''
Linking.addEventListener('url', handleUrl)
function handleUrl (event) {
console.log("NOT BEING HIT")
var [, query_string] = event.url.match(/\#(.*)/)
var query = shittyQs(query_string)
if (state === query.state) {
callback(null, query.access_token, query.uid)
} else {
callback(new Error('Oauth2 security error'))
}
Linking.removeEventListener('url', handleUrl)
}
Linking.openURL([
'http://localhost:3000/mobile/instagram_authentication'
].join(''))
}
如果你想看到终点。
def token
@response = Instagram.get_access_token(params[:code], :redirect_uri => mobile_token_url)
instagram_user = InstagramUserCreator.new(user_params)
if instagram_user.find_or_create
#TODO: Redirect with token in url
redirect_to 'taddarmobileapp://'
else
#TODO
redirect_to 'taddarmobileapp://'
end
end