diff --git a/README.md b/README.md index 1751427..6b19af8 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Get the client's authentication tokens via [3-legged authorization](https://dev. * `forSignIn` If `true`, [oauth/authenticate](https://dev.twitter.com/oauth/reference/get/oauth/authenticate) endpoint is used instead of [oauth/authorize](https://dev.twitter.com/oauth/reference/get/oauth/authorize) (Default: `false`) * `forceLogin` Specify `force_login` (See [Twitter docs](https://dev.twitter.com/oauth/reference/get/oauth/authorize#parameters).) (Default: `false`) * `screenName` Specify `screen_name` (See [Twitter docs](https://dev.twitter.com/oauth/reference/get/oauth/authorize#parameters).) +* `openUrl` specify an alternative method of opening twitter auth (e.g. a web modal) * Returns: `Promise` of `{accessToken, accessTokenSecret, id, name}` * `accessToken` Access token diff --git a/src/oauth/auth.js b/src/oauth/auth.js index 403d6dd..ba07c30 100644 --- a/src/oauth/auth.js +++ b/src/oauth/auth.js @@ -1,4 +1,4 @@ -import {Linking} from 'react-native'; +import {Linking,Modal} from 'react-native'; import URLSearchParams from 'url-search-params'; @@ -63,6 +63,7 @@ export default async function auth( tokens, callbackUrl, {accessType, forSignIn = false, forceLogin = false, screenName = ''} = {}, + openUrl ) { const usePin = typeof callbackUrl.then === 'function'; const {requestToken, requestTokenSecret} = await getRequestToken( @@ -70,9 +71,10 @@ export default async function auth( usePin ? 'oob' : callbackUrl, accessType, ); - Linking.openURL(`https://api.twitter.com/oauth/${forSignIn ? 'authenticate' : 'authorize'}?${ - query({oauth_token: requestToken, force_login: forceLogin, screen_name: screenName}) - }`); + const url = `https://api.twitter.com/oauth/${forSignIn ? 'authenticate' : 'authorize'}?${ + query({oauth_token: requestToken, force_login: forceLogin, screen_name: screenName}) + }`; + openUrl ? openUrl(url):Linking.openURL(url); return getAccessToken( {...tokens, requestToken, requestTokenSecret}, await ( diff --git a/src/stream/index.js b/src/stream/index.js new file mode 100644 index 0000000..9912ecd --- /dev/null +++ b/src/stream/index.js @@ -0,0 +1,3 @@ +export default function stream() { + console.error(new Error('Streaming APIs are not supported on iOS.')); +}