Save device token on middleware

This commit is contained in:
Eudes Inácio
2021-02-01 13:31:33 +01:00
parent 14cd929715
commit 6e8c55ab76
4 changed files with 82 additions and 13 deletions
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { NotificationsService } from './notifications.service';
describe('NotificationsService', () => {
let service: NotificationsService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(NotificationsService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+30
View File
@@ -0,0 +1,30 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { Token } from '../models/token.model';
@Injectable({
providedIn: 'root'
})
export class NotificationsService {
constructor(private http: HttpClient,) { }
getTokenByUserIdAndId(user, userID) {
const geturl = environment.apiURL + 'notifications/user/' + userID;
return this.http.get<Token[]>(`${geturl}`);
}
postToken(userId, token) {
const geturl = environment.apiURL + 'notifications/token';
let data = {
UserId: userId,
TokenId: token,
Status: 1,
Service: 2
}
return this.http.post<Token[]>(`${geturl}`,data);
}
}