Ionic PhoneGap-плагин-толчок не работает для веб - PullRequest
0 голосов
/ 08 декабря 2018

Как добавить мой ключ веб-API для Google Firebase? в моем ионном приложении для веб-платформы **

объяснение -: 1. Я работаю над ионным приложением, где я нахожусьпытаясь интегрировать его с PUSH (https://ionicframework.com/docs/native/push/) с использованием firebase

Я выполнил все шаги, начиная с https://ionicframework.com/docs/native/push/

Проблема : push-уведомление не работает для веб-платформы для ios иAndroid это работает.

Я добавляю код ниже:

ts файл -:

    import { Push, PushObject, PushOptions } from '@ionic-native/push';

    constructor(private push: Push) { }

          initPushNotification() {
            // to check if we have permission
            this.push.hasPermission().then((res: any) => {
              if (res.isEnabled) {
                console.log('We have permission to send push notifications');
              } else {
                console.log("We don't have permission to send push notifications");
              }
            });

            // to initialize push notifications
            const options: PushOptions = {
              android: {
                senderID: '839584699716',
              },
              ios: {
                alert: 'true',
                badge: true,
                sound: 'false',
              },
              windows: {},
              browser: {
                pushServiceURL: 'http://push.api.phonegap.com/v1/push',
              },
             };

    const pushObject: PushObject = this.push.init(options);

    pushObject.on('notification').subscribe((notification: any) => {
      console.log('Received a notification', notification);
      //Notification Display Section
      let confirmAlert = this.alertCtrl.create({
        title: 'New Notification',
        message: JSON.stringify(notification),
        buttons: [
          {
            text: 'Ignore',
            role: 'cancel',
          },
          {
            text: 'View',
            handler: () => {
              //TODO: Your logic here
              //self.nav.push(DetailsPage, {message: data.message});
            },
          },
        ],
      });
      confirmAlert.present();
      //
    });
    pushObject.on('registration').subscribe((registration: any) => {
      console.log('Device registered', registration);
      this.fcmId = registration.registrationId;
      console.log(this.fcmId);
      this.storage.set('fcmId', this.fcmId);
    });

    pushObject.on('error').subscribe(error => console.error('Error with Push plugin.....', error));
  }

app.module.ts

import { Push } from '@ionic-native/push';


import {AngularFireModule} from 'angularfire2';
import {AngularFireAuthModule} from 'angularfire2/auth';

import firebase from 'firebase';

export const firebaseConfig = {
  apiKey: "###############################",
  authDomain: "premier11-109eb.firebaseapp.com",
  databaseURL: "https://premier11-109eb.firebaseio.com",
  projectId: "premier11-109eb",
  storageBucket: "premier11-109eb.appspot.com",
  messagingSenderId: "########" 
}
firebase.initializeApp(firebaseConfig);

@NgModule({
  declarations: [
    MyApp,
   // ContentDrawer
    // HomePage
  ],
  imports: [
    HttpClientModule,
    FormsModule,
    MbscModule,
    BrowserModule,

    AboutusPageModule,
    AllcontestPageModule,
    CaptainselectionPageModule,
    CashcontestPageModule,
    CreateteamPageModule,
    ContestsPageModule,
    FairplayPageModule,
    HelpdeskPageModule,
    HomePageModule,
    JoinedpagePageModule,
    LegalityPageModule,
    LoginmobilePageModule,
    LoginwebPageModule,
    MatchcenterPageModule,
    NotificationPageModule,
    OtpverificationloginPageModule,
    PayPageModule,
    PaymentPageModule,
    PaymentgatewayPageModule,
    PlayerdetailsPageModule,
    PrivacypolicyPageModule,
    ProfilePageModule,
    SignupPageModule,
    TabsPageModule,
    TeamselectionPageModule,
    ViewteamPageModule,
    ErrorPageModule,
    FeedbackformPageModule,

    HttpModule,

    IonicModule.forRoot(MyApp),
    IonicStorageModule.forRoot(),
    AngularFireAuthModule,
    AngularFireModule.initializeApp(firebaseConfig)
  ],
  bootstrap: [IonicApp],
  entryComponents: [MyApp],
  providers: [
    StatusBar,
    SplashScreen,
    Camera,
    { provide: ErrorHandler, useClass: IonicErrorHandler },
    SharedsecondProvider,
    EmailComposer,
    SocialSharing,
    P11dataProvider,Push,GooglePlus,Facebook,Network,AndroidPermissions,
  ],
})
export class AppModule {}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...