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

Xamarin.Essentials Preferences do not work anymore (debug mode)

$
0
0

Hi,

I had some trouble with a piece of code which was not working (my bad), and I restored it successfully. This code uses Preferences from Xamarin Essentials, and as I thought the problem was with it, I updated it with NuGet in the whole solution.

But now my problem is fixed, and I still face an issue that I can't resolve... The code works because I made tests, but I am not able to retrieve preferences at startup. Yet, preferences are correctly set at runtime, I checked its value in the app !

So, is it a known issue with Preferences ? It does not work in debug mode, neither release mode...

Precision : as I changed this piece of code to make it smarter and to preserve MVVM, I already tested Preferences and it worked very well even in debug mode... But as I updated it before being able to build again, I can't compare...

Thanks,
Galactose

(In case it's not a known issue, here is my code:

using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using Xamarin.Essentials;
using CardioCALC.Models;

namespace CardioCALC.ViewModels
{
    public sealed class FavoritesViewModel : ViewModelBase
    {
        /*
         *  SINGLETON :
         *      - Instance
         *      - Constructors to avoir other instance and be thread-safe
         */
        public static FavoritesViewModel Instance { get; } = new FavoritesViewModel();

        static FavoritesViewModel()
        { }

        private FavoritesViewModel()
        {
            this.Favorites.CollectionChanged += OnFavoritesSaveChanges; // Autosave
        }


        /*
         *  CLASS : classic properties and methodes to be used in the singleton instance
         *      - separator : constant char for serialization/deserialization
         *      - favoritePreferenceKey : constant string to be used as Key in Xamarin.Essentials.Preferences
         *      - Methods to Add/Remove/Toggle favorites (update list AND the score instance)
         */

        private const char separator = ',';
        private const string favoritePreferenceKey = "favorites";

        public ObservableCollection<Score> Favorites { get; private set; } = new ObservableCollection<Score>();
        public ObservableCollection<Score> Scores { get => ScoreListViewModel.Instance.Scores; }

        public void ToggleFavorite(Score score)
        {
            if (score.IsFavorite) this.RemoveFavoriteAndUpdate(score);
            else this.AddFavoriteAndUpdate(score);
        }

        public void AddFavoriteAndUpdate(Score score)
        {
            score.IsFavorite = true;
            if (!this.Favorites.Contains(score)) this.Favorites.AddSorted(score);
        }

        public void RemoveFavoriteAndUpdate(Score favorite)
        {
            favorite.IsFavorite = false;
            this.Favorites.Remove(favorite);
        }

        // Auto-save favorites list with event
        private void OnFavoritesSaveChanges(object sender, NotifyCollectionChangedEventArgs e)
        {
            this.SaveFavorites();
        }


        /*
         *      Methods to Save/Load favorites from database/preferences(with serialization/deserialization)
         */
        public void LoadSavedFavorites()
        {
            this.Favorites.Clear(); // Clear favorites (ie. to reload favorites after locale change in ScoreListViewModel)

            string favorites = Preferences.Get(favoritePreferenceKey, "");
            if (favorites == "") return;

            foreach (Score favorite in this.Deserialize(favorites))
            {
                this.AddFavoriteAndUpdate(favorite);
            }
        }

        public void SaveFavorites()
        {
            if (this.Favorites.Count > 0)
                Preferences.Set(favoritePreferenceKey, this.Serialize());

            else Preferences.Remove(favoritePreferenceKey);
        }

        // Serialize favorites list into string format
        public string Serialize()
        {
            if (this.Favorites.Count < 1) return "";

            string favorites = "";
            foreach (Score favorite in this.Favorites)
            {
                favorites += $"{favorite.PageName}{separator}";
            }
            return favorites.TrimEnd(separator);
        }

        // Deserialize favorites list from string to restore Collection
        public ObservableCollection<Score> Deserialize(string favorites)
        {
            ObservableCollection<Score> favoritesList = new ObservableCollection<Score>();
            foreach(string favorite in favorites.Split(separator))
            {
                favoritesList.Add(this.Scores.FirstOrDefault(s => s.PageName == favorite)); // this.Scores contains all scores
            }
            return favoritesList;
        }
    }
}

MonoTorrent for Mobile Store

$
0
0

Good day Everyone

i want to add a functionality to my app that will be using "Monotorrent" , i saw a couple of posts about Stores rejecting apps that has such functionality. am seeking for advice.

Thanks

What is it that is actually being AWAITed?

$
0
0

In a call such as this:

await Navigation.PushAsync(new StateGridPage());
...more code...

When should ...more code.. be executed?

Is it:

  • After the new page has been pushed to the Navigation Stack?
  • After the new page has loaded?
  • After the new page has closed?
  • After something else?

Thank you.

ListView Renderers

$
0
0

Hi everyone,

I've made a sample App to test Xamarin.Forms ListView renderers because i've got some updating issues in a "production app" and i noticed something weird with bindings.

I'm using Xamarin.Forms 2.0, Xamarin.Android(Android 5+ Lollipops) and Xamarin.IOS (iOS 8+) and I followed this documentation
https://developer.xamarin.com/guides/cross-platform/xamarin-forms/custom-renderer/listview/

Here's what i've got:

  • A NativeListView subclass of ListView
  • An Android ListViewRenderer with his Adapter and a customCell.axml
  • An iOS ListViewRenderer with his Source and customCell.cs
  • A CellModel.cs which has only 2 properties (Title, Description)
  • A simple ViewModel (inherits from ViewModelBase because i use MVVMLight) containing an ObservableCollection, and 3 commands (Add, Reset, Clear).
  • A simple ContentPage with the NativeListView inside bound on the ViewModel collection property, and 3 buttons bound to the VM Commands.

Here's what happens:

  • If I use a Xamarin.Forms ListView bounds to the viewmodel, it's working fine, the page/listview are updated according to the VM's datasource.
  • If i use the NativeListView bounds to the viewmodel, and a renderer, both on iOS and Android, when I add / remove an item from the VM's datasource, it doesn't update at all. I never go in the Renderer OnElementPropertyChanged.
  • If i use the NativeListView bounds to the viewmodel and a renderer, both on iOS and Android, when I set the VM's datasource property, it does update the ListView.

So in my opinion it's not working as expected. I shouldn't have to reset the VM's datasource property each time i want to add / remove an object.

Am i missing something ?

I've attached the sample project below if you want to see the code.

Thanks,

Best regards,

Armand

PS : In the example, they use an Items BindableProperty on the NativeListView, but the result was the same so i just removed it and used the build in ItemSource ListView property.

Set window size of UWP application

$
0
0

I am writing a cross-platform (iOS, Android, UWP) application using PCL and Xamarin.Forms.

I use the UWP app for general testing since it is easier (don't need an emulator).

Is there a way to change the default window size of the UWP? I'd like it more "phone" shaped. It will help with estimating the layout (realizing I still may need to tweak on each platform).

Java.Lang.RuntimeException: Unable to instantiate receiver com.google.firebase.iid Error

$
0
0

Hi Xamarin Forum

I got this when I try to use OneSignal for making some notification

here is what happened

  1. I sent the message through OneSignal Dashboard
  2. Upon sending the debugger stopped and display this error

Java.Lang.RuntimeException: Unable to instantiate receiver com.google.firebase.iid.FirebaseInstanceIdReceiver: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.iid.FirebaseInstanceIdReceiver

How do I upload PDF/Docs in Xamarin form?

$
0
0

How do I upload PDF/Docs in Xamarin form? I am able to select and upload Image Files thought using MediaPicker though.

I seem to be doing something wrong as my new page is not appearing, any ideas?

$
0
0

He everyone. I am making a card/board game into an app and running into all kinds of issues with navigation. I am using NavigationPage and the worflow, currently (as I have tried all kinds of things) is currently like this.

App.Xaml.cs does this:
MainPage = new NavigationPage(new PlayersHandPage()) // Show players hand
Player then sees his/her cards clicks to select them and clicks 'Play'
Play() does this:
Navigation.PushAsync(new PlayingCards());

For testing, I am selecting 1 card and clicking play. That card requires me to select a state to go with it. In other testing scenarious the StateGridPage() seems to have proven itself to work correctly. States (50 U.S. states) are displayed and the user taps a state to go with the card. The one the user tapped is placed in memory and is returned properly. The way I tested this was:
App.Xaml.cs did a MainPage = new PlayersHandPage(). PlayersHandPage() called StateGridPage() which set SelectedState and returned control (via Navigation.PopAsync() back to PlayersHandPage(). So, I believe StateGridPage() is the one part of the process that actually seems to work.

Playing Cards is setup as a ContentPage to process cards until there are no more selected cards.

protected override void OnAppearing()
{
  PlayCards();
}

protected void PlayCards()
{
  while (App.CurrentGame.CurrentSelectedCards.Count > 0)
  {
    if (!App.CurrentGame.ProcessingPlay)
      PlayCard(App.CurrentGame.CurrentSelectedCards.FirstOrDefault());
    Task.Delay(100);
  }
  Navigation.PopAsync(); // This should occur when CurrentSelectedCards.Count == 0, sending the user back to the PlayersHandPage()
}

public void PlayCard(KeyValuePair<Int32, Models.Card> myCard)
{
  App.CurrentGame.ProcessingPlay = true; // doing this so PlayCard doesn't run multiple instances
  // .. checks are here to see what type of card is played
  // for the card I am testing it does this:
  if (App.CurrentGame.SelectedState == "") // SelectedState is set via StateGridPage()
    Navigation.PushAsyc(new StateGridPage());
  else
  {
    // .. SelectedState is modified to show the card was applied to it.
    // Selected card is deselected
    // Selected card is put in the discard pile
  }
  App.CurrentGame.ProcessingPlay = false;
}

So, in theory, App.Xaml.Cs should call PlayersHandPage. The player should select the card(s) and click Play. PlayingCards() [a Content Page] should then maintain control processing cards (adding money to user, paying taxes, etc) and calling StateGridPage() for user input as needed. Then, it should pass control back to PlayersHandPage() via Navigation.PopAsync().

Instead, what is happening is this:

  • App.Xaml.Cs calls PlayersHandPage
  • User clicks a single card and play
  • This calls PlayingCards [Page]
  • This calls PlayCards
  • This calls PlayCard (with the selected card)
  • I can then see SelectStateGrid() code get called (via a breakpoint), but without the breakpoint, the SelectStateGrid() page never appears.

On thing I tried (not related to the issue, but I think it would be next) was to move "App.CurrentGame.ProcessingPlay = false;" into the else (ie. just above the } ) and into the StateGridPage.

Any ideas or suggestions to try would be appreciated. I've written and re-written and tried so many things. I have no idea what I am doing wrong. I don't understand why the StateGridPage() does not appear in with this setup.

Thank you.


Remove rows from Grid

$
0
0

Hi,
I try to remove 1 row from a Grid, but after the remove, I still have a space and the defintion of the row. Here is my C#

`var Btn = (ImageButton)sender;
var myGrid = Btn.Parent as Grid;
var rowNb = Grid.GetRow(Btn);

        var childGrid = myGrid.Children.ToList();

        foreach (var row in childGrid.Where(r => Grid.GetRow(r) == rowNb))
        {
            maGrille.Children.Remove(row);
        }

        foreach (var row in childGrid.Where(c => Grid.GetRow(c) > rowNb))
        {
            Grid.SetRow(row, Grid.GetRow(row) - 1);
        }

`
After that, the row is deleted because I can't see anymore the content of the row but if I add a new row to the grid, the previous row definition still exist and I have a large space between the rows. Any ideas ?

Thx,
Q.

Has anybody got the Xamarin.Essentials WebAuth sample working?

$
0
0

How is the authentication token supposed to be used? It doesn't work as a Bearer. Or I'm doing something wrong.

iOS Binding Unity as a library

$
0
0

Hi all,

I don't even know where to start :D

Since alpha 2019.3 Unity offers the feature "Unity as a Library" https://blogs.unity3d.com/2019/06/17/add-features-powered-by-unity-to-native-mobile-apps/ which I'm currently trying to integrate into one of our Xamarin Apps.
There are descriptions how to do that natively for Android and iOS which I got both working fine.
Just for reference:
https://forum.unity.com/threads/integration-unity-as-a-library-in-native-ios-app.685219/
https://forum.unity.com/threads/integration-unity-as-a-library-in-native-android-app.685240/
This is actually a really big deal so it is great working on it :D

However, I got it working fine for Xamarin Android. Now I'm trying on iOS which appears to be much more complicated.

The unity project will be exported as a native Objective-C++ framework (I think at least as there are .mm files using Objective C)
When using Sharpie to bind the framework I get a super large APIDefinitions file.
After some research I figured out that I have to define a scope to the Headers of the Framework, then the APIDefinitions are in fact much smaller and only reference the header files.

Now to my (current) problem:

If I open the ApiDefinitions then there is an interface UnityFramewok which comes from the UnityFramework.h file.
But this header holds a reference to a class UnityView which is not part of the headers. It is within the framework( at least it is within the Library project in Xcode so I assume it is bundled into the framework.)
I copied the .framework into the bindings Native References but I can't see any actual change happening when I do that.
The UnityView can not be found within the interface and I also can't import it from the library because the native reference is not available.

So how can I reference to a class of the framework from within an interface that is defined in the ApiDefinitions?

Thank you already!

How do I access Dropbox, OneDrive or Drive from Xamarin Forms?

$
0
0

I need to access Dropbox, OneDrive or Drive from Xamarin Forms. I have found a couple of nuget packages that look promising. I have also found a tutorial for Dropbox (Dropbox Integration) but this seems to miss out a couple of important details about how to do the authorization.

Given time, I'll work this out, and I don't expect anyone to write my code for me, but can anyone point me at good examples of how to go about doing this?

For now, I am only using this during development so can use any of my personal cloud accounts if that simplifies things.

Any help would be welcome.

Kind wishes - Patrick

being plagued by error when trying to implement google ad mob in xamarin forms

$
0
0

MediationRewardedVideoAdListenerImplementor is not abstract and does not override abstract method zzc(Bundle) in MediationRewardedVideoAdListener
public class MediationRewardedVideoAdListenerImplementor SocialFeedTest.Android C:\Users\blain\source\repos\SocialFeedTest\SocialFeedTest\SocialFeedTest.Android\obj\Debug\90\android\src\mono\com\google\android\gms\ads\reward\mediation\MediationRewardedVideoAdListenerImplementor.java 4

following this tutorial here https://xamarinhelp.com/admob-xamarin-forms-display-google-ads-mobile-app/

heres my code

xamarin.forms

 using System;
 using System.Collections.Generic;
 using System.Text;
 using Xamarin.Forms;

namespace SocialFeedTest.Control
{
public class AdMobView : View
{
    public static readonly BindableProperty AdUnitIdProperty = BindableProperty.Create(
                   nameof(AdUnitId),
                   typeof(string),
                   typeof(AdMobView),
                   string.Empty);

    public string AdUnitId
    {
        get => (string)GetValue(AdUnitIdProperty);
        set => SetValue(AdUnitIdProperty, value);
    }
  }

}

android

renderer

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.Gms.Ads;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using SocialFeedTest.Control;
using SocialFeedTest.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(AdMobView), typeof(AdMobViewRenderer))]

namespace SocialFeedTest.Droid
{
   public class AdMobViewRenderer : ViewRenderer<AdMobView, AdView>
{
    public AdMobViewRenderer(Context context) : base(context) { }

    protected override void OnElementChanged(ElementChangedEventArgs<AdMobView> e)
    {
        base.OnElementChanged(e);

        if (e.NewElement != null && Control == null)
            SetNativeControl(CreateAdView());
    }

    protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        base.OnElementPropertyChanged(sender, e);

        if (e.PropertyName == nameof(AdView.AdUnitId))
            Control.AdUnitId = Element.AdUnitId;
    }

    private AdView CreateAdView()
    {
        var adView = new AdView(Context)
        {
            AdSize = AdSize.SmartBanner,
            AdUnitId = Element.AdUnitId
        };

        adView.LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);

        adView.LoadAd(new AdRequest.Builder().Build());

        return adView;
    }
    } 
}

main activity

   using System;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace SocialFeedTest.Droid
{
    [Activity(Label = "SocialFeedTest", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges =                   ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
  public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
    protected override void OnCreate(Bundle savedInstanceState)
    {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate(savedInstanceState);
        Android.Gms.Ads.MobileAds.Initialize(ApplicationContext, "ca-app-pub-5184019642309342~9928782520");
        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        LoadApplication(new App());
    }
    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[]  grantResults)
    {
        Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

        base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    }
  }
}

ios

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

using Foundation;
using Google.MobileAds;
using SocialFeedTest.Control;
using SocialFeedTest.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(AdMobView), typeof(AdMobViewRenderer))]
namespace SocialFeedTest.iOS
{

   public class AdMobViewRenderer : ViewRenderer<AdMobView, BannerView>
   {
    protected override void OnElementChanged(ElementChangedEventArgs<AdMobView> e)
    {
        base.OnElementChanged(e);
        if (Control == null)
        {
            SetNativeControl(CreateBannerView());
        }
    }

    protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        base.OnElementPropertyChanged(sender, e);

        if (e.PropertyName == nameof(BannerView.AdUnitId))
            Control.AdUnitId = Element.AdUnitId;
    }

    private BannerView CreateBannerView()
    {
        var bannerView = new BannerView(AdSizeCons.SmartBannerPortrait)
        {
            AdUnitId = Element.AdUnitId,
            RootViewController = GetVisibleViewController()
        };

        bannerView.LoadRequest(GetRequest());

        Request GetRequest()
        {
            var request = Request.GetDefaultRequest();
            return request;
        }

        return bannerView;
    }

    private UIViewController GetVisibleViewController()
    {
        var windows = UIApplication.SharedApplication.Windows;
        foreach (var window in windows)
        {
            if (window.RootViewController != null)
            {
                return window.RootViewController;
            }
        }
        return null;
    }
  }

}

main

using System;
using System.Collections.Generic;
using System.Linq;

using Foundation;
using UIKit;

namespace SocialFeedTest.iOS
{
   public class Application
    {
    // This is the main entry point of the application.
    static void Main(string[] args)
    {
        // if you want to use a different Application Delegate class from "AppDelegate"
        // you can specify it here.
        UIApplication.Main(args, null, "AppDelegate");
    }
  }
}

Invoking OnElementChanged to map custom map renderer update

$
0
0

I've modified a code sample so I can draw a circle on a map around a Pin (to simulate a Geofence)

The method I've used calls OnElementChanged only once when the map is created so if I update the pins afterwards (and that all works fine) my custom renderer is never called again

Please can someone advise the best method whereby I can redraw my list of geofence circles on the map as co-ordinates change?

Add two text items to a listView with Data Binding

$
0
0

Hi,

I'm very new to this and I did some research on how to do this, but without succes. I hope someone here is able to help me.

So I have an API which returns a value (string) when a item is given as input. Let's say that when I put "item1" in the API, it returns "value1". Now I want to show "item1" and "value1" in the same list, where "item1" is on the far left and "value1" is on the far right. This would look something like this:

item1 value1
item2 value2
item3 value3
item4 value4

I've read that Data Binding is the solution to do this. I looked at this question: https://forums.xamarin.com/discussion/57739/listview-with-2-labels-one-left-andone-right . This seems to be the solution to my problem. However, I have no idea how Data Binding works and how to set it up. I've read some documentation about this and I'm able to bind some things (like styles), but not this.

For example, looking at this part of the question asked (see link above):

I can see "Text="{Binding Text}" ", but I have no idea how to make sure the label displays the correct item and value in the correct label.

It's a bit of a long story, but I hope my problem is clear.

Regards, Ganesh


How to make editable dropdown or combobox in xamarin form.

$
0
0

Hello All,

How to make editable dropdown or combobox in xamarin form?

Map tile display using SkiaSharp

$
0
0

Hello.

I want to display the acquired OSM or GSI image in tile form using SkiShrap.

I tried the code below but it doesn't work

If there is something wrong, please let me know.

private async void Pic()
{

    try
    {

        for (int i = 0; i <= 10; i++)
        {
            for (int j = 0; j <= 10; i++)
            {
                string url = "";

                url = "http://cyberjapandata.gsi.go.jp/xyz/seamlessphoto/" + Zoom + "/" + i + "/" + j + ".jpg";

                try
                {
                    var httpClient = new HttpClient();
                    using (Stream stream = await httpClient.GetStreamAsync(url))
                    using (MemoryStream memStream = new MemoryStream())
                    {
                        await stream.CopyToAsync(memStream);
                        memStream.Seek(0, SeekOrigin.Begin);
                        bitmaps.Add(SKBitmap.Decode(memStream));
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Error", ex.Message, "OK");
                }
            }

        }
        SKCanvasView canvasView = new SKCanvasView { WidthRequest = 500 };
        canvasView.PaintSurface += OnCanvasViewPaintSurface;
        Content = new ScrollView { Content = canvasView, Orientation = ScrollOrientation.Horizontal };
    }
    catch
    {
    }

}

[Obsolete]
private void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
{
    try
    {

        SKImageInfo info = args.Info;
        SKSurface surface = args.Surface;
        SKCanvas canvas = surface.Canvas;

        canvas.Clear();

        using (surface = SKSurface.Create(new SKImageInfo(500, 500)))
        {
            for (int i = 0; i < bitmaps.Count; i++)
            {
                canvas.DrawBitmap(bitmaps[i], 256 * i, 0, null);
            }
        }


    }
    catch
    {

    }

}

WebAuthenticator and Controller with [Authenticate] attrib

$
0
0

I am using WebAuthenticator from Xamarin.Essentials, I downloaded the XamEssentialsDemo.WebAuthenticator, published this to Azure,
configured login for Microsoft and Google. I am able to Login with these two and I have the token in my hand.

Now I tried to add a new controller with the [Authorize] attribute and used the HttpClient class to call my method in the new controller (after authenticating), but I can't get this to work, within the Xamarin Application, I get a 404 not found - it seems that I am not authenticated as I get redirected to Acccount/Login.

My new controller:

[Route("calculate")]
[ApiController]
[Authorize]
public class CalculateController : ControllerBase
{
    [HttpGet("{km}/{liter}")]
    public IActionResult Get([FromRoute] float km, [FromRoute] float liter)
    {
        return Ok(liter / km * 100f);
    }
}

My call from Xamarin.Forms (AuthToken is the token either from the Microsoft login, or the Google login):

            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Authorization =
                new AuthenticationHeaderValue("bearer", AuthToken);
            var result = await client.GetStringAsync("<myazurewebsiteurl>/calculate/700/50");

If I call the url from within chrome in the Android emulator I get the result (as I am logged in with my google account).
Any help appreciated, as I play around with it since two days.....

How to dismiss Essentials.WebAuthenticator iOS window after successful auth?

$
0
0

I'm using Xamarin.Essentials.WebAuthenticator for OAuth SSO and it's working great for both iOS and Android to get me authorized, but on iOS the dang ASWebAuthenticationSession window just sits open after the auth succeeds. How do I make it close? I can see that my app gets authed in behind the window and proceeds normally, and if I tap Cancel in the top left of the window it closes and I can go on my merry way, but I don't want my users to have to do that. Am I doing something wrong? If the rest of it is working I can't see how that could be the case. Is this based on the behavior of the particular IDP? My app is obviously catching the redirect just fine and I could just close the window programmatically, but how? And I imagine having to do it myself is not the intended behavior.

For more specifics, I have Universal Links set up (and working) and I'm doing my testing with Github as the IDP.

Expander error

$
0
0

Hi,

i'm getting a extrange error with new Expander control and an error of System.Reflection.TargetInvocationException, because in another test project it's working, at least a basic test.
I've a content page, with a Pancake View, with a Collection View, and i haven't any Expander control.
And here comes strange error, if i only add Device.SetFlags(new string[] { "Expander_Experimental" }); to App.xml.cs, and not add a Expander control in View, when i navigate to page (i'm in MVVM model), i get a System.Reflection.TargetInvocationException.

This is the output result.

05-03 12:02:50.978 D/Mono ( 3498): Requesting loading reference 13 (of 20) of /storage/emulated/0/Android/data/com.test.Test.Mobile/files/.override/Test.Mobile.dll
05-03 12:02:50.978 D/Mono ( 3498): Loading reference 13 of /storage/emulated/0/Android/data/com.test.Test.Mobile/files/.override/Test.Mobile.dll asmctx DEFAULT, looking for Xamarin.Forms.PancakeView, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null
05-03 12:02:50.978 D/Mono ( 3498): Assembly Ref addref Test.Mobile[0xaac20e60] -> Xamarin.Forms.PancakeView[0xab27b9e0]: 2
Loaded assembly: Anonymously Hosted DynamicMethods Assembly [External]
System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'

Another error, if i set a breakpoint into source ViewModel (MainViewModel), where i've a command to navigate to this page (ExpanderViewModel->ExpanderPage), i'm getting too System.Reflection.TargetInvocationException , but in System.Core. And brekpoint doesn't work,

async Task ViewTestExpander() {
        if (Condition)  //BreakPoint here, and doesn't work
                await NavigationService.NavigateToAsync(typeof(ViewModels.Main.ExpanderViewModel)).ConfigureAwait(false);
            }

if i remove this line Device.SetFlags(new string[] { "Expander_Experimental" }); from App.xml.cs, all works fine.

Any idea, or suggestion?
Many thanks guys

Viewing all 77050 articles
Browse latest View live


Latest Images

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