gpt4 book ai didi

ios - Xamarin iOS 使用后台任务刷新和维护应用程序

转载 作者:行者123 更新时间:2023-12-02 17:01:05 26 4
gpt4 key购买 nike

这是在 Xamarin.iOS 中使用 BGTaskScheduler 的尝试。

我尝试从 https://github.com/xamarin/ios-samples/tree/master/ios13/RefreshingAndMaintainingYourAppUsingBackgroundTasks 运行示例应用程序。

native 版本(Swift 和 Objective C)运行良好。

平台详情

  • Mac 操作系统:Mac OS Mojave 10.14.6
  • XCode:版本 11.1
  • 设备:iPhone 8 Plus |操作系统13.1.2
  • Visual Studio:VS for Mac 8.3.1

预期结果:应用程序在后台定期更新

实际结果:没有触发回调。控制台中没有任何痕迹。

<小时/>
  • 是否可以从 native swift/objective C 代码创建可绑定(bind)库?

  • Xamarin Bindable Library 如何工作?

  • 它真的是调用 native API(如 JNI)还是映射相应的 Xamarin API?

  • 是否可以在没有源代码或 native 库二进制文件的情况下创建可绑定(bind)库?

  • 在官方 Xamarin.MaciOS SDK 中是否强制等待 bug fix

最佳答案

我通过为 BGTaskScheduler 创建一个可绑定(bind)库解决了这个问题。我做到了,

  1. 创建了一个 iOS Objective C 静态库,其中包含足够的 API 来注册、取消请求。 (可绑定(bind)库项目对 Swift 的支持不多)
  2. 为上述库创建了一个 fat 文件。
  3. 创建了 Xamarin.iOS Bindable Library 项目并引用了创建的 fat 文件。
  4. 在库中定义了 APIDefinitions 并生成了 .dll。
  5. 能够在 Xamarin.iOS 项目中使用此 .dll 文件,并且 BGTaskScheduler 工作正常。
<小时/>
  1. 是否可以从 native swift/objective C 代码创建可绑定(bind)库?

Yes.Objective C is preferred for the same

  • Xamarin Bindable Library 是如何工作的?
  • Bindable library creates a well defined interface between Xamarin.iOS and the Native APIs.Developer can access the native APIs through this layer.

  • 它真的调用 native API(如 JNI)还是映射相应的 Xamarin API?
  • Yes.It is like JNI.When we call the exported method in the APIDefinitions , its actually calls the Native method.

  • 是否可以在没有源代码或 native 库二进制文件的情况下创建可绑定(bind)库?
  • You need to properly link the required frameworks in the static library.

  • 是否必须等待官方 Xamarin.MaciOS SDK 中的错误修复?
  • Not really actually . :)

    关于ios - Xamarin iOS 使用后台任务刷新和维护应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59179119/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com