Xamarin iOS 使用 BackgroundTasks 刷新和维护应用程序
Xamarin iOS Refreshing And Maintaining App Using BackgroundTasks
这是在 Xamarin.iOS 中使用 BGTaskScheduler 的尝试。
我已经尝试 运行 来自 https://github.com/xamarin/ios-samples/tree/master/ios13/RefreshingAndMaintainingYourAppUsingBackgroundTasks 的示例应用程序。
原生版本(Swift 和 Objective C)工作正常。
平台详情
- Mac OS :
Mac OS Mojave 10.14.6
- XCode :
Version 11.1
- 设备:
iPhone 8 Plus | OS 13.1.2
- Visual Studio :
VS for Mac 8.3.1
预期结果: 应用程序在后台定期更新
实际结果:没有触发回调。控制台无痕迹。
是否可以从本机 swift/objective C 代码创建可绑定库?
Xamarin 可绑定库如何工作?
是真的调用原生API(比如JNI)还是映射对应的Xamarin APIs ?
是否可以在没有源代码或本机库二进制文件的情况下创建可绑定库?
是否必须等待官方 Xamarin.MaciOS SDK 中的 bug fix?
我通过为 BGTaskScheduler.I 创建一个可绑定库来解决它,
- 创建了一个 iOS Objective C 静态库,其中包含足够的 API 来注册、取消请求。 (Swift 在 Bindable Library 项目中没有太多支持)
- 为上述库创建了一个 fat 文件。
- 创建了 Xamarin.iOS 可绑定库项目并引用了创建的 fat 文件。
- 定义了库中的API定义并生成了 .dll。
- 能够在 Xamarin.iOS 项目中使用此 .dll 文件并且 BGTaskScheduler 工作正常。
- 是否可以从本机 swift/objective C 代码创建可绑定库?
Yes.Objective C is preferred for the same
- Xamarin 可绑定库如何工作?
Bindable library creates a well defined interface between Xamarin.iOS
and the
Native APIs.Developer can access the native APIs through this layer.
- 它真的是在调用本机 API(如 JNI)还是它映射了相应的 Xamarin API?
Yes.It is like JNI.When we call the exported method in the
APIDefinitions ,
its actually calls the Native method.
- 是否可以在没有源代码或本机库二进制文件的情况下创建可绑定库?
You need to properly link the required frameworks in the static
library.
- 是否必须等待官方 Xamarin.MaciOS SDK 中的错误修复?
Not really actually . :)
这是在 Xamarin.iOS 中使用 BGTaskScheduler 的尝试。
我已经尝试 运行 来自 https://github.com/xamarin/ios-samples/tree/master/ios13/RefreshingAndMaintainingYourAppUsingBackgroundTasks 的示例应用程序。
原生版本(Swift 和 Objective C)工作正常。
平台详情
- Mac OS :
Mac OS Mojave 10.14.6
- XCode :
Version 11.1
- 设备:
iPhone 8 Plus | OS 13.1.2
- Visual Studio :
VS for Mac 8.3.1
预期结果: 应用程序在后台定期更新
实际结果:没有触发回调。控制台无痕迹。
是否可以从本机 swift/objective C 代码创建可绑定库?
Xamarin 可绑定库如何工作?
是真的调用原生API(比如JNI)还是映射对应的Xamarin APIs ?
是否可以在没有源代码或本机库二进制文件的情况下创建可绑定库?
是否必须等待官方 Xamarin.MaciOS SDK 中的 bug fix?
我通过为 BGTaskScheduler.I 创建一个可绑定库来解决它,
- 创建了一个 iOS Objective C 静态库,其中包含足够的 API 来注册、取消请求。 (Swift 在 Bindable Library 项目中没有太多支持)
- 为上述库创建了一个 fat 文件。
- 创建了 Xamarin.iOS 可绑定库项目并引用了创建的 fat 文件。
- 定义了库中的API定义并生成了 .dll。
- 能够在 Xamarin.iOS 项目中使用此 .dll 文件并且 BGTaskScheduler 工作正常。
- 是否可以从本机 swift/objective C 代码创建可绑定库?
Yes.Objective C is preferred for the same
- Xamarin 可绑定库如何工作?
Bindable library creates a well defined interface between Xamarin.iOS and the Native APIs.Developer can access the native APIs through this layer.
- 它真的是在调用本机 API(如 JNI)还是它映射了相应的 Xamarin API?
Yes.It is like JNI.When we call the exported method in the APIDefinitions , its actually calls the Native method.
- 是否可以在没有源代码或本机库二进制文件的情况下创建可绑定库?
You need to properly link the required frameworks in the static library.
- 是否必须等待官方 Xamarin.MaciOS SDK 中的错误修复?
Not really actually . :)