This module is a wrapper around native VK SDKs for Android and iOS.
It allows to log in to VK and obtain access token, which you can later use to make VK API calls.
- Precompile all files, so module can be installed from git repo (no postinstall script)
- Remove all linking scripts (users supposed to make it by hands, sorry... I need control on my sources)
- Cleanup codebase
- Remote images can be shared
Follow Vkontakte iOS SDK documentation.
- Prepare for Using VK SDK
- Setup URL-schema of Your Application
- Add LSApplicationQueriesSchemes to Info.plist so SDK will allow to talk with Vkontakte application
<key>LSApplicationQueriesSchemes</key>
<array>
<string>vk</string>
<string>vk-share</string>
<string>vkauthorize</string>
</array>
- Implement
application:openURL:options:inAppDelegate.m
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
BOOL ret = [VKSdk processOpenURL:url fromApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
return ret;
}
(TODO)
- Add this module to your js dependencies and istall it (
npm install -P @vovkasm/react-native-vkontakte-login) - (iOS) Add it to
Podfile:
pod 'react-native-vkontakte-login', :path => '../node_modules/@vovkasm/react-native-vkontakte-login'Run pod install
Sorry, I don't support other linking methods for now. I'm using RN on iOS only with CocoaPods, it simplifies build infrastructure and reduces number of bugs.
Also VKLogin have initialize method, I recommend do it authomatically (you have to modify Info.plist anyway). So place your app id to Info.plist:
<key>VK_APP_ID</key>
<integer>6658972</integer>
In this case you should not call initialize from JS.
Import module in your JS code
import VKLogin from 'react-native-vkontakte-login'Initialize VK with your APP ID once somewhere during your app startup:
componentDidMount() {
VKLogin.initialize(5514471);
}Check if user is logged in, perform login and logout:
const isLoggedIn = await VKLogin.isLoggedIn()
const auth = await VKLogin.login(['friends', 'photos', 'email'])
console.log(auth.access_token)
await VKLogin.logout()The module also provides share method:
const shareResponse = await VKLogin.share({
linkText: 'Cool site',
linkUrl: 'https://news.ycombinator.com/',
description: 'Check out this cool site!',
image: TEST_IMAGE,
})Check API Reference for more information.
Example project where this module is installed via Cocoapods: here Example project where this module is installed by modifying XCode project: here
Feel free to submit pull requests