nativescript-vkontakte
by rufrozen | v0.1.7
A VKontakte NativeScript module for Android and iOS
npm i --save nativescript-vkontakte

nativescript-vkontakte

A VKontakte NativeScript module for Android and iOS

install npm package

tns plugin add nativescript-vkontakte

Setup

Android

Initialize inside application onCreate (extend application doc)

var vk = require("nativescript-vkontakte");
...
onCreate: function()
{
superProto.onCreate.call(this);
// Enter custom initialization code here
var context = this.getApplicationContext();
vk.initialize(context);
},

Subscribe on activityResult

import * as application from "application";
import * as vk from "nativescript-vkontakte";

application.android.on('activityResult', data =>
{
let res = vk.onActivityResult(data.requestCode, data.resultCode, data.intent, token =>
{
console.log('VKCallback userId: ' + token.userId);
}, error =>
{
console.log('VKCallback error: ' + error.errorCode);
});
console.log('onActivityResult ' + res.toString());
});

Add AppID to strings.xml

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

iOS

Add AppID to Info.plist

<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>vkYOUR_APP_ID</string>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>vk</string>
<string>vk-share</string>
<string>vkauthorize</string>
</array>

Links: