简体   繁体   中英

cordova-plugin-firebase for ios

I have some issue with cordova-plugin-firebase": "^2.0.5", i received the notification using android, but in ios i have some problem, the console logs show this error :

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"}}

And after receiving the Token , this error occured :

3 -

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

If I test sending un example of notification , the return response is :

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

NB : I have created the certificat from apple developer console , and also a keys ,And importe the file AuthKeyxxxxx.pm8 to the firebase console.

My Provider :

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);
          }
        }        
    });
  }
}

More information => ionic info

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

Package Used :

"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。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM