olucurious/PyFCM

How to get registration_id

mahiuddin-dev opened this issue · 2 comments

How to get registration_id

I had to get it within my Ionic/Angular/Capacitor app and send to my web API. Here's the relevant code:

import { HttpClient, HttpParams } from '@angular/common/http';
import {
  ActionPerformed,
  PushNotifications,
  PushNotificationSchema,
  Token,
} from '@capacitor/push-notifications';


PushNotifications.addListener('registration', (token: Token) => {
      console.debug('notifications token: ', JSON.stringify(token.value));
      if (!token) {
        throw new Error('Token empty');
      }
      this.saveToken(token);
}

private saveToken(token: Token): void {
    const params = new HttpParams().set(
      'value',
      btoa(JSON.stringify(token.value))
    );
    // I should change this to an httpClient.post(), .get() does work but it's not as clear what's happening
    this.httpClient.get('notification_tokens', { params })

i've researched a HUGE amount of sites in regards to how to get the registration token using python. I can't for the life of me find out how to do it. Have i missed that vital part in the documentation or something ?

anyone got some tips please on how to get the token using python / kivy please ? in simple terms would be appreciated as ive already spent 12 hours researching it and my brain is going mushy hahah , cheers