簡體   English   中英

用於 ios 的cordova-plugin-firebase

[英]cordova-plugin-firebase for ios

我在使用cordova-plugin-firebase": "^2.0.5" 時遇到了一些問題,我使用android 收到了通知,但在ios 中我遇到了一些問題,控制台日志顯示此錯誤:

1 -

[Firebase/Messaging][I-FCM002023] The object <AppDelegate: 0x2838a9280> does not respond to -messaging:didReceiveRegistrationToken:. Please implement -messaging:didReceiveRegistrationToken: to be provided with an FCM token.

2 -

[Firebase/InstanceID][I-IID003014] Error while reading embedded mobileprovision Error Domain=NSCocoaErrorDomain Code=260 "The file “embedded.mobileprovision” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/var/containers/Bundle/Application/697DE4E1-C6A4-461F-A6B5-2AF26447E1E1/SmartGeoLoc.app/embedded.mobileprovision, NSUnderlyingError=0x2836d1a40 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

收到令牌后,出現了這個錯誤:

3 -

5.7.0 - [Firebase/Messaging][I-FCM004001] Failed to subscribe to topic Error Domain=com.google.fcm Code=0 "(null)"

如果我測試發送通知示例,返回響應是:

{"multicast_id":6967427466880320868,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]}

注意:我已經從蘋果開發者控制台創建了證書,還有一個密鑰,並將文件 AuthKeyxxxxx.pm8 導入到 firebase 控制台。

我的供應商:

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Platform } from 'ionic-angular';
import { Firebase } from '@ionic-native/firebase';
import { Storage } from '@ionic/storage';
import { environment } from '../../environments/environment';


@Injectable()
export class FcmProvider {
  token;

  constructor(public http: HttpClient,private storage: Storage, private platform: Platform, public firebase: Firebase) {
    console.log('Bonjour FcmProvider Provider');
  }

  initializeFirebase(){
    if(!this.platform.is("core")) {
      this.getToken();
      this.firebase.subscribe("all");
    }
  }


  getToken() {
    if (this.platform.is('ios')) {
      this.firebase.grantPermission()
      .then(() => {
        this.firebase.getToken().then(token => {
          console.log("My Token ", toen);
        });        
      })
      .catch((error) => {
        this.firebase.logError(error);
      });
    }else{
      this.firebase.getToken().then(token => {
        console.log("My Token ", toen);
      });
    }

  }

  onNotifications() {
    return this.firebase.onNotificationOpen().subscribe(
      (msg) => {
        if(msg.tap){
            console.log(msg);
        }else{
          if (this.platform.is('ios')) {
            console.log(msg.aps.alert);
          }else {
            this.presentToast(msg.body);
          }
        }        
    });
  }
}

更多信息 => 離子信息

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.3
    ionic (Ionic CLI) : 3.20.1

global packages:

    cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1) 

local packages:

    @ionic/app-scripts : 3.2.3
    Cordova Platforms  : android 7.1.4 ios 4.5.5
    Ionic Framework    : ionic-angular 3.9.2

System:

    ios-deploy : 1.9.4 
    Node       : v10.13.0
    npm        : 6.9.0 
    OS         : macOS High Sierra
    Xcode      : Xcode 10.1 Build version 10B61 

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

使用的包裹:

"cordova-android-firebase-gradle-release": "^2.1.0",
"cordova-android-play-services-gradle-release": "^2.1.0",
"cordova-android-support-gradle-release": "^1.4.4",
"@ionic-native/firebase": "^4.20.0",
"cordova-plugin-firebase": "^2.0.5",
"firebase": "^4.8.0",

最后,我找到了一個解決方案,我從 File -> Project Settings -> Build System 更改了項目系統構建並選擇: Legacy Build System ,默認為 new legacy。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM