如何从跨平台 PCL 使用 iOS AppTrackingTransparency.ATTrackingManager? [英] How use iOS AppTrackingTransparency.ATTrackingManager from cross-platform PCL?

查看:72
本文介绍了如何从跨平台 PCL 使用 iOS AppTrackingTransparency.ATTrackingManager?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以昨天这一行:

          ATTrackingManager.RequestTrackingAuthorization((status) => {
                     if (status == ATTrackingManagerAuthorizationStatus.Authorized)
                     {
                     }

是工作代码(在我的跨平台 Xamarin.Forms PCL 中).今天 xamarin.ios 收到了更新.

was working code (in my cross-platform Xamarin.Forms PCL). Today xamarin.ios received an update.

在 PCL 项目中,不再找到跟踪管​​理器.Intellisense 不知道它是什么,我无法调试应用程序.

In the PCL project, the tracking manager is not found anymore. Intellisense doesnt know what it is anymore and I cannot debug the app.

它在 xamarin.ios 项目中被识别,但我需要从我的 PCL 访问它.

It is recognized in the xamarin.ios project, but I need to access it from my PCL.

有人遇到同样的问题和/或已经找到了解决方案吗?

Anyone having the same issue and / or has already found a solution?

如何在今天收到之前回滚到 xamarin.ios?

How can I rollback to xamarin.ios before the one I received today?

推荐答案

不需要回滚.作为测试,我更新了

Don't need to rollback. As a test, I updated

  • Visual Studio(也更新了 Xamarin.iOS).
  • XCode 到 14.5.1.

然后,我向现有的 Xamarin Forms 解决方案添加了一行代码,引用了 AppTrackingTransparency.ATTrackingManager.这被识别为有效代码.我还尝试了 ATTrackingManager,Intellisense 正确地告诉我我需要 using AppTrackingTransparency.

Then I added a line of code to an existing Xamarin Forms solution, that referenced AppTrackingTransparency.ATTrackingManager. This was recognized as valid code. I Also tried just ATTrackingManager, and Intellisense correctly told me I needed using AppTrackingTransparency.

现在就在那里.

该命名空间+类名是特定于 iOS 的,因此必须从特定于 iOS 的项目中引用.(如果它之前在 PCL 中是可引用的,那么这可能是一个错误,后来被更正了;这样的代码在任何其他平台上都会中断.)

That namespace+classname is specific to iOS, so must be referenced from the iOS-specific project. (If it previously was referenceable in the PCL, that was probably a bug that has since been corrected; such code would break on any other platform.)

第一步:

在您的 iOS 项目中,编写引用该类的代码.

In your iOS project, write code that references that class.

第二步:

您需要了解如何使用来自跨平台 Xamarin Forms PCL 的自定义 iOS 代码.

You need to know how to use your custom iOS code from the cross-platform Xamarin Forms PCL.

我不会在这里重复 - 关于该主题有多个问答.
谷歌stackoverflow xamarin 表单调用平台特定代码".

I won't repeat that here - there are multiple Q&As on that topic.
google "stackoverflow xamarin forms call platform specific code".

这篇关于如何从跨平台 PCL 使用 iOS AppTrackingTransparency.ATTrackingManager?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆