Ioni c 5 Конденсатор: Pu sh Уведомление зарегистрировать UserGroup для firebase сервера / консоли? - PullRequest
0 голосов
/ 02 марта 2020

Я сделал уведомления pu sh в соответствии с инструкциями конденсатора. Ниже приведен код для этого.

Но как я могу указать устройство для группы пользователей в firebase, чтобы устройство было назначено группе пользователей, и поэтому я могу выбирать между группами пользователей при размещении уведомления pu sh? Как можно использовать этот подход для назначения устройства группе пользователей в firebase?

import { Component, OnInit } from '@angular/core';

import {
  Plugins,
  PushNotification,
  PushNotificationToken,
  PushNotificationActionPerformed } from '@capacitor/core';

const { PushNotifications } = Plugins;

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})

export class HomePage implements OnInit {

  ngOnInit() {
    console.log('Initializing HomePage');

    PushNotifications.register();

    PushNotifications.addListener('registration', 
      (token: PushNotificationToken) => {
        alert('Push registration success, token: ' + token.value);
      }
    );

    PushNotifications.addListener('registrationError', 
      (error: any) => {
        alert('Error on registration: ' + JSON.stringify(error));
      }
    );

    PushNotifications.addListener('pushNotificationReceived', 
      (notification: PushNotification) => {
        alert('Push received: ' + JSON.stringify(notification));
      }
    );

    PushNotifications.addListener('pushNotificationActionPerformed', 
      (notification: PushNotificationActionPerformed) => {
        alert('Push action performed: ' + JSON.stringify(notification));
      }
    );
}

...