Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 77050 articles
Browse latest View live

Android Only Webview custom protocols "plaidlink://" throwing error "net:ERR_UNKNOWN_URL_SCHEME

"

$
0
0

When implementing a WebView the service provider Plaid uses urls that have custom protocols. We use the Navigating event to evaluate where the customer is in the registration process. This was working and still works on iOS, but now on Android we are receiving net:ERR_UNKNOWN_URL_SCHEME

 when Plaid sends these links.

We need to be able to receive the Navigating event without the webview throwing an error. We know that this was once working

Plaid uses custom protocols to invoke callbacks to the application. On iOS and previously on Android these were and should be ignored and not navigated to. Here are he three links that we receive.
plaidlink://acknowledged?
plaidlink://exit

plaidlink://connected
We get the navigating event and parse these url.

The error we receive now is net:ERR_UNKNOWN_URL_SCHEME



Here is the code snippet we are using.

        var publickey = "********";
        var webhook = "https://hipmoney.hippocket.net/plaidbankaccounts/webhook";
        var url = "https://cdn.plaid.com/link/v2/stable/link.html?isWebview=true&key=" + publickey + "&env=production&product=connect&selectAccount=true&webhook=" + webhook + "&clientName=hipmoney";

        if (!String.IsNullOrEmpty(PlaidProvider.PublicToken))
        {
            url = "https://cdn.plaid.com/link/v2/stable/link.html?isWebview=true&key=" + publickey + "&env=production&product=connect&webhook=" + webhook + "&clientName=hipmoney" + "&token=" + PlaidProvider.PublicToken;
        }

        plaidView = new WebView
        {
            Source = new UrlWebViewSource
            {
                Url = url
            },
            VerticalOptions = LayoutOptions.FillAndExpand,
        };
        this.Content = plaidView;
        plaidView.Navigating += (sender, e) =>
        {
            JObject plaidParams = ParseQueryString(e.Url);

            Debug.log(DateTime.UtcNow + " Navigating " + e.Url);
            if ((string)plaidParams["uri"] == "plaidlink://connected")
            {
                Debug.log(DateTime.UtcNow + " SUCCESS " + e.Url);
                OnSuccess.Execute(plaidParams);
            }
            else if((string) plaidParams["uri"] == "plaidlink://exit") {
                Debug.log(DateTime.UtcNow + " ERROR "+ e.Url);                  
                OnError.Execute(plaidParams);
            }
        };

We don't know what changed, if there was a configuration within the project or a library that was once included but this no longer works on Android, or if it was working by pure chance but we are 100% confident this was working on release sent out 4 weeks ago.


InfiniteScrolling to CollectionView

Loading does not Show

$
0
0

Good Day all

i have a loading functionality that shows on the long running part of my code. it does not show , here is how i use it

                Configurations.LoadingConfig = new LoadingConfig
                        {
                            IndicatorColor = Color.White,
                            OverlayColor = Color.Black,
                            Opacity = 0.4,
                            DefaultMessage = "Sending you an Sms, Please wait...",
                        };

                 await Loading.Instance.StartAsync(async progress =>
                        { 
                            await obj.Generate_Sms_Verification_code(GenericMethods.USER_DATA);

                        });

and the function Generate_Sms_Verification_code is defined like this

 public async Task Generate_Sms_Verification_code(USERS_Model model)
        {
            con = new SqlConnection(strCon);
            cmd = new SqlCommand();
            cmd.CommandText = "dbo.Sms_Verification_code";
            cmd.CommandType = CommandType.StoredProcedure; 
            cmd.Parameters.Add("@PARAMETER", SqlDbType.NVarChar).Value = model.PARAMETER;

             cmd.Connection = con;cmd.CommandTimeout = 0;
            string code = string.Empty;
            try
            {
                con.Open();
                code = cmd.ExecuteScalar().ToString();

                try
                {

                  await  SendSms(GenericMethods.RemoveSpacesIn_String(model.TELEPHONE), "Your APP Code is, " + code + ", Kindly Dont share this code with anyone");
                }
                catch (Exception ex )
                {
                    throw ex;
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
           }

i am using AiForms.Dialogs for Xamarin.Forms which can be found here https://github.com/muak/AiForms.Dialogs#loading

Thanks

MessagingCenter does't working

$
0
0

When I use async , I taking exeption

( I using MessagingCenter for chat app with Firebase Realtime Database )


PlatformNotSupportedException on iOS using Entity Framework Core and Xamarin Forms

$
0
0

Hello community,

I am using Entity Framework Core with SQLite for the first time on Xamarin Forms.

Because I observe the TaskScheduler.UnobservedTaskException, I noticed the following exception, each time I do an operation on EF:

System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Reflection.Emit.DynamicMethod..ctor (System.String name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[] parameterTypes, System.Type owner, System.Boolean skipVisibility) [0x00006] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection.Emit/DynamicMethod.notsupported.cs:74
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ILEmitResolverBuilder.BuildTypeNoCache (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite) [0x00038] in <29788903d3cf48c4a1368d8b368c6521>:0
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ILEmitResolverBuilder.<.ctor>b__12_0 (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCacheKey key, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite cs) [0x00000] in <29788903d3cf48c4a1368d8b368c6521>:0
at (wrapper delegate-invoke)

Because I would like to use it in a large scale production app, I am a bit concerned of this Exception, especially because I don’t know how the underlying framework behaves and if there are any side effects to this.

I have read that “System.Reflection.Emit” is not available on iOS, which I understand.
And the stacktrace indicates that it’s not directly related to Entity Framework, but apparently it’s causing a DI Service lookup which fails.

Any insight on this?

Here is a small demo app for this

Thanks

How to lock device orientation to landscape for IOS

$
0
0

Hiii community..
I have a small issue i.e I need to lock device orientation to landscape
i have tried info.plist but its not working
is there any solution to lock orientation in Code

Thanks

Advanced ListView

$
0
0

I am trying to create a List with items structured as in the picture. I cant figure out how I should combine that kind of ListItem that can be expanded (see arrow) plus having the text fields like shown in the picture. On top of it I am trying to include so that each section of the list should have an header. Could somebody give me a hint of how to achieve the ListView as below:

TapGestureRecognizer command not called

$
0
0

This is my xaml page

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:prism="http://prismlibrary.com"
             xmlns:ff="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
             xmlns:ffTransformations="clr-namespace:FFImageLoading.Transformations;assembly=FFImageLoading.Transformations"
             xmlns:controls="clr-namespace:InstagroomEX.Controls"
             prism:ViewModelLocator.AutowireViewModel="True"
             x:Class="InstagroomEX.Views.HomePageView"
             Title="Home"
             BackgroundColor="ForestGreen"
             NavigationPage.HasNavigationBar="False"
             x:Name="root">

    <StackLayout>
        <CollectionView ItemsSource="{Binding Images}">
            <CollectionView.Header>
                <StackLayout Orientation="Vertical">
                    <CollectionView ItemsSource="{Binding Source={x:Reference root}, Path=BindingContext.ImagesPath}"
                            HeightRequest="80"
                                    Margin="4,0,0,0">
                        <CollectionView.Header>
                            <Grid HeightRequest="80"
                                  WidthRequest="80">

                                <controls:SquareImage Source="{Binding Source={x:Reference root}, Path=BindingContext.UserAvatarPath, Mode=OneWay}"
                                                      Aspect="AspectFill"
                                                      Margin="8,8,8, 8">
                                    <controls:SquareImage.Transformations>
                                        <ffTransformations:CircleTransformation />
                                    </controls:SquareImage.Transformations>
                                </controls:SquareImage>
                                <controls:SquareImage Source="AddPlus.jpg"
                                                      HorizontalOptions="End"
                                                      VerticalOptions="End"
                                                      HeightRequest="16"
                                                      WidthRequest="16"
                                                      Margin="0,0,8,8">
                                    <ff:CachedImage.Transformations>
                                        <ffTransformations:RoundedTransformation Radius="1000"/>
                                    </ff:CachedImage.Transformations>
                                </controls:SquareImage>
                            </Grid>
                        </CollectionView.Header>



                    <CollectionView.ItemsLayout>
                        <LinearItemsLayout Orientation="Horizontal"
                                           ItemSpacing="0" />
                    </CollectionView.ItemsLayout>
                    <CollectionView.ItemTemplate>
                        <DataTemplate>
                            <Grid HeightRequest="80"
                                  WidthRequest="80">

                                    <controls:SquareImage Source="{Binding .}"
                                                      Aspect="AspectFill"
                                                      Margin="8, 8">
                                        <controls:SquareImage.Transformations>
                                            <ffTransformations:CircleTransformation BorderSize="16" BorderHexColor="#e300b9"/>
                                        </controls:SquareImage.Transformations>
                                    </controls:SquareImage>
                                </Grid>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>
                    <BoxView BackgroundColor="#524b50" HeightRequest="1"/>
                </StackLayout>

            </CollectionView.Header>


            <CollectionView.ItemsLayout>
                <LinearItemsLayout ItemSpacing="8"
                                 Orientation="Vertical"/>
            </CollectionView.ItemsLayout>
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <StackLayout Orientation="Vertical">
                        <StackLayout Orientation="Horizontal">
                            <ff:CachedImage Aspect="AspectFill"
                                            Source="{Binding Source, Mode=OneWay}"
                                            HeightRequest="40"
                                            WidthRequest="40"
                                            Margin="12,0,0,0"
                                            MinimumHeightRequest="100">
                                <ff:CachedImage.Transformations>
                                    <ffTransformations:CircleTransformation/>
                                </ff:CachedImage.Transformations>
                            </ff:CachedImage>

                            <Label Text="Username" 
                                   FontSize="18"
                                   VerticalOptions="Center"/>

                        </StackLayout>
                        <ff:CachedImage Aspect="AspectFill"                                        
                                        Source="{Binding Source, Mode=OneWay}"/>
                        <StackLayout Orientation="Horizontal">
                            <ff:CachedImage Aspect="AspectFill"
                                            Source="Like.png"
                                            HeightRequest="36"
                                            WidthRequest="40"
                                            Margin="12,0,0,0"
                                            MinimumHeightRequest="100">
                                <ff:CachedImage.Transformations>
                                    <ffTransformations:CropTransformation/>
                                </ff:CachedImage.Transformations>
                            </ff:CachedImage>
                            <ff:CachedImage Aspect="AspectFill"
                                            Source="comment.png"
                                            HeightRequest="40"
                                            WidthRequest="40"
                                            Margin="0,0,0,0"
                                            MinimumHeightRequest="100">
                                <ff:CachedImage.Transformations>
                                    <ffTransformations:CropTransformation/>
                                </ff:CachedImage.Transformations>
                            </ff:CachedImage>
                        </StackLayout>
                        <Label Text="Понравилось: M"
                               FontSize="18"
                               FontAttributes="Bold"
                               Margin="12,0,0,0"/>
                        <Label LineBreakMode="WordWrap"
                               BackgroundColor="Aquamarine"
                               HorizontalTextAlignment="Start"
                               Margin="12,0,12,0">
                            <Label.FormattedText >
                                <FormattedString>
                                    <Span Text="username: "
                                          FontSize="14"
                                          FontAttributes="Bold">
                                    </Span>
                                    <Span
                                        Text="{Binding Source={x:Reference root}, Path=BindingContext.PostUserDescription, 
                                        Mode=OneWay}"/>
                                    <Span Text="{Binding Source={x:Reference root}, Path=BindingContext.LoadMoreUserDescription, 
                                        Mode=OneWay}"
                                          FontSize="14"
                                          TextColor="Red">
                                        <Span.GestureRecognizers>
                                            <TapGestureRecognizer Command="{Binding Source={x:Reference root}, Mode=OneWay, Path=BindingContext.ExecuteLoadMoreUserDescriptionCommand}" />
                                        </Span.GestureRecognizers>
                                    </Span>

                                </FormattedString>
                            </Label.FormattedText>
                        </Label>
                        <Label Text="More"
                               FontSize="16"
                                TextColor="Red"
                                Margin="12,0,0,0"
                                HorizontalOptions="Start"
                                VerticalOptions="Center"/>
                        <Label Text="show all () comments"
                                HorizontalOptions="Center"
                                VerticalOptions="Center"
                                FontSize="12"
                                TextColor="Red"/>


                    </StackLayout>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
    </StackLayout>

</ContentPage>

And my ExecuteLoadMoreUserDescriptionCommand command doen't invoke from my ViewModel. other elements bind without problems. What is wrong with my binding?


Webservice call gets abruptly cancelled when app goes to background and comes to foreground(ios)

$
0
0

For a registration page , on click of register it calls the rest API to register the user. But after clicking on register if i goes to background and comes to foreground it throws web exception that operation can not be completed and software caused connection abort. Any suggestions how to handle this scenario. It occurs only in iOS. Android works fine. I have enabled background modes also, and provided the interval also for background fetch but it stills throws error. TIA. @JamesMontemagno @JohnMiller @RHudson @jezh @JoeManke

How to use Google Cloud Speech API within Xamarin.Forms

$
0
0

Hi there
Whats the easiest way to access the Google Cloud Speech API within Xamarin.Forms?

I tried the following code in my PCL-Project (debugging with an Android-Phone)

            Assembly assembly = typeof(Program).GetTypeInfo().Assembly;
            Stream stream = assembly.GetManifestResourceStream("ConsoleApp1.speech_auth.json");

            string resultString = null;

            using (StreamReader reader = new StreamReader(stream))
            {
                resultString = reader.ReadToEnd();
            }

            GoogleCredential credential = GoogleCredential.FromJson(resultString);

            if (credential.IsCreateScopedRequired)
            {
                credential = credential.CreateScoped(new[] { "https://www.googleapis.com/auth/cloud-platform" });
            }

            var channel = new Grpc.Core.Channel(SpeechClient.DefaultEndpoint.Host,
                credential.ToChannelCredentials());

            var speech = SpeechClient.Create(channel);
            var response = speech.Recognize(new RecognitionConfig()
                                                {
                                                    Encoding = RecognitionConfig.Types.AudioEncoding.Flac,
                                                    SampleRateHertz = 16000,
                                                    LanguageCode = "de-CH",
                                                }, RecognitionAudio.FromFile("test.flac"));

However, I get an error message on the line:

var channel = new Grpc.Core.Channel(SpeechClient.DefaultEndpoint.Host,
                credential.ToChannelCredentials());

which says:

Unhandled Exception: System.NotImplementedException: The method or operation is not implemented

Whats the problem there? Is there any better solution?

On a blank .NET ConsoleApplication, this code is working without problem.

PopUp page - Send data to mainpage ( mvvm )

$
0
0

Hello friends, i have main and popup pages.

my architecture is MVVM and i want to call back a string from popup page.

i tried EventHandler . Normally it works but for MVVM i couldnt make it work.

Any ideas?
Thanks in Advance;

What is the ListDictionaryInternal Involved in UpdateMainPage()?

$
0
0

I am encountering an error when assigning a new page to a class parameter. It appears that it has not been initialized and is null. What is it and how is it initialized? The code is in the PCL and has no problems in either Android or UWP.

<p>Object reference not set to an instance of an object</p><p>Data ----------</p><p>System.Collections.ListDictionaryInternal</p><p>HResult ----------</p><p>-2147467261</p><p>Source ----------</p><p>Xamarin.Forms.Platform.iOS</p><p>StackTrace ----------</p><p>  

at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.UpdateMainPage () [0x0000e] in d:\a\1\s\Xamarin.Forms.Platform.iOS\FormsApplicationDelegate.cs:198 \n at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.ApplicationOnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x00012] in d:\a\1\s\Xamarin.Forms.Platform.iOS\FormsApplicationDelegate.cs:152 \n at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in d:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:229 \n at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in d:\a\1\s\Xamarin.Forms.Core\Element.cs:353 \n at Xamarin.Forms.Application.set_MainPage (Xamarin.Forms.Page value) [0x0008b] in d:\a\1\s\Xamarin.Forms.Core\Application.cs:91

Error: Could not find any available provisioning profiles for iOS. NotificationContentExtension

$
0
0

I added the NotificationContentExtension for the IOS Project in xamarin forms.while building i am getting the below Error.

**Could not find any available provisioning profiles for iOS. NotificationContentExtension.
**
Do we create a new provision profile for this NotificationContentExtension ?

Please help us.

Thanks,

Remove padding/borders between Grid cell rows & columns

$
0
0

I am trying to remove the cell padding/borders in a Grid. I have read this thread: https://forums.xamarin.com/discussion/23295/can-the-padding-between-rows-in-a-grid-be-changed but none of the methods discussed there allow me to remove the spaces. How do I remove the invisible cell borders?

I've tried :

<Grid.RowDefinitions RowSpacing="0" 
<Grid.ColumnDefinitions ColumnSpacing="0" 

And obviously I've tried Padding="0" in the <Grid and <Grid.RowDefinitions and <Grid.ColumnDefinitions, but no luck.

Potential bug in compiled code

$
0
0

To make a long story short, the following code crashes my app on startup with System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

It is just a normal property on an object contained in a Listview bound to an ObservableCollection.

    private AnswerState _answerState;
    public new AnswerState AnswerState
    {
        get => _answerState;
        set
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                _answerState = value;
                OnPropertyChanged(nameof(AnswerStateText));
            });
        }
    }

If I remove Device.BeginInvokeOnMainThread() and put it further out, the app runs fine. The exception sure was misleading, and no stacktrace would guide me to find this. In fact, as it happens on startup, I am not even sure if the code in question is even being called before crashing.


My iOS Renderer is not detecting when theme changes

Displaying all images inside FlowListVIew

$
0
0

Hi Xamarin Forum
does anyone already used FlowlistView to display images from recorded file path in database and display the image in a tile design just like instagram?

How to share local web assets between iOS and Android projects?

$
0
0

Hello!

Issue: I'm trying to share a folder of web assets to both iOS and Android projects without duplicating them, but I'm having a hard time understanding where they're copying to/where to point my WebView at.

My structure looks like:

MySharedProject
- Content
- data.json
- main.css
- index.html
[...]
MySharedProject.Android
- HybridWebViewRenderer.cs
[...]
MySharedProject.iOS
- HybridWebViewRender
[...]


Backstory: I had the assets in MySharedProject.Android -> Content -> Index.html , etc, then in my WebViewer, I had this code and everything worked.

Control.LoadUrl($"file:///android_asset/Content/{((HybridWebView)Element).Uri}");

I'm trying to take the raw assets out of iOS + Android so I don't have to keep duplicating my efforts when updating them.


1.) Is there a way to create a link/reference between the shared asset and platform assets?

2.) In Android, should I not be using "file:///android_asset/" to reach those assets?

3.) How do you reach copied shared assets from Android and from iOS?

Thanks!

Change navigation bar color or eliminate it

$
0
0

Hi,
I've created a CarouselPage which contains 3 ContentPage. I want to achieve the next functionality:

  • when I open the app for the first time (after install), I want to display that pages and on the last one, a kind of button like Accept. When clicking Accept, I want to navigate the user to the MainPage.
  • after first use of the App, I don't want to display these pages anymore.

To do this, I've done the next steps:

  • created CarouselPage with 3 pages.
  • in App.xaml.cs:

        public App()
            {
                InitializeComponent();
                if (FirstTimeOpen())
                {
                    MainPage = new NavigationPage(new Page1());
                }
                else
                {
                    MainPage = new MainPage();
                }
            }
            public bool FirstTimeOpen()
            {
                bool isFirstTime = false;
    
                var value = Preferences.Get("wasOpened","");
                if (value.Equals("true"))
                {
                    isFirstTime = false;
                }
                else
                {
                    isFirstTime = true;
                }
    
                return isFirstTime;
            }
    

and in Page1.xaml.cs:

               public Page1()
                {
                    InitializeComponent();
                }

                public void SetApplicationWasOpened()
                {
                    Preferences.Set("wasOpened", "true");
                }

                private void Button_Clicked(object sender, EventArgs e)
                {
                    SetApplicationWasOpened();
                    Navigation.PushAsync(new MainPage());
                }

This works fine but I'd like not to display the navigation bar when I swipe the carousel pages, or at least to color it white.

Thank you!

ImageButton versus Button when setting FontImageSource to some font icon

Viewing all 77050 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>