npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-vk-auth

v1.0.5

Published

React Native plugin for VK SDK Authorization

Downloads

10

Readme

React Native VK authorization wrapper

Installation

yarn add rn-vk-auth

or

npm install rn-vk-auth --save

Then you should configure native parts:

Android

  1. Edit android/settings.gradle

    ...
    include ':rn-vk-auth'
    project(':rn-vk-auth').projectDir = new File(settingsDir, '../node_modules/rn-vk-auth/android')
    ...
  2. Edit android/app/build.gradle

    ...
    
    dependencies {
        ...
        compile project(':rn-vk-auth')
    }
  3. Edit android/app/src/main/java/<...>/MainApplication.java

    ...
    
    import com.mastereugene.vkauth.VKAuthPackage; //<---- import package
    
    public class MainApplication extends Application implements ReactApplication {
    ...
      @Override
      protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            ...
            new VKAuthPackage()//<---- Add package
          );
      }
    ...
    }
  4. In your AndroidManifest.xml, add following line inside <application> element:

    <activity android:name="com.vk.sdk.VKServiceActivity" android:label="ServiceActivity" android:theme="@style/VK.Transparent" />
  5. Add VK Application ID to resources (main/res/values/strings.xml) so the module will initialize with it at startup:

    <integer name="com_vk_sdk_AppId">VK_APP_ID</integer>

    (In this example, VK_APP_ID should be replaced with your real VK App ID you've got from VK manage panel)

iOS

  1. Add rn-vk-auth to your XCode project. To do so, go to node_modules/rn-vk-auth/ios directory inside your project and drag VKAuthorization.xcodeproj into your XCode project

    Then add library libRNVkontakteLogin.a to Linked Frameworks and Libraries section.

  2. Add VKSdkFramework.framework to embedded binaries. This can be done in Embedded binaries section of General Tab of your project in XCode.

  3. Add following fragment to your info.plist:

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>vk</string>
        <string>vkauthorize</string>
    </array>
  4. To use authorization via VK App you need to setup a url-schema of your application. Open your application settings then select the Info tab. In the URL Types section click the plus sign. Enter vk+APP_ID to the Identifier and URL Schemes fields.

    Alternatively, you can add following to your info.plist:
    
    ```xml
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string>vk1111111</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>vk1111111</string>
            </array>
        </dict>
    </array>
    ```
    
    Here vk1111111 is your real VK App ID you've got from VK App manage panel
  5. In your AppDelegate.m, you need to import VK SDK:

    #import <VKSdkFramework/VKSdkFramework.h>

    and then add following code (both methods are required):

    //iOS 9 workflow
    - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
       [VKSdk processOpenURL:url fromApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
       return YES;
    }
    
    //iOS 8 and lower
    -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
    {
       [VKSdk processOpenURL:url fromApplication:sourceApplication];
       return YES;
    }
  6. (Optional) You can add your VK Application ID to info.plist so the module will initialize with it at startup:

    <key>VK_APP_ID</key>
    <integer>1111111</integer>

    If you do so, you won't need to call VKLogin.initialize(vkAppId) from your JS code.

The last step is to run pod install:

cd ios && pod install

Usage

Import module in your JS code

import VKAuth from 'rn-vk-auth';

Initialize VK with your APP ID once somewhere during your app startup(only iOS):

componentDidMount() {
  VKAuth.initialize(1111111);
}

Check if user is logged in, perform login and logout:

const isLoggedIn = await VKAuth.isLoggedIn();
const auth = await VKAuth.login(['friends', 'photos', 'email']);
console.log(auth.access_token);
await VKAuth.logout();