-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (30 loc) · 928 Bytes
/
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
import Meteor from '@meteorrn/core';
import appleAuth from '@invertase/react-native-apple-authentication';
Meteor.loginWithApple = async function(callback) {
try {
const appleAuthRequestResponse = await appleAuth.performRequest({
requestedOperation: appleAuth.Operation.LOGIN,
requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME]
});
if (!appleAuthRequestResponse.authorizationCode) {
typeof callback == 'function' && callback('Apple Sign-In failed');
return;
}
Meteor._startLoggingIn();
Meteor.call(
'login',
{
methodName: 'native-apple',
code: appleAuthRequestResponse.authorizationCode,
...appleAuthRequestResponse
},
(error, response) => {
Meteor._endLoggingIn();
Meteor._handleLoginCallback(error, response);
typeof callback == 'function' && callback(error);
}
);
} catch (error) {
typeof callback == 'function' && callback(error);
}
};