0

它在 FirebaseInvite Not found 时出错,我添加了 firebase-invite 的插件,但没有用于 firebase-invite 的节点包,所以我该如何使用 firebase-invite 插件的方法............ ..................................................... ..................................................... ..................................................... ..................................................... ……

import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';


// declare let FirebaseInvites: any;
@Component({
  selector: 'page-nvg',
  templateUrl: 'nvg.html',
})
export class NvgPage {

  constructor(public navCtrl: NavController, public navParams: NavParams) {
    alert(navParams.get('data'))
  }

  ionViewDidLoad() {
    alert('ionViewDidLoad NvgPage');
    console.log( window['plugins'].FirebaseInvites)

  }

  setInvitation() {
  FirebaseInvites.sendInvitation(
      {
        title: "The title", // mandatory, see the screenshots for its purpose
        message: "The message", // mandatory, see the screenshots for its purpose
        deepLink: "https://play.google.com/store/apps/details?id=xaviers.connect.io",
        callToActionText: "My CTA",
        description: "My description",
        customImage: "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png",
        //emailSubject: "My Email subject",
        //emailHtmlContent: "Some <strong>HTML</strong> content",
        androidClientID: "961112633951-499bi24dis8cf7cttef8kus9pe7a700p.apps.googleusercontent.com",
        // You can find your iOS app's client ID in the GoogleService-Info.plist file you downloaded from the Firebase console
        // iosClientID: "abc123"
      },
      function (result) {
        alert("Sent " + result.count + " invites");
        alert("Invitation ID's: " + JSON.stringify(result.invitationIds));
      },
      function (msg) {
        alert("Error: " + msg);
      }
    );
  }
  getInvitations() {
    window['FirebaseInvites'].getInvitation(
      function (result) {
        alert("invitation ID: " + result.invitationId);
        alert("deeplink: " + result.deepLink);
        alert("matchType: " + result.matchType); // iOS only, either "Weak" or "Strong" as described at https://firebase.google.com/docs/invites/ios
      },
      function (msg) {
        alert("Error: " + msg);
      }
    );
  }

}


It display NvgPage.html:17 ERROR TypeError: Cannot read property 'sendInvitation' of undefined
    at NvgPage.webpackJsonp.194.NvgPage.setInvitation (nvg.ts:23)
    at Object.eval [as handleEvent] (NvgPage.html:17)
    at handleEvent (core.js:13547)
    at callWithDebugContext (core.js:15056)
    at Object.debugHandleEvent [as handleEvent] (core.js:14643)
    at dispatchEvent (core.js:9962)
    at core.js:10587
    at HTMLButtonElement.<anonymous> (platform-browser.js:2628) 
    at t.invokeTask (polyfills.js:3)
    at Object.onInvokeTask (core.js:4740) 
4

0 回答 0