【问题标题】:cordova-plugin-fcm-with-dependecy-updated not working with IOScordova-plugin-fcm-with-dependecy-updated 不适用于 IOS
【发布时间】:2021-07-10 05:32:26
【问题描述】:

这是我的代码,它在 Android 上运行良好。但是当我为 IOS 进行构建时,它不起作用。

package.json

"cordova-plugin-fcm-with-dependecy-updated": {
        "ANDROID_FCM_VERSION": "19.0.0",
        "ANDROID_GRADLE_TOOLS_VERSION": "4.2.0",
        "ANDROID_GOOGLE_SERVICES_VERSION": "4.3.3",
        "ANDROID_DEFAULT_NOTIFICATION_ICON": "@mipmap/ic_launcher"
      },
import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx'; 
@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.scss']
})
export class AppComponent { 
  constructor(
    private platform: Platform,
    private fcm: FCM) { 
    this.initializeApp();
  }

  initializeApp() {
   this.platform.ready().then(() => {
      this.fcm.getToken().then(token => { 
        console.log(token); 
        EnvironmentConfig.token = token; 
        this.commonService.updateFCMToken(token, userId).subscribe( 
          async data => {
            // 
          },
          error => { 
            
          }
        ); 
      }); 
    })
    .catch(e => console.log('ErrorInitFCM', e))
}

在 IOS 中,我按照以下步骤操作,但仍然无法正常工作。

添加了 pod 'Firebase' 吊舱“火力基地/核心” pod 'Firebase/Messaging', '7.8.0' 到 podfile。

播客文件

# DO NOT MODIFY -- auto-generated by Apache Cordova
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'

target 'Project' do
    project 'Project.xcodeproj'
    pod 'Firebase'
    pod 'Firebase/Core'
    pod 'Firebase/Messaging', '7.8.0'
end 

删除 Podfile.lock、Pods、Project.xwcworkspace pod 安装在 IOS 文件夹中。 然后 Podfile.lock、Pods、Project.xwcworkspace 生成。 使用 Project.xwcworkspace 打开 xcode

PODS_ROOT = ${SRCROOT}/Pods PODS_ROOT = ${SRCROOT}/。将用户定义的设置添加到构建设置中。

然后存档项目。

它显示错误 'Firebase.h' file not found Click here to view error after build in xcode

【问题讨论】:

    标签: ios xcode cordova ionic-framework firebase-cloud-messaging


    【解决方案1】:

    在使用以下命令安装 fcm 插件之前,您需要安装可可豆荚: sudo gem install cocoapods

    另外cordova run ios 可能比直接从 xcode 构建应用程序更好。

    【讨论】:

      猜你喜欢
      • 2020-10-17
      • 2021-01-19
      • 2021-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多