/** * NymOS API 1.9.21 * * The contents of this file are subject to the NymOS License, version 1.0. * It is forbidden the use of the codes included on this file, even partially, * for third parties, such as its copy, without express authorization of the * intelectual property and commercial rights owners. A copy of the license * may be obtained at http://nymos.io/source-license. The intelectual * property and comercial rights of this file and codes belong to NymOS S.A. * * Copyright (c) 2017. All rights reserved. * */ /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import { CustomHttpUrlEncodingCodec } from '../internal/encoder'; import { Problem } from '../models/problem.model'; @Injectable() export class NotificationsService { constructor(protected httpClient: HttpClient) { } /** * Update the push notification token. * [Firebase Cloud Messaging (FCM)](https://firebase.google.com/docs/cloud-messaging) is a cross-platform messaging solution that let `NymOS` reliably deliver messages at no cost. On initial startup, the FCM SDK ([Android](https://firebase.google.com/docs/cloud-messaging/android/client), [IOS](https://firebase.google.com/docs/cloud-messaging/ios/client), [Web](https://firebase.google.com/docs/cloud-messaging/js/client)) generates a registration token. Please note that tokens may change when: - The app deletes Instance ID - The app is restored on a new device - The user uninstalls/reinstall the app - The user clears app data. This `endpoint` must be called whenever a new token is generated. * @param registrationToken * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public updateFirebaseToken(registrationToken: string): Observable { if (registrationToken === null || registrationToken === undefined) { throw new Error('Required parameter registrationToken was null or undefined when calling updateFirebaseToken.'); } let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); if (registrationToken !== undefined) { queryParameters = queryParameters.set('registration_token', registrationToken); } let headers = new HttpHeaders(); return this.httpClient.put(`https://notifications-dot-nymos-dev.appspot.com/v1/notifications/push:updateFcmToken`, { params: queryParameters, headers: headers, } ); } }