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

Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED in Android. Works in iOS

$
0
0

Hi,

Please go through the below exception and suggest the resolution of this error.

  • Happens only when calling any API and only in Android. Works in iOS without any exceptions.
  • Using XF v4.0.30319
    Approaches tried:
    As mentioned in some forums, tried to change the HTTPClient of Android project to Android but didn't worked out.

Attached the complete exception

08-20 09:46:34.678 E/mono (13095): Unhandled Exception:
08-20 09:46:34.678 E/mono (13095): System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: TrustFailure (A call to SSPI failed, see inner exception.) ---> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
08-20 09:46:34.678 E/mono (13095): at /Users/builder/jenkins/workspace/xamarin-android-d15-8/xamarin-android/external/mono/external/boringssl/ssl/handshake_client.c:1132
08-20 09:46:34.678 E/mono (13095): at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00038] in :0
08-20 09:46:34.678 E/mono (13095): at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status) [0x0003e] in :0
08-20 09:46:34.678 E/mono (13095): at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus)
08-20 09:46:34.678 E/mono (13095): at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00006] in :0
08-20 09:46:34.678 E/mono (13095): at Mono.Net.Security.AsyncProtocolRequest+d__24.MoveNext () [0x000ff] in :0
08-20 09:46:34.678 E/mono (13095): --- End of stack trace from previous location where exception was thrown ---
08-20 09:46:34.678 E/mono (13095): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <43dbbdc147f2482093d8409abb04c233>:0
08-20 09:46:34.678 E/mono (13095): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <43dbbdc147f2482093d8409abb04c233>:0
08-20 09:46:34.678 E/mono (13095): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <43dbbdc147f2482093d8409abb04c233>:0
08-20 09:46:34.678 E/mono (13095): at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0
08-20 09:46:34.678 E/mono (13095): at Mono.Net.Security.AsyncProtocolRequest+d__23.MoveNext () [0x0008b] in :0
08-20 09:46:34.678 E/mono (13095): --- End of inner exception stack trace ---


Tabbed Page tab reselected

$
0
0

I've been looking for a solution to this problem for a few days and I think I've exhausted all of the old posts and articles on the topic without finding a solution. For Android specifically I've tried a custom renderer that uses TabLayout.IOnTabSelectedListener.OnTabReselected but it seems the event is never fired or even referenced anywhere.

How do you detect when a tab is reselected on a tabbed page? By reselected I mean the button of the tabbed page tab you are currently on is pressed while you are still on that tab. I need this in order to do a page "refresh". Thanks in advance!

UIBarButtonItem in Tabbed Page Custom Renderer Losing Title Text Attributes

$
0
0

When my view loads I can see that my CustomRenderer is working, my navbar's background is changed, the left and right button's tintcolors are changed and the right button has its font updated to use FontAwesome. However when I select another tab the right button loses all of the text attributes I've set and reverts back to its default values. Is there a way to make those changes persist across tab selections?

Push Notification, OnMessageReceived triggers multiple times, loading multiple pages.

$
0
0

Guys im having an issue,

I want to load a page that displays the push notification string content but the OnReceivedMessage() gets triggered an increasing number of times equal to the amount of times I go to the DisplayNotificationPage and back.

So first time I run, the OnRevceivedMessage triggers, opens the DisplayNotificationPage() that i close and return to the previous page through PopAsync(). The second time the OnReceivedMessage() triggers twice, then 3 times etc for every run.

What is going on? I think it has to do something with subscribing.. how can i fix this?

[XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class NotificationReceivingPage : ContentPage
    {
        public NotificationReceivingPage ()
        {
            InitializeComponent ();
        }


        protected override void OnAppearing()
        {
            base.OnAppearing();
            MessagingCenter.Subscribe<object, string>(this, App.NotificationReceivedKey, OnMessageReceived);
        }

        private void OnMessageReceived(object sender, string incomingNotificationBody)     // gets triggered x1, x2, x3... and so on
        {
            if (!string.IsNullOrEmpty(incomingNotificationBody))
            {
                Navigation.PushAsync(new NotificationDisplayPage(incomingNotificationBody));
            }         
        }

        protected override void OnDisappearing()
        {
            base.OnDisappearing();
            MessagingCenter.Unsubscribe<object>(this, App.NotificationReceivedKey);
        }


[XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class NotificationDisplayPage : ContentPage
    {
        ISimpleAudioPlayer soundPlayer;
        private static string incomingMessage = null;

        //default constructor
        public AlarmDisplayPage ()
        {
            InitializeComponent ();
        }

        // overloaded constructor that receives incoming notification body
        public AlarmDisplayPage(string messageBody)
        {
            InitializeComponent();

            if (messageBody != null)
            {
                incomingMessage = messageBody;
            }

            //alarm to sound on incoming message
            var assembly = typeof(AlarmDisplayPage);
            alertHeader.Source = ImageSource.FromResource("SApp.Assets.Images.mypic-header.png", assembly);
        }


        protected override void OnAppearing()
        {
            base.OnAppearing();

            stopAlarmButton.IsEnabled = true;

            //initialize soundplayer
            soundPlayer = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
            soundPlayer.Load(GetStreamFromFile("mysound.mp3"));

            if (!string.IsNullOrEmpty(incomingMessage))
            {
                setEventDetails();

                //play the alarm
                soundPlayer.Play();
            }    

        }

        protected override void OnDisappearing()
        {
            base.OnDisappearing();
            soundPlayer.Stop();
            incomingMessage = null;
        }


        private Stream GetStreamFromFile(string mediaFilename)
        {
            var assembly = typeof(App).GetTypeInfo().Assembly;
            var stream = assembly.GetManifestResourceStream("SApp.Assets.Sounds." + mediaFilename);
            return stream;
        }

        private void stopAlarmButton_Clicked(object sender, EventArgs e)
        {
            stopAlarmButton.IsEnabled = false;

            Navigation.PopToRootAsync();
        }

        private void setEventDetails()
        {
            if (!string.IsNullOrEmpty(incomingMessage))
            {
                labelEventType.Text = incomingMessage;
            }
            else
            {
                labelEventType.Text = "No Data";
            }

        }
    }

Auto Size font for button text to fit in single line

$
0
0

Hello All,

I have a problem and kind of stuck on this.
I had 5 buttons which display at the bottom of the screen. (Android & ios)
The default font size is 14. I want to calculate the font size of all 5 buttons text to check they fit the screen size or not.
If they don't fit with the width of the screen then reduce the font size to 12 and try to display. If it still doesn't fit truncates the button text length and display with font size 14.

Button sets are in Grid and I have a button renderer which is using Control.TitleLabel.LineBreakMode = UILineBreakMode.WordWrap;
I can't change this wordwrap here because this renderer is been used in many places where text wrap is required.

This is another scenario where only 3 buttons are available and 2nd button still wraps in 2 lines.

Thank you

Get User Current Latitude and Longitude without any packages.

$
0
0

Hi,
I am implementing app where I need user's current latitude and longitude but without using any packages. So is there any way to do that?

P.S.
I have already tried this package but it didn't work properly.

var position = await locator.GetPositionAsync();

Above line never return once it is called and I am testing on my physical device.

INotifyPropertyChanged Event for nested Properties

$
0
0

Hi Guys,

i have the following situation:

OverviewPage.xaml:

 <Label>
           <Label.Triggers>
                  <DataTrigger TargetType="Label" Binding="{Binding VehicleState.Tires.TypeSelectedIndex}" Value="0">
                            <Setter Property="Text" Value="Summer" />
                  </DataTrigger>
           </Label.Triggers> > 
    </Label>

OverviewPageModel.cs has a Property:

    public VehicleStatePageModel VehicleState
    {
        get
        {
            return vehicleState;
        }
        set
        {
            vehicleState= value;
            OnPropertyChanged("VehicleState");
        }
    }

VehicleStatePageModel has a Property:

  public TiresPageModel Tires
        {
            get
            {
                return tires;
            }
            set
            {
                tires= value;
                OnPropertyChanged("Tires");
            }
        }

and TiresPageModel has a Property:

public int TypeSelectedIndex
{
get
{
return typeSelectedIndex;
}
set
{
if (typeSelectedIndex!= value)
{
typeSelectedIndex= value;
OnPropertyChanged("TypeSelectedIndex");
}
}
}

Now i have a TiresPage.xaml with a Picker whichs SelectedIndex Attribute is bound to the TypeSelectedIndex Property of TiresPageModel:

>! <Picker ItemsSource="{Binding TiresTypeList}" SelectedIndex="{Binding TypeSelectedIndex}"/>

If i change the value of the Picker the "OnPropertyChanged-Event" of the TypeSelectedIndex Property gets called.

But in my OverviewPage.xaml from the very first code snipped this binding:

>!  Binding="{Binding VehicleState.Tires.TypeSelectedIndex}"

dont gets refreshed.

Why is that?
Thanks, Gelatto

MR.gesture call event twice in IOS but behaving correctly in Android.

$
0
0

I am using MR. Gestures plugin to handle single tap and long pressed event. I have the listview and inside the listview, there is a grid which divided into two column. Each separate column having longpress event and single tap event.

on a Longpressed event, items are select/deselect. That item may be left item or right item from the single row of the listview.

When I long press one item it is selected then after when I press some other item from different row, "Longpressed" event call twice and the previous item is deselected automatically.

the whole scenario is as follows

There are three row (index - 0,1,2)

  1. Left item from index-2 is selected

  2. Now I long press on left item of index-1.

  3. Long press event call twice.

  4. First time for index-2 and unchecked the selected item.

  5. second time for index-1 and checked.

private void grd_left_product_LongPressed(object sender, MR.Gestures.LongPressEventArgs e)
{
try
{
var productId = sender as Grid;
if (!string.IsNullOrEmpty(productId.ClassId) && lstcollectionproductDatas != null && lstcollectionproductDatas.Count > 0)
{
var selectedObject = lstcollectionproductDatas.Where(d => d.Left_attachedFilePath == productId.ClassId).FirstOrDefault();
if (selectedObject != null)
{
int index = lstcollectionproductDatas.IndexOf(selectedObject);
if (!selectedObject.Left_IsChecked)
lstcollectionproductDatas[index].Left_IsChecked = true;
else
lstcollectionproductDatas[index].Left_IsChecked = false;
}
lstProducts.ItemsSource = null;
lstProducts.ItemsSource = lstcollectionproductDatas;
}
else
new ShowSnackbar(AppResources.Validation_FileNotFound_Message);
}
catch (Exception)
{
new ShowSnackbar(AppResources.Validation_Exception);
}
}

This same behaviour working correctly in android but not working in IOS.

Is this plugin issue? Please suggest me some other plugin.

My Content page is call inside tabbed page. Every content page is having the same kind of listview. I can not figure out the actual issue.


MR.Gestures behaving correctly on Android but not on iOS

$
0
0

Hi all,

I have come across a problem and wondered if there was a quick solution or something I'm missing.

Basically I have a StackLayout that forms most of the page - I am using its .Tapped event courtesy of MR.Gestures.

The StackLayout's children are MR.Gesture.Label objects and I am also using their .Tapped events.

On iOS when I run on the simulator, tapping one of the child labels causes the parent StackLayout's .Tapped event to fire, but the child label .Tapped event doesn't.

However, on Android when tapping a child label the correct .Tapped event fires (and actually I think the parent StackLayout's .Tapped event fires afterwards but I can cope with that).

Not sure if this is the desired functionality or if there is some way of making sure the correct event fires.

I'm using a GridLayout if that makes any difference, and happy to supply some code (but there's a lot so would need to paste the relevant bits) for this particular application.

@MichaelRumpler

Thank you.

PS I'm using MR.Gestures v1.3.5 on both platforms and also XF 2.0.1.6495 on both as well.

PPS. I'm now just wondering if it's anything to do with the fact I'm clicking my mouse on the iOS simulator but for Android I have an actual device.

Serving dynamic files to a WebView

$
0
0

Hi,

I created a WebView which shows a single page application, which works very well.
But I am facing an issue where I want to show an user uploaded image. I have managed to do this so far by injecting an base64 image through invocation of javascript, but due to memory limitations, the WebView crashes if the image gets too large.

Is there a way to serve dynamic data to the WebView, now that Resources are read-only?

I would love to be able to call image instead of image

/Søren

Android.Webkit.WebView height issue?

$
0
0

I have a custom android webview renderer that loads only about 10% of the top page.

When I try to load the URL using mobile chrome or firefox app, the page loads fine.

Noticed when the web page loads, it momentarily loads a page, and starts to load the page again (using javascript).

Need help setting the height of the web view.

How to Restrict my application to launch English only Keyboard

$
0
0

How to Restrict my application to launch English only Keyboard for all Entry across the application irrespective of any language set on the phone?

Bind dynamic data to picker inside list view

$
0
0

Hi Guys,

I am trying to bind data to picker inside the list view but i am not able to bind the things to it. currently i am trying static one. Can any please help me.

            <ListView x:Name="lsttest">
                            <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                    <ContentView>
                                      <Picker x:Name="pckdate" ItemsSource="{Binding ClsRenWeekly}" TextColor="Red"    ItemDisplayBinding="{Binding strdates}"
                                                Title="Choose date" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />
                                    </ContentView>
                                </ViewCell>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                        </ListView>

public List<ClsRenWeekly> renewweeklyitems { get; set; }

renewweeklyitems = new List<ClsRenWeekly>()
                        {
                            new ClsRenWeekly() {  strdates="March" },

                            new ClsRenWeekly() {strdates="April" }

                        };

            lsttest.ItemsSource = renewweeklyitems;

how can i get notified when static property is changed

$
0
0

how can i get notified when static property is changed

How do I properly bind to a label's span?

$
0
0

I have a label that looks something like this:

<Label x:Name="MovAvgLabel" Grid.Column="0" HorizontalOptions="Center" HorizontalTextAlignment="Center" >
                            <Label.FormattedText>
                                <FormattedString>
                                    <Span Text="{Binding Path=MovingAverage}" FontSize="Medium" FontAttributes="Bold"/>
                                    <Span Text="&#10;Moving Average&#10;Today"/>
                                </FormattedString>
                            </Label.FormattedText>
                        </Label>

The above code fails to bind to my ViewModel. I don't think it's the binding context, I tried binding to a regular label like so:

<Label Grid.Column="0" HorizontalOptions="Center" HorizontalTextAlignment="Center" Text="{Binding MovingAverage}"/>

And that seemed to work fine. What am I doing wrong here? The two examples shared the same grid parent. What's weird is that I've bound objects to spans before and it worked fine, although it was in the context of a custom ViewCell so maybe there's some weirdness there.


BindingCondition

$
0
0

Given the following code fragment, would xamarin.forms support the second and the third condition?
<MultiTrigger.Conditions>
<BindingCondition Binding="{Binding AllowDataSubmission}" Value="True" />
<BindingCondition Binding="{Binding SessionState.LoadedProcedure.CurrentStep.eid}" Value="{Binding Data.eid}" />
<BindingCondition Binding="{Binding SessionState.LoadedProcedureMetadata.owner_id}" Value="{Binding SessionState.UserProfile.SessionId}" />
</MultiTrigger.Conditions>

Thanks

using scrollview with grid

$
0
0

how can use scrollview for this code?

<StackLayout>
    <RelativeLayout>
        <Grid BackgroundColor="White" RowSpacing="1" >
            <Grid.RowDefinitions>
                <RowDefinition Height="7*" />
                <RowDefinition Height="3*" />
                <RowDefinition Height="3*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="2*" />
                <ColumnDefinition Width="1*" />

            </Grid.ColumnDefinitions>

            <Grid Grid.Column="0" Grid.Row="0" RowSpacing="1"  >
                <imb:ImageButton  Source="@Resources/" />
            </Grid>
            <Grid Grid.Column="1" Grid.Row="0"  RowSpacing="1" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="2*" />
                    <RowDefinition Height="2*" />

                </Grid.RowDefinitions>
                <imb:ImageButton   Grid.Row="0" 
                   Source="@Resources/u.jpg"       />
                <imb:ImageButton  Grid.Row="1" 
                                  Source="@Resources/u.jpg" />

            </Grid>
            <Grid Grid.Row="1" Grid.Column="0" RowSpacing="1"   >
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="1*" />
                </Grid.RowDefinitions>

                <imb:ImageButton   BackgroundColor="Gold"  Grid.Row="0" />
                <imb:ImageButton   BackgroundColor="Gainsboro"  Grid.Row="1"  />
            </Grid>
            <Grid Grid.Row="1" Grid.Column="1" RowSpacing="1" >

                <imb:ImageButton  BackgroundColor="Aqua" />

            </Grid>
            <Grid Grid.Row="2" Grid.Column="0" RowSpacing="1" >

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="1*"/>
                </Grid.ColumnDefinitions>
                <imb:ImageButton    Grid.Column="0"  BackgroundColor="BlueViolet"  />

                <imb:ImageButton    BackgroundColor="AliceBlue"  />
            </Grid>
            <Grid Grid.Row="2" Grid.Column="1" RowSpacing="1" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="1*" />
                </Grid.RowDefinitions>
                <imb:ImageButton  BackgroundColor="Beige"  Grid.Row="0" />
                <imb:ImageButton  BackgroundColor="Bisque"  Grid.Row="1" />
            </Grid>
        </Grid>
    </RelativeLayout>

    <RelativeLayout  >
        <Grid  RowSpacing="1" >
            <Grid.RowDefinitions>
                <RowDefinition Height="1*" />
            </Grid.RowDefinitions>
            <imb:ImageButton Grid.Row="0" BackgroundColor="Orange" />
        </Grid>
    </RelativeLayout>

</StackLayout>

Flexlayout with itemtapped mvvm

$
0
0
Hi
I have been learning about flexlayout and I have seen few samples with custom flexlayout with itemsource and binding to a collection.

I am building a form (wraplayout square tiles) that has a flexlayout that should display images of products and when clicking on a product should popup a form with details
The vision app achievements form is exactly what I am trying to build but I need an itemtapped for my mvvm

I have tried to attach prism event attach item tapped but does not work

Any suggestion about adding an itemtapped?

All the samples do not show what you would do in real world. E.g. click something and pop up a form

Many thanks for any suggestions

How to auto upper-case text for Editor/Entry in Xamarin Forms in iOS 11.4

$
0
0

Hi guys,

In iOS version 11.2, I used this code to set auto upper-case text. It run OK.

*In Xamarin.Forms:

    public static readonly BindableProperty HasAutoUpperCaseTextProperty =
        BindableProperty.Create(
            nameof(HasAutoUpperCaseText),
            typeof(bool),
            typeof(EditorExtend),
            false);

    public bool HasAutoUpperCaseText
    {
        get { return (bool)GetValue(HasAutoUpperCaseTextProperty); }
        set { SetValue(HasAutoUpperCaseTextProperty, value); }
    }

*In iOS Renderer:

Control.AutocapitalizationType = UITextAutocapitalizationType.AllCharacters;

*Problem: After I upgraded OS version of iPAD to iOS 11.4, It run incorrectly.

Have you ever met this problem? How to fix it in iOS 11.4?

How to Implement Facebook Authentication in Xamarin.Forms using Firebase ?

$
0
0

I have been Trying to Achieve Facebook Authentication in Xamarin Forms using Firebase in my Application.

I tried Searching for the Documentation/Blogs/Videos to Achieve this, but I found the information regarding the Native Authentication(Xamarin.Android and Xamarin.iOS). Didn't find anything related to Xamarin.Forms.

Please Help me Achieving the Facebook Authentication in Xamarin.Forms.

Viewing all 91519 articles
Browse latest View live