I am trying to include Judopay in my project, and I was able to add it to Android and iOS, but not to the Xamarin forms project. There is no NuGet to be included and I can't seem to add the component reference. Any idea on how can I add it? I cannot use any of these:
using JudoDotNetXamarin;
using JudoPayDotNet.Enums;
using JudoPayDotNet.Models;
Again, they only work on iOS or Android, but not Xam forms.
That is because they only provide platform implementations. You will need to tell your Forms app which implementation to use at what time.
The correct way to go about this is with some form of IoC, using dependency injection or service location. Luckily Xamarin Forms has this integrated:
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/dependency-service/introduction/
Using the references from the Android or iOS projects in your shared code will likely not work completely or break things. Maybe not immediately but surely later on. (Except when there really is no platform-specific functionality, then you might get away with this.)
Related
I need to create a reusable Xamarin Forms control that will be used in two separate projects. It does require custom renderers for IOS and Android. The problem is I cannot figure our what kind of project to use to create a reusable custom control library for Xamarin forms.
Every site seems to talk about creating customer controls that can be reusing in the same project. But I need it in a separate project for reuse.
Can someone please point me in the right direction.
Depending what are your needs regarding multi-targeting, using a solution with a shared project of type MSBuild.Sdk.Extras could be very helpful. You can then packed your shared project into a package that you can reference from your apps project and use locally.
Examples that might guide you and shows you the path are known nuget packages that are being used by app developers cross-platforms, just an example Xamarin.Forms.PancakeView.
Related to MSBuild.Sdk.Extras: How to use different base class in custom control depending on platform target?
I'm trying to create an app using Visual Studio and Xamarin that will be cross platform. I've been trying to follow a tutorial I found online to do this.
When the guy in the video went to create a new project, he had the below screen, and created a Blank App (Xamarin.Forms Portable
I've installed the necessary components (Xamarin, WPF and a couple of others) with the IDE, however I don't see this option.
I've created a project using Mobile App (Xamarin.Forms) but it doesn't have the same structure as the desired template. Am I missing a component? Is the template called something different now?
The video is almost two years old, which means that some parts look different today.
If you click on the create a new xamarin.forms app, you will come to a new step where you can choose a blank app.
Then you have a choice, either choose shared projects or .net (portable).
The .net will give you a portable class library, like that in the video.
The two methods have different advantages.
Read more in the documentation: https://learn.microsoft.com/sv-se/xamarin/cross-platform/app-fundamentals/code-sharing
I hope the information will help you!
How do i make sure my app can run on android devices below Lollipop( version 4.03 to 4.42). I watched a xamarin university video that says xamarin forms supports android version 4.03(ice-cream sandwich) and upwards. I also read about runtime checks and feel like this might be the answer to my problem, but how can i write runtime checks for android when basically all my ui and logic is contained in the PCL project?
The first thing to do is ensure you are using the Android AppCompat library. I think new projects use this by default now. If you have an older project that doesn't follow these instructions to update. This will allow your app including any Material Design look and feel to run on older versions of Android.
If you do things differently based on Android version, put the code for this in the Android project and use dependency service to call it.
Like this:
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
{
// level specific code here
}
I have tricky question about SignaturePad updated to Xamarin Forms 2.0, link to GitHub:
https://github.com/mrbelk/acr-xamarin-forms
I did manage to download repo and build it, however I have no idea how to produce proper DLLs that I could use in my project?
The main issue is that SignaturePadView is treated as Xamarin Forms View class instead of Android View, so there is different constructors, methods, etc.
Does smb know how to build these projects to produce proper dlls that iOS/Android solution will treat SignaturePadView as Android View and iOS UIView respectively?
Don't use acr.* any more if you want to save yourself some pain. I had to pull their camera implementation out of one of my apps due to no support for forms 2.0+.
Replace acr with supported NuGets like Plugin.Media and the others found here. For this particular issue no one has created a non-deprecated NuGet so there is this plugin as an option.
Apparently, it happens that we have actually used SignaturePad from https://components.xamarin.com/view/signature-pad but via acr.* nuget package.
What I found in my quick research that both acr.xamforms.SignaturePad and SignaturePad it self were in acr nuget package, and actually we were using components from SignaturePad, luckily. So I did remove this nuget from sln to get rid of acr.* components and add SignaturePad from xamarin components by hand.
Now we are able to use Xamarin Forms 2.0 without any problems.
Cheers,
G
I been set the mission to look at Xamarin and its cross plaform / code resuse ability, I come from a iOS/Android background.
I want to aim for the holy grail of one universal front end (basic) and one reusable service layer.
I created my first project as a Xamarin Forms PLC, hit the issue it can not support compiler directives, which seem to be something your going to need. Also I was unable to add Parse package to the PLC. You need to reference it per platform / write code per platform?
I have now created Shared Asset Project, the default setup (new project). This does not allow me to add parse to the shared layer. Some of the examples I see add a new project called service, what type of project is this?
So, my question is, forgetting how many members are in a dev team, which one (PCL, SAP) lets me have a universal backend (parse).
I found a Github sample project that could help you. It can be found here: Sample Parse Project
The link to the xamarin component can be found here: Parse component This Xamarin Component should be able to be added into your project and it should get you started immediately. Also when you add the component to you project you should be able to view sample projects that come along with it.
I would start with the sample project and see what I can do with it, but it should become a lot easier by just adding the Parse component in. This would make it so you could probably use either type of project with some Dependency Injection.