react-native interface to login to instagram (iOS)
npm install react-native-instagram-oauth@latest --save
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj
➜ and addRCTLinking.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRCTLinking.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Click
RCTLinking.xcodeproj
in the project navigator and go theBuild Settings
tab. Make sure 'All' is toggled on (instead of 'Basic'). Look forHeader Search Paths
and make sure it contains both$(SRCROOT)/../../react-native/React
and$(SRCROOT)/../../../React
- mark both asrecursive
. - Run your project (
Cmd+R
) - Register a new client on instagram itself => https://instagram.com/developer/clients/manage/
var RNInstagramOAuth = require('react-native-instagram-oauth');
var instagram: {
client_id: '<YOUR CLIENT ID>',
redirect_url: '<YOUR REDIRECT URL>' // e.g.: 'test://init'
};
function getInstagramByMyself (access_token) {
fetch('https://api.instagram.com/v1/users/self/?access_token='+access_token)
.then((response) => response.json()).then((responseData) => {
console.log(responseData);
});
}
RNInstagramOAuth(instagram.client_id, instagram.redirect_url, (err, access_token) => {
if (err) { console.log(err) }
if (access_token !== undefined) {
console.log(access_token);
getInstagramByMyself(access_token);
}
});
Can be easily used together with react-native-instagram-share (https://github.com/watzak/react-native-instagram-share)