ngx-apple-login
v1.0.6
Published
Apple login module for Angular 13.
Downloads
62
Maintainers
Readme
Angular Apple Login
This library was generated with Angular CLI version 13.3.0.
Compatibility Matrix
| Library Version | Angular Version | | --------------- | --------------- | | >=1.0.6 | 13 |
Getting started
Install via npm
npm i ngx-apple-login
Import the module
In your AppModule
, import the NgxAppleLoginModule
import { NgxAppleLoginModule } from 'ngx-apple-login';
@NgModule({
declarations: [
...
],
imports: [
...
NgxAppleLoginModule
],
})
export class AppModule { }
Usage
In Template use
<ngx-apple-login [noDefaultStyle]="true" [uiType]="'dark'" [buttonLabel]="'Signup'" [config]="config" (onSuccess)="handleOnSuccess($event)" (onError)="handleError($event)"></ngx-apple-login>
In Component use
import { AppleAuthOptions } from 'ngx-apple-login/entities/apple-auth-options'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
config: AppleAuthOptions = {
clientId: 'com.example.com',
scope: 'email name',
usePopup: true,
redirectURI: '/'
}
handleOnSuccess(event: any){
// Success Response
}
handleError(event: any){
// Error Response
}
}
Using Service Only
import { NgxAppleLoginService } from 'ngx-apple-login';
import { AppleAuthOptions } from 'ngx-apple-login/entities/apple-auth-options'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
config: AppleAuthOptions = {
clientId: 'com.example.com',
scope: 'email name',
usePopup: true,
redirectURI: '/'
}
constructor(private ngxAppleLoginService: NgxAppleLoginService){}
signIn(){
this.ngxAppleLoginService.signIn(this.config).then((res) => {
// Success Response
}).catch((error) => {
// Error Response
})
}
}
API
| Input | Type | Default | Required | Description | | ---------------- | ---------------- | ------------------- | -------- | ------------------------------------ | | [noDefaultStyle] | boolean | false | no | prevents rendering of default styles | | [uiType] | dark | light | dark | no | UT type | | [buttonLabel] | string | Continue with Apple | no | Button text | | [config] | AppleAuthOptions | - | yes | Apple config | | [class] | string | - | no | External class | | (onSuccess) | EventEmitter | - | no | Success callback | | (onError) | EventEmitter | - | no | Error callback |
AppleAuthOptions
| Key | Type | Required | Description | | ----------- | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | clientId | string | yes | Client ID - eg: 'com.example.com' | | scope | string | yes | Requested scopes, seperated by spaces - eg: 'email name' | | redirectURI | string | no | Apple's redirectURI - must be one of the URIs you added to the serviceID - the undocumented trick in apple docs is that you should call auth from a page that is listed as a redirectURI, localhost fails | | usePopup | boolean | yes | Uses popup auth instead of redirection | | state | string | no | State string that is returned with the apple response | | nonce | string | no | Nonce |