xamarin.forms - 无法让 Firebase 为 Xamarin Forms iOS 工作
问题描述
我在 Windows 上使用 Visual Studio 2019,使用 Xamarin Forms 开发适用于 Android 和 iOS 的应用程序。一切都是最新版本。
我正在尝试使用 Firebase 添加推送通知功能。我已经能够为 Android 应用程序实现此功能,但无论我做什么似乎都失败/不适用于 iOS。
我尝试使用 Xamarin.Firebase.iOS.CloudMessaging 和 Plugin.FirebasePushNotification 并获得相同的结果。从在 Visual Studio 中创建的基本应用程序开始,只要我为 iOS 项目添加基本代码,应用程序就会停止工作,并在 17 秒后运行任何项目代码(没有遇到断点)超时。
我还尝试下载此演示应用程序https://github.com/jfversluis/XFFCMPushNotificationsSample。我创建了我的 google-services.json (Android) 和 GoogleService-Info.plist (iOS) 版本。Android 应用程序运行,但 iOS 应用程序不运行(17 秒后超时)。
尝试了这么多不同的示例、示例、选项等 - 我完全不知道问题可能是什么。我刚接触 App 开发和 Xamarin Forms 对这种情况没有帮助!
我很感激我没有添加任何“我试过这个”代码,但我希望有人可以帮助我调试这个。Visual Studio 似乎没有显示任何内容,我可以从 iPhone 获得更多有用的信息吗?
编辑:
对于 iOS,
- 我创建了一个密钥并启用了 Apple 推送通知。
- 我已将密钥上传到 Firebase(云消息传递)中的 iOS 项目。
- 我已经下载了 GoogleService-Info.plist 文件并将其添加到 Visual Studio 中的 iOS 项目中,并将其设置为 BundleResource
- 我在 Entitlements.plist 中启用了推送通知
- 我在 Info.plist 中启用了后台模式和远程通知
- 我正在使用自动配置
- 我已检查捆绑标识符是否正确
- 我已将 FirebaseAppDelegateProxyEnabled 添加到 info.plist
编辑 2:我已经收到一条错误消息,该消息在调用
FirebasePushNotificationManager.Initialize(options, true);
{System.NullReferenceException:对象引用未设置为对象的实例。在 /Users/runner/runners/2.169.1/work/1/s/Plugin.FirebasePushNotification/FirebasePushNotificationManager.ios.cs 中的 Plugin.FirebasePushNotification.FirebasePushNotificationManager.Initialize(Foundation.NSDictionary 选项,System.Boolean autoRegistration)[0x00029]: 141 在 MyApp.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication 应用程序,Foundation.NSDictionary 选项)[0x00014] 在 \MyKRing.iOS\AppDelegate.cs:34 }
解决方案
推荐阅读
- c++ - MFC 如何解释 SetWindowTextW(LPCTSTR)?
- spring-integration - Service Activator 的 Spring Integration 输入通道
- javascript - 如何查找重复项 - 通过引用第一列?
- python - 如何根据用户响应更新松弛交互消息
- apache-camel - 动态构建 Apache Camel 路由
- ios - UIView insertSubview atIndex 移动子视图的奇怪行为
- spring - 具有自定义登录表单的 Spring Security 不起作用
- javascript - 设置超时的Javascript函数,当单击页面上的按钮时取消超时并继续执行其余功能?
- flutter - Hummingbird(现为 Flutter for web)计划发布。我应该停止学习 AngularDart 吗?
- arduino - 使用 74hc595(移出)控制继电器