【发布时间】: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