How use iOS AppTrackingTransparency.ATTrackingManager from cross-platform PCL? - xamarin.forms

So yesterday this line:
ATTrackingManager.RequestTrackingAuthorization((status) => {
if (status == ATTrackingManagerAuthorizationStatus.Authorized)
{
}
was working code (in my cross-platform Xamarin.Forms PCL).
Today xamarin.ios received an update.
In the PCL project, the tracking manager is not found anymore. Intellisense doesnt know what it is anymore and I cannot debug the app.
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?
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 (which also updated Xamarin.iOS).
XCode to 14.5.1.
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.
So its there now.
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.)
First step:
In your iOS project, write code that references that class.
Second step:
You need to know how to use your custom iOS code from the cross-platform Xamarin Forms PCL.
I won't repeat that here - there are multiple Q&As on that topic.
google "stackoverflow xamarin forms call platform specific code".

Related

Xamarin forms: ITMS-90809: Deprecated API Usage, but no webview in my project

Yesterday I have pushed a new app to AppStore, but it gets rejected with the following error.
ITMS-90809: Deprecated API Usage - New apps that use UIWebView are no longer accepted. Instead, use WKWebView for improved security and reliability. Learn more (https://developer.apple.com/documentation/uikit/uiwebview).
In my knowledge, this issue usually occurs due to the use of Webview. I have one Webview in my project, so I decided to remove it (Since that part is currently not using in the project). I have pushed the app again to AppStore after removing the Webview, but again my app gets rejected with the same error. After that I do a clean, rebuild, and deleted the bin, obj folders. 2 times my app gets rejected from Appstore after removing Webview.
See the below screenshot: No Webviews are available for the entire solution.
Are there any other reasons for this error?
This seems an existing issue of Xamarin.forms on iOS .
Make sure that the version Xamarin.Forms is 4.6 or higher and Xamarin.iOS is 13.10.0.17 or higher.
Change the Linker Behavior to SDK Only or Link All and then add the
additional arguments: --optimize=experimental-xforms-product-type
Please check all of these have been set under the release
configuration and iPhone platform.
For more details you could refer
https://devblogs.microsoft.com/xamarin/uiwebview-deprecation-xamarin-forms/

Migrating Xamarin.Forms Android app to AndroidX support packages

I have a Xamarin.Forms Android project, am I'm trying migrate from the old Android support packages to AndroidX. The migrate seems to work, and I end up having to add a reference to the AndroidX media package during compile.
The issue is that when I try to actually run the app, I get the exception
System.InvalidCastException: 'Unable to convert instance of type 'Android.Widget.RelativeLayout' to type 'AndroidX.AppCompat.Widget.Toolbar'.'
from the Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnCreate. My MainActivity class subclasses FormsAppCompatActivity and MainActivity's OnCreate immediately calls the base OnCreate. Visual Studio says the exception is from external code, so it doesn't show me anything.
The OnStart and OnResume overrides in my MainActivity are called and finish fine (its only one line of code configuring the CrossCurrentActivity plugin being used.
I'm at a loss as to how to track down the problem. I suspect the issue is somewhere in one of the packages I'm using, my main suspect being the Xam.Plugin.Iconize since it hasn't been updated for a while, but we rely on it and I'm not really sure how to prove where the issue is.
I recently migrated to AndroidX and published the app. Users have been reporting a lot of crashes on start. I'm still figuring it out. Weird part is that, it works fine on some devices but crashes on some others.
I have noticed a few files in Android project still refer to the old 'Android Support' lib. Make sure you change them manually to AndroidX.
Check the Toolbar.xml and Tabbar.xml (Android proj>Resources>Layout). I had this in my app, which was still using android.support.v7......
I suggest to check in all the files and update manually where ever required.

How to include Android.Support.v4 in Xamarin Forms (iOS)?

I am using Visual Studio For Mac. My Xamarin Forms project is quite large and contains many content pages. Some of them will be only used in android project and some of them only used in iOS project. There is no problem when I compile the project into android. However, when I want to compile the project into iOS, it seems like did not accept anything related to android. Please refer to the screenshot. There is no way I can include the android specialised reference and compile into iOS project. So, any idea to deal with this? Maybe there is a way to force build the iOS project no matter what? The error from the screenshot is from the page that will be only used in android. So what I can do for now is delete the page when I want to compile as iOS and recreate the page when I want to used it for android. But there are plenty of them, it is too heavy for me to do this every time. Please help.
You can't call platform specific APIs at the .NET standard libraries that are used to host Xamarin.Forms code by default.
Basically you have those options:
1) using shared project instead of library and using conditional compiling (easier but it is now not available as the option when creating the project)
2) using dependency injection.

Xamarin UWP and Azure Mobile Services Offline SQLite Sync - problems when building in Relase mode with .Net Native Toolchain on

We have a problem when we build our app in Release mode with .Net Native Toolchain on.
MobileServiceClient.SyncContext.PendingOperations then returns -1 instead of 0 when there are no Pending Operations which result in that offline functionality no longer works (no items that are inserted when you are offline are sent over to the server).
The same phenomenon is described here:
https://github.com/Azure/azure-mobile-services/issues/890
We have tested with Visual Studio Update 2 and also with Visual Studio Update 3, but unfortunately, the problem remains in that version.
However, we have noticed that if we set "Optimize code" = false the offline functionality works, but then we instead get the following errors when Windows App Certification Kit tests have been completed.
"AppName" takes a dependency on Microsoft .Net Native Framework Package 1.x framework but is missing the framework dependency declaration in the manifest.
and
API CoCreateInstance in api-ms-win-core-com-l1-1-0.dll is not supported for this application type. "AppName.dll" calls this API.
If anyone has a solution for this, we would be very grateful!
With the help of a member from the .NET Native runtime and compiler team (Many thanks) we have been able to troubleshoot the problem and come up with a workaround!
We have worked around this issue by adding this to Properties\Default.rd.xml file:
<Library Name="Newtonsoft.Json"> <Assembly Name="Newtonsoft.Json" DoNotOptimize="true"DoNotInline="true" /></Library>​
This instructs the optimizer to ignore all of the types/methods inside of Newtonsoft.Json.
I have noticed that you reposted on the Azure Forums as well. I asked a few follow-up questions there and will answer your query there. We can cross-post the eventual answer if you like.

appGyver Steroids SQLite Cordova Plugin

I'm using steroids by appgyver (update to latest version which includes supersonic as well) to develop my app.
I'm confused about the SQLite plugin. First they supported and included it, then they remove it, then they say that it will not work unless you configure the custom build (and there is no much documentation about that)...
I have a very simple application: textarea and button. When you click the button you insert intto the database the value.
According to the docs https://github.com/brodysoft/Cordova-SQLitePlugin
I'm using var db = window.sqlitePlugin.openDatabase({name : "mydb"});
to open the database. I have the scanner app updated on both android and ios. The result is that in IOS works fine while in Android I get this error: "Cannot read property 'openDatabase' of undefined".
My question is: for IOS the app will stop working once deployed on the appstore?
Why it's working with IOS Scanner? Is it supposed to work? I understood they removed SQLIte support. I don't understand. Then, cause in IOS works, why in Android is not working?
Moreover, how to include SQLite plugin in a steroid project? Anyone was suffesfuul with that? I love appgyver, they did a wonderful job with steroids and supersonic, but... for this SQLite plugin and related support (even an example would do) I'm a bit concerned regarding my decision to go with steroids and not with xamarin for example.
Thank you guys.
AppGyver dev here! You need to include the SQLite plugin as a custom plugin to your app using our Build Service, and then build a stand-alone app: http://docs.appgyver.com/tooling/build-service/
The SQLite plugin is included in the iOS App Store Scanner for preview purposes, so that's the reason it's working on iOS and not on Android. This is actually something we're removing soon, so sorry for the confusion.

Resources