Cordova plugin to implement Signin With Apple
.
The function logs in and verifies.
cordova >= 7.1.0
cordova-ios >= 4.5.0
xcode >= 11
example)using swift5
config.xml
<platform name="ios">
<preference name="UseSwiftLanguageVersion" value="5" />
</platform>
https://github.com/akofman/cordova-plugin-add-swift-support
cordova plugin add cordova-signin-with-apple-plugin
- iOS (>=13.0)
ionic
angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
window.signinWithApple.validCredential({
userID: result.userIdentifier
},function() {
// success
}, function(err) {
// failure
/*
{
code: -3,
description: "The operation couldn’t be completed. (com.apple.AuthenticationServices.AuthorizationError error 1000.)"
}
*/
});
});
})
.controller("SigninCtrl", function($scope) {
$scope.onSignin = function() {
// signin...
window.signinWithApple.auth({
scopes: "fullName, email"
}, function(result) {
/*
success
{
email: "[email protected]",
userIdentifier: "xxxxx.yyyyy.zzzzz...",
givenName: "xxxxx",
familyName: "xxxxx"
}
*/
}, function(err) {
/*
failure
{
code: -3,
description: "description: "The operation couldn’t be completed. (com.apple.AuthenticationServices.AuthorizationError error 1001.)"
}
*/
});
}
});
error callback returns an error of the form
{
code: -1: Incorrect iOS version(< 13), -2:Invalid parameter, -3: authorization failed
description: Error message
}