forked from doochik/react-native-vksdk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
49 lines (44 loc) · 1.39 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';
var VkSdkLoginManager = require('react-native').NativeModules.VkSdkLoginManager;
module.exports = {
/**
* Starts authorization process to retrieve unlimited token.
* If VKapp is available in system, it will opens and requests access from user.
* Otherwise Mobile Safari will be opened for access request.
* @returns {Promise}
*/
authorize: function() {
return new Promise(function(resolve, reject) {
VkSdkLoginManager.authorize(function(error, result) {
if (error) {
reject(error);
} else {
resolve(result);
}
});
});
},
/**
* Forces logout using OAuth (with VKAuthorizeController). Removes all cookies for *.vk.com.
* Has no effect for logout in VK app.
*/
logout: function() {
VkSdkLoginManager.logout();
},
/**
* @param {string} methodName
* @param {Object} [params]
* @returns {Promise}
*/
callMethod: function(methodName, params) {
return new Promise(function(resolve, reject) {
VkSdkLoginManager.callMethodWithParams(methodName, params || {}, function(error, result) {
if (error) {
reject(error);
} else {
resolve(result);
}
});
});
}
};