ios - 具有 Firebase 消息传递和 Firebase 动态链接的 Cordova Ionic 项目

标签 ios cordova firebase firebase-cloud-messaging firebase-dynamic-links

在我们正在构建的应用程序中,我们需要 Firebase 动态链接,因为注册是使用 Firebase 电子邮件链接登录。此登录将向提供的电子邮件地址发送一封电子邮件,单击该电子邮件地址将打开带有动态链接的应用程序。为了让我们的用户保持参与,我们还喜欢发送推送通知。当我使用 GitHub 上的 chemerisuk 版本时,我可以让它们在 Android 上协同工作。我什至获得了一个 iOS 版本,但我无法在 iOS 上获取 token 。收到此错误消息:

Failed to fetch default token Error Domain=com.firebase.iid Code=1003 "(null)"

我仔细检查了我的 Firebase 项目设置(捆绑 ID、应用程序 ID 前缀、云消息发送者 ID、云消息 apn key )和我的 Apple 设置(证书、配置文件、 key 和标识符)。我已经在模拟器和真实设备上试过了。我尝试过开发版本、App Store 存档和 Ad Hoc 存档。

遗憾的是,动态链接未包含在 Cordova Firebase 插件中。当我尝试添加不同的 fcm 插件时,它包含完整的 Firebase 核心,这与动态链接冲突。

我觉得我真的很接近,谁有使用这种插件组合的经验并让它在 iOS 上运行?

这是我的环境:

Ionic:

  ionic (Ionic CLI)  : 4.0.2 (/usr/local/lib/node_modules/ionic)
  Ionic Framework    : ionic-angular 3.9.2
  @ionic/app-scripts : 3.1.8

Cordova:

  cordova (Cordova CLI) : 8.0.0
  Cordova Platforms     : android 7.0.0, ios 4.5.5

System:

  Android SDK Tools : 26.1.1
  ios-deploy        : 1.9.2
  ios-sim           : 6.1.2
  NodeJS            : v8.11.3 (/usr/local/bin/node)
  npm               : 5.6.0
  OS                : macOS High Sierra
  Xcode             : Xcode 9.4.1 Build version 9F2000

Environment:

  ANDROID_HOME : /Users/user/Library/Android/sdk/

我的(相关的)Cordova config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget android-packageName="com.example.android" android-versionCode="10001" id="com.example.app" ios-CFBundleIdentifier="com.example.ios" ios-CFBundleVersion="1.0.1" version="1.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Example</name>
    <description>Some description</description>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="ScrollEnabled" value="false" />
    <preference name="BackgroundColor" value="0xff168aa5" />
    <preference name="android-minSdkVersion" value="16" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="FadeSplashScreenDuration" value="300" />
    <preference name="Orientation" value="portrait" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="3000" />
    <platform name="android">
        <resource-file src="google-services.json" target="app/google-services.json" />
        <allow-intent href="market:*" />
        <icon />
        <splash />
    </platform>
    <platform name="ios">
        <resource-file src="GoogleService-Info.plist" />
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <icon />
        <splash />
    </platform>
    <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="cordova-plugin-device" spec="^2.0.2" />
    <plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
    <plugin name="cordova-plugin-ionic-webview" spec="^1.2.1" />
    <plugin name="cordova-plugin-ionic-keyboard" spec="^2.1.2" />
    <plugin name="cordova-plugin-x-socialsharing" spec="^5.4.1" />
    <plugin name="cordova-plugin-qrscanner" spec="^2.6.0" />
    <allow-navigation href="http://192.168.178.19:8101" />
    <plugin name="cordova-plugin-firebase-dynamiclinks" spec="^1.0.0">
        <variable name="APP_DOMAIN" value="example.com" />
        <variable name="PAGE_LINK_DOMAIN" value="ab123.app.goo.gl" />
        <variable name="FIREBASE_DYNAMIC_LINKS_VERSION" value="+" />
    </plugin>
    <plugin name="cordova-plugin-firebase-messaging" spec="^1.1.0">
        <variable name="FIREBASE_MESSAGING_VERSION" value="17.1.+" />
        <variable name="ANDROID_SUPPORT_VERSION" value="27.+" />
    </plugin>
    <engine name="android" spec="7.0.0" />
    <engine name="ios" spec="4.5.5" />
</widget>

最佳答案

因为我只使用了 Firebase 库的一部分,所以我没有包括 Firebase Analytics,因为我没有使用它。显然,它是其余插件运行所必需的。所以安装 cordova-plugin-firebase-analytics 是我的解决方法。

对于某些人来说,这是为了确保他们拥有正确的 Firebase 项目设置。转到 Firebase > Cloud messaging > iOS app configuration 并确保您已上传有效的 APNs 身份验证 key 或 APNs 证书。

希望这对想要同时使用 Firebase 消息传递和 Firebase 动态链接的其他人有所帮助!

关于ios - 具有 Firebase 消息传递和 Firebase 动态链接的 Cordova Ionic 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51657315/

相关文章:

ios - applicationReceivedRemoteMessage 只在前台执行

ios - Swift 在两个 View Controller 上使用后退按钮

angularjs - 可以将 AngularJS 与 Parse.com 一起使用吗?

ios - MKMapView 在选择注释时崩溃,然后立即释放 map View

javascript - 让本地 HTML5 视频在 Meteor 生成的 iOS 应用程序中工作

javascript - Phonegap iOS - 防止在输入焦点上滚动

javascript - 使用 Firebase 在 AngularJS 简单应用程序中出现错误

node.js - 无法在 Node.js 中导入 firebase-admin

ios - iOS Enterprise Build发行版

ios - 如何在 iOS/xcode 中重用颜色和样式?