Add device token management
This commit is contained in:
parent
907fe6eab6
commit
113a100ba1
5 changed files with 43 additions and 14 deletions
|
@ -8,6 +8,14 @@
|
|||
</div>
|
||||
<form class="form-horizontal" [formGroup]="sendMessageForm" (ngSubmit)="onSubmit()">
|
||||
<div class="card-block">
|
||||
<div class="form-group row">
|
||||
<label class="col-md-3 form-control-label" for="select-input"><strong>Select Recipients</strong></label>
|
||||
<select required class="form-control" type="text" formControlName="devicetokens" multiple>
|
||||
<option *ngFor="let deviceToken of deviceTokenIdList" [ngValue]="deviceTokenList[deviceToken].token">
|
||||
{{ deviceTokenList[deviceToken].user }} <{{deviceTokenList[deviceToken].token}}>
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-md-3 form-control-label" for="text-input"><strong>Enter Message Here</strong></label>
|
||||
<div class="col-md-9">
|
||||
|
|
|
@ -13,10 +13,24 @@ export class SendPushNotificationComponent implements OnInit {
|
|||
noEmail = false;
|
||||
sendMessageFormStatus: any;
|
||||
sendMessageFormStatusError = 'Error received, please try again.';
|
||||
deviceTokenList: any;
|
||||
deviceTokenIdList: any;
|
||||
|
||||
constructor(private api: ApiService) {
|
||||
this.api.getDeviceTokens().subscribe(
|
||||
result => {
|
||||
console.log(result);
|
||||
this.deviceTokenList = result.tokens;
|
||||
this.deviceTokenIdList = Object.keys(this.deviceTokenList);
|
||||
},
|
||||
error => {
|
||||
console.log("Couldn't get device token");
|
||||
console.log(error._body);
|
||||
}
|
||||
);
|
||||
this.sendMessageForm = new FormGroup({
|
||||
messagetext: new FormControl('', Validators.required),
|
||||
devicetokens: new FormControl('', Validators.required),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue