Apple login module for Angular 13.
npm install ngx-apple-loginThis library was generated with Angular CLI version 13.3.0.
| Library Version | Angular Version |
| --------------- | --------------- |
| >=1.0.6 | 13 |
``sh`
npm i ngx-apple-login
In your AppModule, import the NgxAppleLoginModule
`javascript
import { NgxAppleLoginModule } from 'ngx-apple-login';
@NgModule({
declarations: [
...
],
imports: [
...
NgxAppleLoginModule
],
})
export class AppModule { }
`
In Template use
`html`
In Component use
`javascript
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
`javascript
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
})
}
}
``
| 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 |
| 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 |