Search code examples
javascriptiosreact-nativeoauthtwitter-oauth

react-native-twitter Oath URLSearchParams Error on IOS


Currently implementing Twitter's API on an IOS App RN 0.61.1 and using the react-native-twitter, library but am running into problems following the example on github.

Clicking the auth button returns an error. The expected result should be a browser page pop up, which allows user to grant access to twitter through the app.

I have found similar issues with react-native and OAuth but none of the suggestions work in my case.

In Debugger:ERROR

setUpDeveloperTools.js:73 Possible Unhandled Promise Rejection (id: 0): Error: not implemented Error: not implemented at URLSearchParams.get (http://localhost:8081/index.delta?platform=ios&dev=true&minify=false&revisionId=306550084ac919f0:40695:15...

Any suggestions will be appreciated.


Solution

  • Not sure if this is allowed but I edited the module itself since it didn't work in index.js.

    Located the auth() function through the debugger and changed the URLSearchParams import.

    //in ./node_modules/react-native-twitter/src/oauth/auth.js 
    
    //from
    import URLSearchParams from 'url-search-params';
    
    
    //to
    import {URLSearchParams } from 'whatwg-url';
    import { Buffer } from 'buffer';
    global.Buffer = Buffer;
    

    Suggested here.