npm i --save nativescript-vkontakte
- 版本:0.1.7
- GitHub: https://github.com/rufrozen/nativescript-vkontakte
- NPM: https://npmjs.net.cn/package/nativescript-vkontakte
- 下载
- 昨天: 0
- 上周: 0
- 上个月: 0
nativecript-vkontakte
适用于 Android 和 iOS 的 VKontakte NativeScript 模块
安装 npm 包
tns plugin add nativescript-vkontakte
设置
Android
在应用的 onCreate 中初始化(扩展应用文档)
var vk = require("nativescript-vkontakte");
...
onCreate: function()
{
superProto.onCreate.call(this);
// Enter custom initialization code here
var context = this.getApplicationContext();
vk.initialize(context);
},
在 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());
});
将 AppID 添加到 strings.xml
<integer name="com_vk_sdk_AppId">YOUR_APP_ID</integer>
iOS
将 AppID 添加到 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>